Skip to content

Commit 2b72b71

Browse files
committed
unit: more tests for stepper mutations
1 parent 879ad22 commit 2b72b71

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/helpers/state-machine/form/mutations/__tests__/form-state-mutations.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ describe('FormMutations', () => {
126126
expect(stateMachineService.state.value).toStrictEqual({"formUI": "dirty"});
127127
});
128128

129+
it('stepChange', () => {
130+
const updateMutation = stateMachineService.send('updateTabIndex', {
131+
stepName: '',
132+
});
133+
const contextMutations = JSON.parse(JSON.stringify(updateMutation.context));
134+
delete contextMutations.effects;
135+
const expected = {"formData": {"test": "test-2"}, "formSchema": {}, "formSchemaXHR": {"new": "info"}, "hasError": false, "hasXHRError": false, "lastField": "test", "parsedFormSchema": {}, "uiData": {}, "uiSchema": {"ui:page": {"props": {"ui:schemaErrors": true}, "style": {"boxShadow": "none"}, "tab": {"style": {"minWidth": 81}}, "tabs": {"props": {}, "style": {"marginTop": 10, "width": "29vw"}}, "ui:layout": "tabs"}}, "validation": {}, "validations": {}, "xhrProgress": {"undefined": false}, "xhrSchema": {"ui:errors": {"offline": {"message": "Please try again once you are online.", "title": "You are Offline !"}}}}
136+
expect(contextMutations).toStrictEqual(expected);
137+
expect(onChange).toHaveBeenCalled();
138+
expect(stateMachineService.state.value).toStrictEqual({"formUI": "dirty"});
139+
});
140+
129141
it('updateTabIndex', () => {
130142
const updateMutation = stateMachineService.send('updateTabIndex', {
131143
tabIndex: 1,
@@ -138,6 +150,7 @@ describe('FormMutations', () => {
138150
expect(stateMachineService.state.value).toStrictEqual({"formUI": "dirty"});
139151
});
140152

153+
141154
it('updateArrayData', () => {
142155
const updateArrayFN = jest.fn();
143156
const updateMutation = stateMachineService.send('moveItemUp', {

src/helpers/state-machine/form/mutations/__tests__/stepper-state-mutations.spec.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)