@legalplace/wizardx-core 4.42.10-nightly.20251125120616 → 4.42.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -376
- package/dist/App.d.ts +6 -1
- package/dist/App.js +7 -2
- package/dist/App.test.js +37 -0
- package/dist/Loader.d.ts +1 -1
- package/dist/Loader.js +1 -1
- package/dist/PluginLoader.d.ts +36 -21
- package/dist/PluginLoader.js +227 -90
- package/dist/PluginLoader.test.d.ts +1 -0
- package/dist/PluginLoader.test.js +52 -0
- package/dist/Shimmer.d.ts +11 -8
- package/dist/Shimmer.js +4 -4
- package/dist/ThemeLoader.d.ts +8 -8
- package/dist/ThemeLoader.test.d.ts +2 -0
- package/dist/ThemeLoader.test.js +65 -0
- package/dist/components/PluginRoute.d.ts +2 -2
- package/dist/components/PluginRoute.js +4 -3
- package/dist/components/SmartScript.d.ts +6 -2
- package/dist/components/SmartScript.js +1 -1
- package/dist/components/UserLocked/UserLockedComponent.js +2 -2
- package/dist/components/View.d.ts +3 -3
- package/dist/components/View.js +7 -5
- package/dist/components/View.test.d.ts +2 -0
- package/dist/components/View.test.js +84 -0
- package/dist/componentsConnectors/connectBox.d.ts +6 -4
- package/dist/componentsConnectors/connectBox.test.d.ts +1 -0
- package/dist/componentsConnectors/connectBox.test.js +218 -0
- package/dist/componentsConnectors/connectDocument.d.ts +6 -4
- package/dist/componentsConnectors/connectDocument.test.d.ts +1 -0
- package/dist/componentsConnectors/connectDocument.test.js +95 -0
- package/dist/componentsConnectors/connectHeader.d.ts +6 -4
- package/dist/componentsConnectors/connectMetaTitle.d.ts +7 -3
- package/dist/componentsConnectors/connectMetaTitle.test.d.ts +1 -0
- package/dist/componentsConnectors/connectMetaTitle.test.js +32 -0
- package/dist/componentsConnectors/connectOption.d.ts +7 -5
- package/dist/componentsConnectors/connectPagination.d.ts +7 -5
- package/dist/componentsConnectors/connectPreview.d.ts +7 -3
- package/dist/componentsConnectors/connectProgress.d.ts +6 -4
- package/dist/componentsConnectors/connectRootOption.d.ts +7 -5
- package/dist/componentsConnectors/connectSection.d.ts +6 -4
- package/dist/componentsConnectors/connectSummary.d.ts +9 -5
- package/dist/componentsConnectors/connectSummaryItem.d.ts +6 -4
- package/dist/componentsConnectors/connectTermsheet.js +1 -1
- package/dist/componentsConnectors/connectVariable.d.ts +8 -6
- package/dist/componentsConnectors/connectWizardWrapper.d.ts +6 -4
- package/dist/componentsConnectors/connector/componentConnector.d.ts +10 -7
- package/dist/componentsConnectors/connector/componentConnector.js +3 -3
- package/dist/componentsConnectors/library.d.ts +81 -47
- package/dist/config.test.d.ts +1 -0
- package/dist/config.test.js +54 -0
- package/dist/helpers/activitiesHelper.d.ts +3 -3
- package/dist/helpers/autocomplete.helper.d.ts +2 -2
- package/dist/helpers/autocomplete.helper.js +1 -1
- package/dist/helpers/autosave.helper.d.ts +13 -3
- package/dist/helpers/autosave.helper.js +70 -3
- package/dist/helpers/inpiCitiesHelper.js +1 -1
- package/dist/helpers/outputsParsing.d.ts +9 -9
- package/dist/hooks/useDispatch.d.ts +1 -1
- package/dist/hooks/usePrevious.js +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/libs/ConditionsRunner.d.ts +1 -1
- package/dist/libs/Formatter/FormatAddress.d.ts +1 -1
- package/dist/libs/InputsInitiator.d.ts +1 -1
- package/dist/libs/NumAuto.test.d.ts +1 -0
- package/dist/libs/NumAuto.test.js +43 -0
- package/dist/libs/PathReader.d.ts +1 -96
- package/dist/libs/PathReader.js +2 -1
- package/dist/libs/SectionValidity.test.d.ts +1 -0
- package/dist/libs/SectionValidity.test.js +116 -0
- package/dist/libs/SmartScriptStore.d.ts +6 -6
- package/dist/redux/actions/app.d.ts +1 -1
- package/dist/redux/actions/app.test.d.ts +1 -0
- package/dist/redux/actions/app.test.js +90 -0
- package/dist/redux/actions/conditions.test.d.ts +1 -0
- package/dist/redux/actions/conditions.test.js +68 -0
- package/dist/redux/actions/inputs.d.ts +1 -1
- package/dist/redux/actions/inputs.test.d.ts +1 -0
- package/dist/redux/actions/inputs.test.js +53 -0
- package/dist/redux/actions/library.d.ts +21 -15
- package/dist/redux/actions/references.d.ts +2 -2
- package/dist/redux/actions/references.test.d.ts +1 -0
- package/dist/redux/actions/references.test.js +43 -0
- package/dist/redux/actions/sagas/data.d.ts +1 -1
- package/dist/redux/actions/sagas/data.test.d.ts +1 -0
- package/dist/redux/actions/sagas/data.test.js +11 -0
- package/dist/redux/actions/sagas/model.test.d.ts +1 -0
- package/dist/redux/actions/sagas/model.test.js +11 -0
- package/dist/redux/actions/sagas/user.d.ts +1 -1
- package/dist/redux/actions/user.test.d.ts +1 -0
- package/dist/redux/actions/user.test.js +16 -0
- package/dist/redux/listeners/subscriber.d.ts +1 -1
- package/dist/redux/listeners/subscriber.test.d.ts +1 -0
- package/dist/redux/listeners/subscriber.test.js +31 -0
- package/dist/redux/middlewares/conditionsWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/conditionsWatcherMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +330 -0
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.js +242 -0
- package/dist/redux/middlewares/mandatoriesWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/multiplesActionsMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/multiplesActionsMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/multiplesActionsMiddleware.test.js +209 -0
- package/dist/redux/middlewares/paginationWatcherMiddleware.d.ts +2 -2
- package/dist/redux/middlewares/pluginsHookMiddleware.d.ts +2 -1
- package/dist/redux/middlewares/pluginsHookMiddleware.js +7 -1
- package/dist/redux/middlewares/prefillerWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/prefillerWatcherMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/prefillerWatcherMiddleware.test.js +84 -0
- package/dist/redux/middlewares/smartscriptMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/smartscriptMiddleware.js +2 -2
- package/dist/redux/middlewares/thirdpartyScriptsMiddleware.d.ts +1 -1
- package/dist/redux/reducers/app/instance.test.d.ts +1 -0
- package/dist/redux/reducers/app/instance.test.js +75 -0
- package/dist/redux/reducers/app/meta.test.d.ts +1 -0
- package/dist/redux/reducers/app/meta.test.js +70 -0
- package/dist/redux/reducers/app/pagination/updateAvailableAppStates.js +2 -1
- package/dist/redux/reducers/app/pagination.test.d.ts +1 -0
- package/dist/redux/reducers/app/pagination.test.js +134 -0
- package/dist/redux/reducers/app/wizard.test.d.ts +1 -0
- package/dist/redux/reducers/app/wizard.test.js +53 -0
- package/dist/redux/reducers/app.d.ts +6 -6
- package/dist/redux/reducers/app.test.d.ts +1 -0
- package/dist/redux/reducers/app.test.js +175 -0
- package/dist/redux/reducers/conditions/addMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/addMultipleOccurency.test.js +108 -0
- package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.js +77 -0
- package/dist/redux/reducers/conditions/updateDocumentConditions.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/updateDocumentConditions.test.js +35 -0
- package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.js +35 -0
- package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.js +35 -0
- package/dist/redux/reducers/conditions.test.d.ts +1 -0
- package/dist/redux/reducers/conditions.test.js +196 -0
- package/dist/redux/reducers/inputs/addMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/inputs/addMultipleOccurency.test.js +101 -0
- package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.js +56 -0
- package/dist/redux/reducers/inputs.test.d.ts +1 -0
- package/dist/redux/reducers/inputs.test.js +171 -0
- package/dist/redux/reducers/references.js +0 -2
- package/dist/redux/reducers/user.test.d.ts +1 -0
- package/dist/redux/reducers/user.test.js +42 -0
- package/dist/redux/routerHistore.test.d.ts +1 -0
- package/dist/redux/routerHistore.test.js +15 -0
- package/dist/redux/sagas/fetchModel.test.d.ts +1 -0
- package/dist/redux/sagas/fetchModel.test.js +127 -0
- package/dist/redux/sagas/runner.test.d.ts +1 -0
- package/dist/redux/sagas/runner.test.js +10 -0
- package/dist/redux/sagas/saveData.test.d.ts +1 -0
- package/dist/redux/sagas/saveData.test.js +74 -0
- package/dist/redux/sagas/setDefaults.test.d.ts +1 -0
- package/dist/redux/sagas/setDefaults.test.js +73 -0
- package/dist/redux/selectors/app.test.d.ts +1 -0
- package/dist/redux/selectors/app.test.js +99 -0
- package/dist/redux/selectors/conditions.test.d.ts +1 -0
- package/dist/redux/selectors/conditions.test.js +70 -0
- package/dist/redux/selectors/inputs.d.ts +1 -1
- package/dist/redux/selectors/inputs.test.d.ts +1 -0
- package/dist/redux/selectors/inputs.test.js +44 -0
- package/dist/redux/selectors/references.test.d.ts +1 -0
- package/dist/redux/selectors/references.test.js +471 -0
- package/dist/redux/selectors/selectors.d.ts +4 -4
- package/dist/redux/selectors/selectors.test.d.ts +1 -0
- package/dist/redux/selectors/selectors.test.js +16 -0
- package/dist/redux/selectors/user.test.d.ts +1 -0
- package/dist/redux/selectors/user.test.js +29 -0
- package/dist/redux/store.d.ts +3 -5
- package/dist/redux/store.js +1 -2
- package/dist/redux/store.test.d.ts +1 -0
- package/dist/redux/store.test.js +16 -0
- package/dist/service/api.manager.d.ts +2 -2
- package/dist/service/autocomplete.manager.d.ts +3 -3
- package/dist/service/autocomplete.manager.js +3 -3
- package/dist/tests-misc/plugins/jestTestPlugin/after.js +1 -1
- package/dist/tests-misc/plugins/jestTestPlugin/before.js +1 -1
- package/dist/tests-misc/plugins/jestTestPlugin/title.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.d.ts +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.d.ts +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.d.ts +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.js +1 -1
- package/dist/types/Actions.type.d.ts +6 -70
- package/dist/types/Components.type.d.ts +2 -3
- package/dist/types/PluginConfig.type.d.ts +52 -18
- package/dist/types/State.type.d.ts +2 -2
- package/dist/types/config.type.d.ts +1 -1
- package/dist/types/getActions.type.d.ts +1 -1
- package/dist/types/getConnectors.type.d.ts +2 -2
- package/dist/types/getSelectors.type.d.ts +1 -1
- package/package.json +22 -45
- package/dist/WizardCore.d.ts +0 -29
- package/dist/WizardCore.js +0 -153
- package/dist/app.entry.d.ts +0 -2
- package/dist/app.entry.js +0 -1
- package/dist/routing/adapters/nextjs.adapter.d.ts +0 -3
- package/dist/routing/adapters/nextjs.adapter.js +0 -61
- package/dist/routing/adapters/reactRouter.adapter.d.ts +0 -2
- package/dist/routing/adapters/reactRouter.adapter.js +0 -16
- package/dist/routing/context.d.ts +0 -14
- package/dist/routing/context.js +0 -23
- package/dist/routing/index.d.ts +0 -4
- package/dist/routing/index.js +0 -4
- package/dist/routing/types.d.ts +0 -26
- package/dist/wizardcore.entry.d.ts +0 -3
- package/dist/wizardcore.entry.js +0 -2
- /package/dist/{routing/types.js → App.test.d.ts} +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { deleteMultipleOccurencyReducer } from './deleteMultipleOccurency';
|
|
2
|
+
const state = {
|
|
3
|
+
options: {
|
|
4
|
+
4: [true, false, true],
|
|
5
|
+
},
|
|
6
|
+
variables: {
|
|
7
|
+
2: [false, true, false],
|
|
8
|
+
},
|
|
9
|
+
validators: {
|
|
10
|
+
options: {
|
|
11
|
+
4: [false, false, true],
|
|
12
|
+
},
|
|
13
|
+
variables: {
|
|
14
|
+
3: [true, false, true],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
documents: {},
|
|
18
|
+
sections: {},
|
|
19
|
+
prefillers: {
|
|
20
|
+
3: [
|
|
21
|
+
[true, false, false],
|
|
22
|
+
[false, true, false],
|
|
23
|
+
[false, false, true],
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
describe('deleteMultipleOccurencyReducer test suit', () => {
|
|
28
|
+
it('Throws an error if optionRelations or prefillersVariables are undefined', () => {
|
|
29
|
+
expect(() => {
|
|
30
|
+
deleteMultipleOccurencyReducer(state, {
|
|
31
|
+
id: 3,
|
|
32
|
+
optionRelations: undefined,
|
|
33
|
+
});
|
|
34
|
+
}).toThrowError('DELETE_MULTIPLE_OCCURENCY reducer did not recieve complete data when removing occurency for 3,' +
|
|
35
|
+
' please make sure "multiplesActions" middleware is plugged and working properly');
|
|
36
|
+
});
|
|
37
|
+
it('Adds a multiple occurency conditions correctly', () => {
|
|
38
|
+
const optionRelations = {
|
|
39
|
+
options: [],
|
|
40
|
+
variables: [],
|
|
41
|
+
sections: {},
|
|
42
|
+
documents: [],
|
|
43
|
+
prefillers: [],
|
|
44
|
+
validators: {
|
|
45
|
+
options: [],
|
|
46
|
+
variables: [],
|
|
47
|
+
},
|
|
48
|
+
parents: [],
|
|
49
|
+
children: {
|
|
50
|
+
options: [3, 4],
|
|
51
|
+
variables: [2, 3],
|
|
52
|
+
},
|
|
53
|
+
dependants: [7, 8],
|
|
54
|
+
};
|
|
55
|
+
const reducerResult = deleteMultipleOccurencyReducer(state, {
|
|
56
|
+
id: 2,
|
|
57
|
+
index: 1,
|
|
58
|
+
optionRelations,
|
|
59
|
+
type: 'DELETE_MULTIPLE_OCCURENCY',
|
|
60
|
+
});
|
|
61
|
+
expect(reducerResult).toStrictEqual(Object.assign(Object.assign({}, state), { options: Object.assign(Object.assign({}, state.options), { 4: [true, true] }), variables: {
|
|
62
|
+
2: [false, false],
|
|
63
|
+
}, prefillers: {
|
|
64
|
+
3: [
|
|
65
|
+
[true, false, false],
|
|
66
|
+
[false, false, true],
|
|
67
|
+
],
|
|
68
|
+
}, validators: {
|
|
69
|
+
options: {
|
|
70
|
+
4: [false, true],
|
|
71
|
+
},
|
|
72
|
+
variables: {
|
|
73
|
+
3: [true, true],
|
|
74
|
+
},
|
|
75
|
+
} }));
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { updateDocumentConditionReducer } from './updateDocumentConditions';
|
|
2
|
+
import { UPDATE_DOCUMENT_CONDITION } from '../../constants/conditions';
|
|
3
|
+
const state = {
|
|
4
|
+
options: {},
|
|
5
|
+
variables: {},
|
|
6
|
+
validators: {
|
|
7
|
+
options: {},
|
|
8
|
+
variables: {},
|
|
9
|
+
},
|
|
10
|
+
documents: {
|
|
11
|
+
'test-document-1': true,
|
|
12
|
+
'test-document-2': false,
|
|
13
|
+
'test-document-3': true,
|
|
14
|
+
},
|
|
15
|
+
sections: {},
|
|
16
|
+
prefillers: {},
|
|
17
|
+
};
|
|
18
|
+
describe('updateDocumentConditionReducer test suit', () => {
|
|
19
|
+
it('Updates document condition properly', () => {
|
|
20
|
+
const reducerResult = updateDocumentConditionReducer(state, {
|
|
21
|
+
type: UPDATE_DOCUMENT_CONDITION,
|
|
22
|
+
name: 'test-document-2',
|
|
23
|
+
value: true,
|
|
24
|
+
});
|
|
25
|
+
expect(reducerResult).toStrictEqual(Object.assign(Object.assign({}, state), { documents: Object.assign(Object.assign({}, state.documents), { 'test-document-2': true }) }));
|
|
26
|
+
});
|
|
27
|
+
it('Returns same state without touching references if condition did not change', () => {
|
|
28
|
+
const reducerResult = updateDocumentConditionReducer(state, {
|
|
29
|
+
type: UPDATE_DOCUMENT_CONDITION,
|
|
30
|
+
name: 'test-document-2',
|
|
31
|
+
value: false,
|
|
32
|
+
});
|
|
33
|
+
expect(reducerResult).toEqual(state);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { updateOptionValidatorConditionReducer } from './updateOptionValidatorCondition';
|
|
2
|
+
import { UPDATE_OPTION_VALIDATOR_CONDITION } from '../../constants/conditions';
|
|
3
|
+
const state = {
|
|
4
|
+
options: {},
|
|
5
|
+
variables: {},
|
|
6
|
+
validators: {
|
|
7
|
+
options: {
|
|
8
|
+
2: [false, true, false],
|
|
9
|
+
},
|
|
10
|
+
variables: {},
|
|
11
|
+
},
|
|
12
|
+
documents: {},
|
|
13
|
+
sections: {},
|
|
14
|
+
prefillers: {},
|
|
15
|
+
};
|
|
16
|
+
describe('updateOptionValidatorConditionReducer test suit', () => {
|
|
17
|
+
it('Updates option validator condition properly', () => {
|
|
18
|
+
const reducerResult = updateOptionValidatorConditionReducer(state, {
|
|
19
|
+
type: UPDATE_OPTION_VALIDATOR_CONDITION,
|
|
20
|
+
id: 2,
|
|
21
|
+
index: 1,
|
|
22
|
+
value: false,
|
|
23
|
+
});
|
|
24
|
+
expect(reducerResult).toStrictEqual(Object.assign(Object.assign({}, state), { validators: Object.assign(Object.assign({}, state.validators), { options: Object.assign(Object.assign({}, state.validators.options), { 2: [false, false, false] }) }) }));
|
|
25
|
+
});
|
|
26
|
+
it('Returns same state without touching references if condition did not change', () => {
|
|
27
|
+
const reducerResult = updateOptionValidatorConditionReducer(state, {
|
|
28
|
+
type: UPDATE_OPTION_VALIDATOR_CONDITION,
|
|
29
|
+
id: 2,
|
|
30
|
+
index: 1,
|
|
31
|
+
value: true,
|
|
32
|
+
});
|
|
33
|
+
expect(reducerResult).toEqual(state);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { updateVariableValidatorConditionReducer } from './updateVariableValidatorCondition';
|
|
2
|
+
import { UPDATE_VARIABLE_VALIDATOR_CONDITION } from '../../constants/conditions';
|
|
3
|
+
const state = {
|
|
4
|
+
options: {},
|
|
5
|
+
variables: {},
|
|
6
|
+
validators: {
|
|
7
|
+
options: {},
|
|
8
|
+
variables: {
|
|
9
|
+
5: [false, true, false],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
documents: {},
|
|
13
|
+
sections: {},
|
|
14
|
+
prefillers: {},
|
|
15
|
+
};
|
|
16
|
+
describe('updateVariableValidatorConditionReducer test suit', () => {
|
|
17
|
+
it('Updates variable validator condition properly', () => {
|
|
18
|
+
const reducerResult = updateVariableValidatorConditionReducer(state, {
|
|
19
|
+
type: UPDATE_VARIABLE_VALIDATOR_CONDITION,
|
|
20
|
+
id: 5,
|
|
21
|
+
index: 1,
|
|
22
|
+
value: false,
|
|
23
|
+
});
|
|
24
|
+
expect(reducerResult).toStrictEqual(Object.assign(Object.assign({}, state), { validators: Object.assign(Object.assign({}, state.validators), { variables: Object.assign(Object.assign({}, state.validators.variables), { 5: [false, false, false] }) }) }));
|
|
25
|
+
});
|
|
26
|
+
it('Returns same state without touching references if condition did not change', () => {
|
|
27
|
+
const reducerResult = updateVariableValidatorConditionReducer(state, {
|
|
28
|
+
type: UPDATE_VARIABLE_VALIDATOR_CONDITION,
|
|
29
|
+
id: 5,
|
|
30
|
+
index: 1,
|
|
31
|
+
value: true,
|
|
32
|
+
});
|
|
33
|
+
expect(reducerResult).toEqual(state);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { initConditionsReducer } from './conditions/initConditions';
|
|
2
|
+
import { INIT_CONDITIONS } from '../constants/conditions';
|
|
3
|
+
import { updateOptionConditionReducer } from './conditions/updateOptionConditions';
|
|
4
|
+
import { updateSectionConditionReducer } from './conditions/updateSectionConditions';
|
|
5
|
+
import { updateVariableConditionReducer } from './conditions/updateVariableConditions';
|
|
6
|
+
import { updatePrefillerConditionReducer } from './conditions/updatePrefillerConditions';
|
|
7
|
+
import { conditionsReducer } from './conditions';
|
|
8
|
+
const initialState = {
|
|
9
|
+
type: INIT_CONDITIONS,
|
|
10
|
+
options: {
|
|
11
|
+
1: [true, false],
|
|
12
|
+
},
|
|
13
|
+
variables: {
|
|
14
|
+
1: [false, true],
|
|
15
|
+
},
|
|
16
|
+
prefillers: {
|
|
17
|
+
1: [
|
|
18
|
+
[true, false],
|
|
19
|
+
[false, true],
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
validators: {
|
|
23
|
+
options: {},
|
|
24
|
+
variables: {},
|
|
25
|
+
},
|
|
26
|
+
sections: {
|
|
27
|
+
main: {},
|
|
28
|
+
},
|
|
29
|
+
documents: {},
|
|
30
|
+
};
|
|
31
|
+
describe('Conditions reducer test suit', () => {
|
|
32
|
+
it('initConditions reducer', () => {
|
|
33
|
+
const reducer = initConditionsReducer(initialState, {
|
|
34
|
+
type: INIT_CONDITIONS,
|
|
35
|
+
options: {},
|
|
36
|
+
variables: {},
|
|
37
|
+
prefillers: {},
|
|
38
|
+
validators: {
|
|
39
|
+
options: {},
|
|
40
|
+
variables: {},
|
|
41
|
+
},
|
|
42
|
+
sections: {
|
|
43
|
+
main: {
|
|
44
|
+
1: true,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
documents: {},
|
|
48
|
+
});
|
|
49
|
+
expect(reducer).toEqual({
|
|
50
|
+
options: {},
|
|
51
|
+
variables: {},
|
|
52
|
+
prefillers: {},
|
|
53
|
+
validators: {
|
|
54
|
+
options: {},
|
|
55
|
+
variables: {},
|
|
56
|
+
},
|
|
57
|
+
sections: {
|
|
58
|
+
main: {
|
|
59
|
+
1: true,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
documents: {},
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
it('updateOptionConditions reducer', () => {
|
|
66
|
+
const reducer = updateOptionConditionReducer(initialState, {
|
|
67
|
+
type: 'UPDATE_OPTION_CONDITION',
|
|
68
|
+
value: false,
|
|
69
|
+
index: 0,
|
|
70
|
+
id: 1,
|
|
71
|
+
});
|
|
72
|
+
expect(reducer).toEqual(Object.assign(Object.assign({}, initialState), { options: {
|
|
73
|
+
1: [false, false],
|
|
74
|
+
} }));
|
|
75
|
+
});
|
|
76
|
+
it('updateSectionConditions reducer', () => {
|
|
77
|
+
const reducer = updateSectionConditionReducer(initialState, {
|
|
78
|
+
type: 'UPDATE_SECTION_CONDITION',
|
|
79
|
+
value: false,
|
|
80
|
+
document: 'main',
|
|
81
|
+
id: 1,
|
|
82
|
+
});
|
|
83
|
+
expect(reducer).toEqual(Object.assign(Object.assign({}, initialState), { sections: {
|
|
84
|
+
main: {
|
|
85
|
+
1: false,
|
|
86
|
+
},
|
|
87
|
+
} }));
|
|
88
|
+
});
|
|
89
|
+
it('updateVariableCondition reducer', () => {
|
|
90
|
+
const reducer = updateVariableConditionReducer(initialState, {
|
|
91
|
+
type: 'UPDATE_VARIABLE_CONDITION',
|
|
92
|
+
value: true,
|
|
93
|
+
id: 1,
|
|
94
|
+
index: 0,
|
|
95
|
+
});
|
|
96
|
+
expect(reducer).toEqual(Object.assign(Object.assign({}, initialState), { variables: {
|
|
97
|
+
1: [true, true],
|
|
98
|
+
} }));
|
|
99
|
+
});
|
|
100
|
+
it('updatePrefillerCondition reducer', () => {
|
|
101
|
+
const reducer = updatePrefillerConditionReducer(initialState, {
|
|
102
|
+
type: 'UPDATE_PREFILLER_CONDITION',
|
|
103
|
+
value: [false, true],
|
|
104
|
+
id: 1,
|
|
105
|
+
index: 0,
|
|
106
|
+
});
|
|
107
|
+
expect(reducer).toEqual(Object.assign(Object.assign({}, initialState), { prefillers: {
|
|
108
|
+
1: [
|
|
109
|
+
[false, true],
|
|
110
|
+
[false, true],
|
|
111
|
+
],
|
|
112
|
+
} }));
|
|
113
|
+
});
|
|
114
|
+
it('Conditions reducer INIT_CONDITIONS', () => {
|
|
115
|
+
const reducer = conditionsReducer(initialState, {
|
|
116
|
+
type: INIT_CONDITIONS,
|
|
117
|
+
options: {},
|
|
118
|
+
variables: {},
|
|
119
|
+
prefillers: {},
|
|
120
|
+
validators: {
|
|
121
|
+
options: {},
|
|
122
|
+
variables: {},
|
|
123
|
+
},
|
|
124
|
+
sections: {
|
|
125
|
+
main: {
|
|
126
|
+
1: true,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
documents: {},
|
|
130
|
+
});
|
|
131
|
+
expect(reducer).toEqual({
|
|
132
|
+
options: {},
|
|
133
|
+
variables: {},
|
|
134
|
+
prefillers: {},
|
|
135
|
+
validators: {
|
|
136
|
+
options: {},
|
|
137
|
+
variables: {},
|
|
138
|
+
},
|
|
139
|
+
sections: {
|
|
140
|
+
main: {
|
|
141
|
+
1: true,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
documents: {},
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
it('Conditions reducer UPDATE_OPTION_CONDITION', () => {
|
|
148
|
+
const reducer = conditionsReducer(initialState, {
|
|
149
|
+
type: 'UPDATE_OPTION_CONDITION',
|
|
150
|
+
value: false,
|
|
151
|
+
index: 0,
|
|
152
|
+
id: 1,
|
|
153
|
+
});
|
|
154
|
+
expect(reducer).toEqual(Object.assign(Object.assign({}, initialState), { options: {
|
|
155
|
+
1: [false, false],
|
|
156
|
+
} }));
|
|
157
|
+
});
|
|
158
|
+
it('Conditions reducer UPDATE_SECTION_CONDITION', () => {
|
|
159
|
+
const reducer = conditionsReducer(initialState, {
|
|
160
|
+
type: 'UPDATE_SECTION_CONDITION',
|
|
161
|
+
document: 'main',
|
|
162
|
+
value: false,
|
|
163
|
+
id: 1,
|
|
164
|
+
});
|
|
165
|
+
expect(reducer).toEqual(Object.assign(Object.assign({}, initialState), { sections: {
|
|
166
|
+
main: {
|
|
167
|
+
1: false,
|
|
168
|
+
},
|
|
169
|
+
} }));
|
|
170
|
+
});
|
|
171
|
+
it('Conditions reducer UPDATE_VARIABLE_CONDITION', () => {
|
|
172
|
+
const reducer = conditionsReducer(initialState, {
|
|
173
|
+
type: 'UPDATE_VARIABLE_CONDITION',
|
|
174
|
+
value: true,
|
|
175
|
+
id: 1,
|
|
176
|
+
index: 0,
|
|
177
|
+
});
|
|
178
|
+
expect(reducer).toEqual(Object.assign(Object.assign({}, initialState), { variables: {
|
|
179
|
+
1: [true, true],
|
|
180
|
+
} }));
|
|
181
|
+
});
|
|
182
|
+
it('Conditions reducer UPDATE_PREFILLER_CONDITION', () => {
|
|
183
|
+
const reducer = conditionsReducer(initialState, {
|
|
184
|
+
type: 'UPDATE_PREFILLER_CONDITION',
|
|
185
|
+
value: [false, true],
|
|
186
|
+
id: 1,
|
|
187
|
+
index: 0,
|
|
188
|
+
});
|
|
189
|
+
expect(reducer).toEqual(Object.assign(Object.assign({}, initialState), { prefillers: {
|
|
190
|
+
1: [
|
|
191
|
+
[false, true],
|
|
192
|
+
[false, true],
|
|
193
|
+
],
|
|
194
|
+
} }));
|
|
195
|
+
});
|
|
196
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { addMultipleOccurencyReducer } from './addMultipleOccurency';
|
|
2
|
+
const state = {
|
|
3
|
+
options: {
|
|
4
|
+
2: [true],
|
|
5
|
+
3: [false],
|
|
6
|
+
4: [true],
|
|
7
|
+
},
|
|
8
|
+
variables: {
|
|
9
|
+
2: [''],
|
|
10
|
+
3: [''],
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
describe('addMultipleOccurencyReducer test suit', () => {
|
|
14
|
+
it('Throws an error if optionRelations or optionsReferences are undefined', () => {
|
|
15
|
+
expect(() => {
|
|
16
|
+
addMultipleOccurencyReducer(state, {
|
|
17
|
+
id: 3,
|
|
18
|
+
optionRelations: undefined,
|
|
19
|
+
optionsReferences: undefined,
|
|
20
|
+
});
|
|
21
|
+
}).toThrowError('ADD_MULTIPLE_OCCURENCY reducer did not recieve complete data when adding ' +
|
|
22
|
+
`occurency for 3, please make sure "multiplesActions" middleware is ` +
|
|
23
|
+
'plugged and working properly');
|
|
24
|
+
});
|
|
25
|
+
it('Adds a multiple occurency conditions correctly', () => {
|
|
26
|
+
const optionRelations = {
|
|
27
|
+
options: [],
|
|
28
|
+
variables: [],
|
|
29
|
+
sections: {},
|
|
30
|
+
documents: [],
|
|
31
|
+
prefillers: [],
|
|
32
|
+
validators: {
|
|
33
|
+
options: [],
|
|
34
|
+
variables: [],
|
|
35
|
+
},
|
|
36
|
+
parents: [],
|
|
37
|
+
children: {
|
|
38
|
+
options: [3, 4],
|
|
39
|
+
variables: [2, 3],
|
|
40
|
+
},
|
|
41
|
+
dependants: [7, 8],
|
|
42
|
+
};
|
|
43
|
+
const optionsReferences = {
|
|
44
|
+
'2': {
|
|
45
|
+
meta: {
|
|
46
|
+
id: 2,
|
|
47
|
+
type: 'static',
|
|
48
|
+
label: 'Multiple question',
|
|
49
|
+
step: '*',
|
|
50
|
+
tags: [],
|
|
51
|
+
defaultRadio: 4,
|
|
52
|
+
multiple: {
|
|
53
|
+
enabled: true,
|
|
54
|
+
},
|
|
55
|
+
validator: {},
|
|
56
|
+
},
|
|
57
|
+
options: [3, 4],
|
|
58
|
+
variables: [2, 3],
|
|
59
|
+
},
|
|
60
|
+
'3': {
|
|
61
|
+
meta: {
|
|
62
|
+
id: 3,
|
|
63
|
+
type: 'radio',
|
|
64
|
+
label: 'Option 1',
|
|
65
|
+
step: '*',
|
|
66
|
+
tags: [],
|
|
67
|
+
defaultRadio: 0,
|
|
68
|
+
validator: {},
|
|
69
|
+
},
|
|
70
|
+
options: [],
|
|
71
|
+
variables: [],
|
|
72
|
+
},
|
|
73
|
+
'4': {
|
|
74
|
+
meta: {
|
|
75
|
+
id: 4,
|
|
76
|
+
type: 'radio',
|
|
77
|
+
label: 'Option 2',
|
|
78
|
+
step: '*',
|
|
79
|
+
tags: [],
|
|
80
|
+
defaultRadio: 0,
|
|
81
|
+
validator: {},
|
|
82
|
+
},
|
|
83
|
+
options: [],
|
|
84
|
+
variables: [],
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
const reducerResult = addMultipleOccurencyReducer(state, {
|
|
88
|
+
id: 2,
|
|
89
|
+
optionRelations,
|
|
90
|
+
optionsReferences,
|
|
91
|
+
type: 'ADD_MULTIPLE_OCCURENCY',
|
|
92
|
+
});
|
|
93
|
+
expect(reducerResult).toStrictEqual({
|
|
94
|
+
options: Object.assign(Object.assign({}, state.options), { 2: [true, true], 3: [false, false], 4: [true, false] }),
|
|
95
|
+
variables: {
|
|
96
|
+
2: ['', ''],
|
|
97
|
+
3: ['', ''],
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { deleteMultipleOccurencyReducer } from './deleteMultipleOccurency';
|
|
2
|
+
const state = {
|
|
3
|
+
options: {
|
|
4
|
+
2: [true, true, true],
|
|
5
|
+
3: [false, true, true],
|
|
6
|
+
4: [true, true, false],
|
|
7
|
+
},
|
|
8
|
+
variables: {
|
|
9
|
+
2: ['21', '22', '23'],
|
|
10
|
+
3: ['31', '32', '33'],
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
describe('deleteMultipleOccurencyReducer test suit', () => {
|
|
14
|
+
it('Throws an error if optionRelations are undefined', () => {
|
|
15
|
+
expect(() => {
|
|
16
|
+
deleteMultipleOccurencyReducer(state, {
|
|
17
|
+
id: 3,
|
|
18
|
+
optionRelations: undefined,
|
|
19
|
+
});
|
|
20
|
+
}).toThrowError('DELETE_MULTIPLE_OCCURENCY reducer did not recieve complete data when removing ' +
|
|
21
|
+
`occurency for 3, please make sure "multiplesActions" middleware is ` +
|
|
22
|
+
'plugged and working properly');
|
|
23
|
+
});
|
|
24
|
+
it('Deletes a multiple occurency conditions correctly', () => {
|
|
25
|
+
const optionRelations = {
|
|
26
|
+
options: [],
|
|
27
|
+
variables: [],
|
|
28
|
+
sections: {},
|
|
29
|
+
documents: [],
|
|
30
|
+
prefillers: [],
|
|
31
|
+
validators: {
|
|
32
|
+
options: [],
|
|
33
|
+
variables: [],
|
|
34
|
+
},
|
|
35
|
+
parents: [],
|
|
36
|
+
children: {
|
|
37
|
+
options: [3, 4],
|
|
38
|
+
variables: [2, 3],
|
|
39
|
+
},
|
|
40
|
+
dependants: [7, 8],
|
|
41
|
+
};
|
|
42
|
+
const reducerResult = deleteMultipleOccurencyReducer(state, {
|
|
43
|
+
id: 2,
|
|
44
|
+
index: 1,
|
|
45
|
+
optionRelations,
|
|
46
|
+
type: 'DELETE_MULTIPLE_OCCURENCY',
|
|
47
|
+
});
|
|
48
|
+
expect(reducerResult).toStrictEqual({
|
|
49
|
+
options: Object.assign(Object.assign({}, state.options), { 2: [true, true], 3: [false, true], 4: [true, false] }),
|
|
50
|
+
variables: {
|
|
51
|
+
2: ['21', '23'],
|
|
52
|
+
3: ['31', '33'],
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|