@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.
Files changed (211) hide show
  1. package/README.md +1 -376
  2. package/dist/App.d.ts +6 -1
  3. package/dist/App.js +7 -2
  4. package/dist/App.test.js +37 -0
  5. package/dist/Loader.d.ts +1 -1
  6. package/dist/Loader.js +1 -1
  7. package/dist/PluginLoader.d.ts +36 -21
  8. package/dist/PluginLoader.js +227 -90
  9. package/dist/PluginLoader.test.d.ts +1 -0
  10. package/dist/PluginLoader.test.js +52 -0
  11. package/dist/Shimmer.d.ts +11 -8
  12. package/dist/Shimmer.js +4 -4
  13. package/dist/ThemeLoader.d.ts +8 -8
  14. package/dist/ThemeLoader.test.d.ts +2 -0
  15. package/dist/ThemeLoader.test.js +65 -0
  16. package/dist/components/PluginRoute.d.ts +2 -2
  17. package/dist/components/PluginRoute.js +4 -3
  18. package/dist/components/SmartScript.d.ts +6 -2
  19. package/dist/components/SmartScript.js +1 -1
  20. package/dist/components/UserLocked/UserLockedComponent.js +2 -2
  21. package/dist/components/View.d.ts +3 -3
  22. package/dist/components/View.js +7 -5
  23. package/dist/components/View.test.d.ts +2 -0
  24. package/dist/components/View.test.js +84 -0
  25. package/dist/componentsConnectors/connectBox.d.ts +6 -4
  26. package/dist/componentsConnectors/connectBox.test.d.ts +1 -0
  27. package/dist/componentsConnectors/connectBox.test.js +218 -0
  28. package/dist/componentsConnectors/connectDocument.d.ts +6 -4
  29. package/dist/componentsConnectors/connectDocument.test.d.ts +1 -0
  30. package/dist/componentsConnectors/connectDocument.test.js +95 -0
  31. package/dist/componentsConnectors/connectHeader.d.ts +6 -4
  32. package/dist/componentsConnectors/connectMetaTitle.d.ts +7 -3
  33. package/dist/componentsConnectors/connectMetaTitle.test.d.ts +1 -0
  34. package/dist/componentsConnectors/connectMetaTitle.test.js +32 -0
  35. package/dist/componentsConnectors/connectOption.d.ts +7 -5
  36. package/dist/componentsConnectors/connectPagination.d.ts +7 -5
  37. package/dist/componentsConnectors/connectPreview.d.ts +7 -3
  38. package/dist/componentsConnectors/connectProgress.d.ts +6 -4
  39. package/dist/componentsConnectors/connectRootOption.d.ts +7 -5
  40. package/dist/componentsConnectors/connectSection.d.ts +6 -4
  41. package/dist/componentsConnectors/connectSummary.d.ts +9 -5
  42. package/dist/componentsConnectors/connectSummaryItem.d.ts +6 -4
  43. package/dist/componentsConnectors/connectTermsheet.js +1 -1
  44. package/dist/componentsConnectors/connectVariable.d.ts +8 -6
  45. package/dist/componentsConnectors/connectWizardWrapper.d.ts +6 -4
  46. package/dist/componentsConnectors/connector/componentConnector.d.ts +10 -7
  47. package/dist/componentsConnectors/connector/componentConnector.js +3 -3
  48. package/dist/componentsConnectors/library.d.ts +81 -47
  49. package/dist/config.test.d.ts +1 -0
  50. package/dist/config.test.js +54 -0
  51. package/dist/helpers/activitiesHelper.d.ts +3 -3
  52. package/dist/helpers/autocomplete.helper.d.ts +2 -2
  53. package/dist/helpers/autocomplete.helper.js +1 -1
  54. package/dist/helpers/autosave.helper.d.ts +13 -3
  55. package/dist/helpers/autosave.helper.js +70 -3
  56. package/dist/helpers/inpiCitiesHelper.js +1 -1
  57. package/dist/helpers/outputsParsing.d.ts +9 -9
  58. package/dist/hooks/useDispatch.d.ts +1 -1
  59. package/dist/hooks/usePrevious.js +1 -1
  60. package/dist/index.d.ts +0 -3
  61. package/dist/index.js +0 -3
  62. package/dist/libs/ConditionsRunner.d.ts +1 -1
  63. package/dist/libs/Formatter/FormatAddress.d.ts +1 -1
  64. package/dist/libs/InputsInitiator.d.ts +1 -1
  65. package/dist/libs/NumAuto.test.d.ts +1 -0
  66. package/dist/libs/NumAuto.test.js +43 -0
  67. package/dist/libs/PathReader.d.ts +1 -96
  68. package/dist/libs/PathReader.js +2 -1
  69. package/dist/libs/SectionValidity.test.d.ts +1 -0
  70. package/dist/libs/SectionValidity.test.js +116 -0
  71. package/dist/libs/SmartScriptStore.d.ts +6 -6
  72. package/dist/redux/actions/app.d.ts +1 -1
  73. package/dist/redux/actions/app.test.d.ts +1 -0
  74. package/dist/redux/actions/app.test.js +90 -0
  75. package/dist/redux/actions/conditions.test.d.ts +1 -0
  76. package/dist/redux/actions/conditions.test.js +68 -0
  77. package/dist/redux/actions/inputs.d.ts +1 -1
  78. package/dist/redux/actions/inputs.test.d.ts +1 -0
  79. package/dist/redux/actions/inputs.test.js +53 -0
  80. package/dist/redux/actions/library.d.ts +21 -15
  81. package/dist/redux/actions/references.d.ts +2 -2
  82. package/dist/redux/actions/references.test.d.ts +1 -0
  83. package/dist/redux/actions/references.test.js +43 -0
  84. package/dist/redux/actions/sagas/data.d.ts +1 -1
  85. package/dist/redux/actions/sagas/data.test.d.ts +1 -0
  86. package/dist/redux/actions/sagas/data.test.js +11 -0
  87. package/dist/redux/actions/sagas/model.test.d.ts +1 -0
  88. package/dist/redux/actions/sagas/model.test.js +11 -0
  89. package/dist/redux/actions/sagas/user.d.ts +1 -1
  90. package/dist/redux/actions/user.test.d.ts +1 -0
  91. package/dist/redux/actions/user.test.js +16 -0
  92. package/dist/redux/listeners/subscriber.d.ts +1 -1
  93. package/dist/redux/listeners/subscriber.test.d.ts +1 -0
  94. package/dist/redux/listeners/subscriber.test.js +31 -0
  95. package/dist/redux/middlewares/conditionsWatcherMiddleware.d.ts +1 -1
  96. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.d.ts +1 -0
  97. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +330 -0
  98. package/dist/redux/middlewares/evaluationsWatcherMiddleware.d.ts +1 -1
  99. package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.d.ts +1 -0
  100. package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.js +242 -0
  101. package/dist/redux/middlewares/mandatoriesWatcherMiddleware.d.ts +1 -1
  102. package/dist/redux/middlewares/multiplesActionsMiddleware.d.ts +1 -1
  103. package/dist/redux/middlewares/multiplesActionsMiddleware.test.d.ts +1 -0
  104. package/dist/redux/middlewares/multiplesActionsMiddleware.test.js +209 -0
  105. package/dist/redux/middlewares/paginationWatcherMiddleware.d.ts +2 -2
  106. package/dist/redux/middlewares/pluginsHookMiddleware.d.ts +2 -1
  107. package/dist/redux/middlewares/pluginsHookMiddleware.js +7 -1
  108. package/dist/redux/middlewares/prefillerWatcherMiddleware.d.ts +1 -1
  109. package/dist/redux/middlewares/prefillerWatcherMiddleware.test.d.ts +1 -0
  110. package/dist/redux/middlewares/prefillerWatcherMiddleware.test.js +84 -0
  111. package/dist/redux/middlewares/smartscriptMiddleware.d.ts +1 -1
  112. package/dist/redux/middlewares/smartscriptMiddleware.js +2 -2
  113. package/dist/redux/middlewares/thirdpartyScriptsMiddleware.d.ts +1 -1
  114. package/dist/redux/reducers/app/instance.test.d.ts +1 -0
  115. package/dist/redux/reducers/app/instance.test.js +75 -0
  116. package/dist/redux/reducers/app/meta.test.d.ts +1 -0
  117. package/dist/redux/reducers/app/meta.test.js +70 -0
  118. package/dist/redux/reducers/app/pagination/updateAvailableAppStates.js +2 -1
  119. package/dist/redux/reducers/app/pagination.test.d.ts +1 -0
  120. package/dist/redux/reducers/app/pagination.test.js +134 -0
  121. package/dist/redux/reducers/app/wizard.test.d.ts +1 -0
  122. package/dist/redux/reducers/app/wizard.test.js +53 -0
  123. package/dist/redux/reducers/app.d.ts +6 -6
  124. package/dist/redux/reducers/app.test.d.ts +1 -0
  125. package/dist/redux/reducers/app.test.js +175 -0
  126. package/dist/redux/reducers/conditions/addMultipleOccurency.test.d.ts +1 -0
  127. package/dist/redux/reducers/conditions/addMultipleOccurency.test.js +108 -0
  128. package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.d.ts +1 -0
  129. package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.js +77 -0
  130. package/dist/redux/reducers/conditions/updateDocumentConditions.test.d.ts +1 -0
  131. package/dist/redux/reducers/conditions/updateDocumentConditions.test.js +35 -0
  132. package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.d.ts +1 -0
  133. package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.js +35 -0
  134. package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.d.ts +1 -0
  135. package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.js +35 -0
  136. package/dist/redux/reducers/conditions.test.d.ts +1 -0
  137. package/dist/redux/reducers/conditions.test.js +196 -0
  138. package/dist/redux/reducers/inputs/addMultipleOccurency.test.d.ts +1 -0
  139. package/dist/redux/reducers/inputs/addMultipleOccurency.test.js +101 -0
  140. package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.d.ts +1 -0
  141. package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.js +56 -0
  142. package/dist/redux/reducers/inputs.test.d.ts +1 -0
  143. package/dist/redux/reducers/inputs.test.js +171 -0
  144. package/dist/redux/reducers/references.js +0 -2
  145. package/dist/redux/reducers/user.test.d.ts +1 -0
  146. package/dist/redux/reducers/user.test.js +42 -0
  147. package/dist/redux/routerHistore.test.d.ts +1 -0
  148. package/dist/redux/routerHistore.test.js +15 -0
  149. package/dist/redux/sagas/fetchModel.test.d.ts +1 -0
  150. package/dist/redux/sagas/fetchModel.test.js +127 -0
  151. package/dist/redux/sagas/runner.test.d.ts +1 -0
  152. package/dist/redux/sagas/runner.test.js +10 -0
  153. package/dist/redux/sagas/saveData.test.d.ts +1 -0
  154. package/dist/redux/sagas/saveData.test.js +74 -0
  155. package/dist/redux/sagas/setDefaults.test.d.ts +1 -0
  156. package/dist/redux/sagas/setDefaults.test.js +73 -0
  157. package/dist/redux/selectors/app.test.d.ts +1 -0
  158. package/dist/redux/selectors/app.test.js +99 -0
  159. package/dist/redux/selectors/conditions.test.d.ts +1 -0
  160. package/dist/redux/selectors/conditions.test.js +70 -0
  161. package/dist/redux/selectors/inputs.d.ts +1 -1
  162. package/dist/redux/selectors/inputs.test.d.ts +1 -0
  163. package/dist/redux/selectors/inputs.test.js +44 -0
  164. package/dist/redux/selectors/references.test.d.ts +1 -0
  165. package/dist/redux/selectors/references.test.js +471 -0
  166. package/dist/redux/selectors/selectors.d.ts +4 -4
  167. package/dist/redux/selectors/selectors.test.d.ts +1 -0
  168. package/dist/redux/selectors/selectors.test.js +16 -0
  169. package/dist/redux/selectors/user.test.d.ts +1 -0
  170. package/dist/redux/selectors/user.test.js +29 -0
  171. package/dist/redux/store.d.ts +3 -5
  172. package/dist/redux/store.js +1 -2
  173. package/dist/redux/store.test.d.ts +1 -0
  174. package/dist/redux/store.test.js +16 -0
  175. package/dist/service/api.manager.d.ts +2 -2
  176. package/dist/service/autocomplete.manager.d.ts +3 -3
  177. package/dist/service/autocomplete.manager.js +3 -3
  178. package/dist/tests-misc/plugins/jestTestPlugin/after.js +1 -1
  179. package/dist/tests-misc/plugins/jestTestPlugin/before.js +1 -1
  180. package/dist/tests-misc/plugins/jestTestPlugin/title.js +1 -1
  181. package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.d.ts +1 -1
  182. package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.js +1 -1
  183. package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.d.ts +1 -1
  184. package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.js +1 -1
  185. package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.d.ts +1 -1
  186. package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.js +1 -1
  187. package/dist/types/Actions.type.d.ts +6 -70
  188. package/dist/types/Components.type.d.ts +2 -3
  189. package/dist/types/PluginConfig.type.d.ts +52 -18
  190. package/dist/types/State.type.d.ts +2 -2
  191. package/dist/types/config.type.d.ts +1 -1
  192. package/dist/types/getActions.type.d.ts +1 -1
  193. package/dist/types/getConnectors.type.d.ts +2 -2
  194. package/dist/types/getSelectors.type.d.ts +1 -1
  195. package/package.json +22 -45
  196. package/dist/WizardCore.d.ts +0 -29
  197. package/dist/WizardCore.js +0 -153
  198. package/dist/app.entry.d.ts +0 -2
  199. package/dist/app.entry.js +0 -1
  200. package/dist/routing/adapters/nextjs.adapter.d.ts +0 -3
  201. package/dist/routing/adapters/nextjs.adapter.js +0 -61
  202. package/dist/routing/adapters/reactRouter.adapter.d.ts +0 -2
  203. package/dist/routing/adapters/reactRouter.adapter.js +0 -16
  204. package/dist/routing/context.d.ts +0 -14
  205. package/dist/routing/context.js +0 -23
  206. package/dist/routing/index.d.ts +0 -4
  207. package/dist/routing/index.js +0 -4
  208. package/dist/routing/types.d.ts +0 -26
  209. package/dist/wizardcore.entry.d.ts +0 -3
  210. package/dist/wizardcore.entry.js +0 -2
  211. /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,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,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,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,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,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 {};