@legalplace/wizardx-core 4.42.9 → 4.42.10-nightly.20251125120616

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 +376 -1
  2. package/dist/App.d.ts +1 -6
  3. package/dist/App.js +2 -7
  4. package/dist/Loader.d.ts +1 -1
  5. package/dist/Loader.js +1 -1
  6. package/dist/PluginLoader.d.ts +21 -36
  7. package/dist/PluginLoader.js +90 -227
  8. package/dist/Shimmer.d.ts +8 -11
  9. package/dist/Shimmer.js +4 -4
  10. package/dist/ThemeLoader.d.ts +8 -8
  11. package/dist/WizardCore.d.ts +29 -0
  12. package/dist/WizardCore.js +153 -0
  13. package/dist/app.entry.d.ts +2 -0
  14. package/dist/app.entry.js +1 -0
  15. package/dist/components/PluginRoute.d.ts +2 -2
  16. package/dist/components/PluginRoute.js +3 -4
  17. package/dist/components/SmartScript.d.ts +2 -6
  18. package/dist/components/SmartScript.js +1 -1
  19. package/dist/components/UserLocked/UserLockedComponent.js +2 -2
  20. package/dist/components/View.d.ts +3 -3
  21. package/dist/components/View.js +5 -7
  22. package/dist/componentsConnectors/connectBox.d.ts +4 -6
  23. package/dist/componentsConnectors/connectDocument.d.ts +4 -6
  24. package/dist/componentsConnectors/connectHeader.d.ts +4 -6
  25. package/dist/componentsConnectors/connectMetaTitle.d.ts +3 -7
  26. package/dist/componentsConnectors/connectOption.d.ts +5 -7
  27. package/dist/componentsConnectors/connectPagination.d.ts +5 -7
  28. package/dist/componentsConnectors/connectPreview.d.ts +3 -7
  29. package/dist/componentsConnectors/connectProgress.d.ts +4 -6
  30. package/dist/componentsConnectors/connectRootOption.d.ts +5 -7
  31. package/dist/componentsConnectors/connectSection.d.ts +4 -6
  32. package/dist/componentsConnectors/connectSummary.d.ts +5 -9
  33. package/dist/componentsConnectors/connectSummaryItem.d.ts +4 -6
  34. package/dist/componentsConnectors/connectTermsheet.js +1 -1
  35. package/dist/componentsConnectors/connectVariable.d.ts +6 -8
  36. package/dist/componentsConnectors/connectWizardWrapper.d.ts +4 -6
  37. package/dist/componentsConnectors/connector/componentConnector.d.ts +7 -10
  38. package/dist/componentsConnectors/connector/componentConnector.js +3 -3
  39. package/dist/componentsConnectors/library.d.ts +47 -81
  40. package/dist/helpers/activitiesHelper.d.ts +3 -3
  41. package/dist/helpers/autocomplete.helper.d.ts +2 -2
  42. package/dist/helpers/autocomplete.helper.js +1 -1
  43. package/dist/helpers/autosave.helper.d.ts +3 -13
  44. package/dist/helpers/autosave.helper.js +3 -70
  45. package/dist/helpers/inpiCitiesHelper.js +1 -1
  46. package/dist/helpers/outputsParsing.d.ts +9 -9
  47. package/dist/hooks/useDispatch.d.ts +1 -1
  48. package/dist/hooks/usePrevious.js +1 -1
  49. package/dist/index.d.ts +3 -0
  50. package/dist/index.js +3 -0
  51. package/dist/libs/ConditionsRunner.d.ts +1 -1
  52. package/dist/libs/Formatter/FormatAddress.d.ts +1 -1
  53. package/dist/libs/InputsInitiator.d.ts +1 -1
  54. package/dist/libs/PathReader.d.ts +96 -1
  55. package/dist/libs/PathReader.js +1 -2
  56. package/dist/libs/SmartScriptStore.d.ts +6 -6
  57. package/dist/redux/actions/app.d.ts +1 -1
  58. package/dist/redux/actions/inputs.d.ts +1 -1
  59. package/dist/redux/actions/library.d.ts +15 -21
  60. package/dist/redux/actions/references.d.ts +2 -2
  61. package/dist/redux/actions/sagas/data.d.ts +1 -1
  62. package/dist/redux/actions/sagas/user.d.ts +1 -1
  63. package/dist/redux/listeners/subscriber.d.ts +1 -1
  64. package/dist/redux/middlewares/conditionsWatcherMiddleware.d.ts +1 -1
  65. package/dist/redux/middlewares/evaluationsWatcherMiddleware.d.ts +1 -1
  66. package/dist/redux/middlewares/mandatoriesWatcherMiddleware.d.ts +1 -1
  67. package/dist/redux/middlewares/multiplesActionsMiddleware.d.ts +1 -1
  68. package/dist/redux/middlewares/paginationWatcherMiddleware.d.ts +2 -2
  69. package/dist/redux/middlewares/pluginsHookMiddleware.d.ts +1 -2
  70. package/dist/redux/middlewares/pluginsHookMiddleware.js +1 -7
  71. package/dist/redux/middlewares/prefillerWatcherMiddleware.d.ts +1 -1
  72. package/dist/redux/middlewares/smartscriptMiddleware.d.ts +1 -1
  73. package/dist/redux/middlewares/smartscriptMiddleware.js +2 -2
  74. package/dist/redux/middlewares/thirdpartyScriptsMiddleware.d.ts +1 -1
  75. package/dist/redux/reducers/app/pagination/updateAvailableAppStates.js +1 -2
  76. package/dist/redux/reducers/app.d.ts +6 -6
  77. package/dist/redux/reducers/references.js +2 -0
  78. package/dist/redux/selectors/inputs.d.ts +1 -1
  79. package/dist/redux/selectors/selectors.d.ts +4 -4
  80. package/dist/redux/store.d.ts +5 -3
  81. package/dist/redux/store.js +2 -1
  82. package/dist/routing/adapters/nextjs.adapter.d.ts +3 -0
  83. package/dist/routing/adapters/nextjs.adapter.js +61 -0
  84. package/dist/routing/adapters/reactRouter.adapter.d.ts +2 -0
  85. package/dist/routing/adapters/reactRouter.adapter.js +16 -0
  86. package/dist/routing/context.d.ts +14 -0
  87. package/dist/routing/context.js +23 -0
  88. package/dist/routing/index.d.ts +4 -0
  89. package/dist/routing/index.js +4 -0
  90. package/dist/routing/types.d.ts +26 -0
  91. package/dist/service/api.manager.d.ts +2 -2
  92. package/dist/service/autocomplete.manager.d.ts +3 -3
  93. package/dist/service/autocomplete.manager.js +3 -3
  94. package/dist/tests-misc/plugins/jestTestPlugin/after.js +1 -1
  95. package/dist/tests-misc/plugins/jestTestPlugin/before.js +1 -1
  96. package/dist/tests-misc/plugins/jestTestPlugin/title.js +1 -1
  97. package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.d.ts +1 -1
  98. package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.js +1 -1
  99. package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.d.ts +1 -1
  100. package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.js +1 -1
  101. package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.d.ts +1 -1
  102. package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.js +1 -1
  103. package/dist/types/Actions.type.d.ts +70 -6
  104. package/dist/types/Components.type.d.ts +3 -2
  105. package/dist/types/PluginConfig.type.d.ts +18 -52
  106. package/dist/types/State.type.d.ts +2 -2
  107. package/dist/types/config.type.d.ts +1 -1
  108. package/dist/types/getActions.type.d.ts +1 -1
  109. package/dist/types/getConnectors.type.d.ts +2 -2
  110. package/dist/types/getSelectors.type.d.ts +1 -1
  111. package/dist/wizardcore.entry.d.ts +3 -0
  112. package/dist/wizardcore.entry.js +2 -0
  113. package/package.json +40 -17
  114. package/dist/App.test.js +0 -37
  115. package/dist/PluginLoader.test.d.ts +0 -1
  116. package/dist/PluginLoader.test.js +0 -52
  117. package/dist/ThemeLoader.test.d.ts +0 -2
  118. package/dist/ThemeLoader.test.js +0 -65
  119. package/dist/components/View.test.d.ts +0 -2
  120. package/dist/components/View.test.js +0 -84
  121. package/dist/componentsConnectors/connectBox.test.d.ts +0 -1
  122. package/dist/componentsConnectors/connectBox.test.js +0 -218
  123. package/dist/componentsConnectors/connectDocument.test.d.ts +0 -1
  124. package/dist/componentsConnectors/connectDocument.test.js +0 -95
  125. package/dist/componentsConnectors/connectMetaTitle.test.d.ts +0 -1
  126. package/dist/componentsConnectors/connectMetaTitle.test.js +0 -32
  127. package/dist/config.test.d.ts +0 -1
  128. package/dist/config.test.js +0 -54
  129. package/dist/libs/NumAuto.test.d.ts +0 -1
  130. package/dist/libs/NumAuto.test.js +0 -43
  131. package/dist/libs/SectionValidity.test.d.ts +0 -1
  132. package/dist/libs/SectionValidity.test.js +0 -116
  133. package/dist/redux/actions/app.test.d.ts +0 -1
  134. package/dist/redux/actions/app.test.js +0 -90
  135. package/dist/redux/actions/conditions.test.d.ts +0 -1
  136. package/dist/redux/actions/conditions.test.js +0 -68
  137. package/dist/redux/actions/inputs.test.d.ts +0 -1
  138. package/dist/redux/actions/inputs.test.js +0 -53
  139. package/dist/redux/actions/references.test.d.ts +0 -1
  140. package/dist/redux/actions/references.test.js +0 -43
  141. package/dist/redux/actions/sagas/data.test.d.ts +0 -1
  142. package/dist/redux/actions/sagas/data.test.js +0 -11
  143. package/dist/redux/actions/sagas/model.test.d.ts +0 -1
  144. package/dist/redux/actions/sagas/model.test.js +0 -11
  145. package/dist/redux/actions/user.test.d.ts +0 -1
  146. package/dist/redux/actions/user.test.js +0 -16
  147. package/dist/redux/listeners/subscriber.test.d.ts +0 -1
  148. package/dist/redux/listeners/subscriber.test.js +0 -31
  149. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.d.ts +0 -1
  150. package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +0 -330
  151. package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.d.ts +0 -1
  152. package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.js +0 -242
  153. package/dist/redux/middlewares/multiplesActionsMiddleware.test.d.ts +0 -1
  154. package/dist/redux/middlewares/multiplesActionsMiddleware.test.js +0 -209
  155. package/dist/redux/middlewares/prefillerWatcherMiddleware.test.d.ts +0 -1
  156. package/dist/redux/middlewares/prefillerWatcherMiddleware.test.js +0 -84
  157. package/dist/redux/reducers/app/instance.test.d.ts +0 -1
  158. package/dist/redux/reducers/app/instance.test.js +0 -75
  159. package/dist/redux/reducers/app/meta.test.d.ts +0 -1
  160. package/dist/redux/reducers/app/meta.test.js +0 -70
  161. package/dist/redux/reducers/app/pagination.test.d.ts +0 -1
  162. package/dist/redux/reducers/app/pagination.test.js +0 -134
  163. package/dist/redux/reducers/app/wizard.test.d.ts +0 -1
  164. package/dist/redux/reducers/app/wizard.test.js +0 -53
  165. package/dist/redux/reducers/app.test.d.ts +0 -1
  166. package/dist/redux/reducers/app.test.js +0 -175
  167. package/dist/redux/reducers/conditions/addMultipleOccurency.test.d.ts +0 -1
  168. package/dist/redux/reducers/conditions/addMultipleOccurency.test.js +0 -108
  169. package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.d.ts +0 -1
  170. package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.js +0 -77
  171. package/dist/redux/reducers/conditions/updateDocumentConditions.test.d.ts +0 -1
  172. package/dist/redux/reducers/conditions/updateDocumentConditions.test.js +0 -35
  173. package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.d.ts +0 -1
  174. package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.js +0 -35
  175. package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.d.ts +0 -1
  176. package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.js +0 -35
  177. package/dist/redux/reducers/conditions.test.d.ts +0 -1
  178. package/dist/redux/reducers/conditions.test.js +0 -196
  179. package/dist/redux/reducers/inputs/addMultipleOccurency.test.d.ts +0 -1
  180. package/dist/redux/reducers/inputs/addMultipleOccurency.test.js +0 -101
  181. package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.d.ts +0 -1
  182. package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.js +0 -56
  183. package/dist/redux/reducers/inputs.test.d.ts +0 -1
  184. package/dist/redux/reducers/inputs.test.js +0 -171
  185. package/dist/redux/reducers/user.test.d.ts +0 -1
  186. package/dist/redux/reducers/user.test.js +0 -42
  187. package/dist/redux/routerHistore.test.d.ts +0 -1
  188. package/dist/redux/routerHistore.test.js +0 -15
  189. package/dist/redux/sagas/fetchModel.test.d.ts +0 -1
  190. package/dist/redux/sagas/fetchModel.test.js +0 -127
  191. package/dist/redux/sagas/runner.test.d.ts +0 -1
  192. package/dist/redux/sagas/runner.test.js +0 -10
  193. package/dist/redux/sagas/saveData.test.d.ts +0 -1
  194. package/dist/redux/sagas/saveData.test.js +0 -74
  195. package/dist/redux/sagas/setDefaults.test.d.ts +0 -1
  196. package/dist/redux/sagas/setDefaults.test.js +0 -73
  197. package/dist/redux/selectors/app.test.d.ts +0 -1
  198. package/dist/redux/selectors/app.test.js +0 -99
  199. package/dist/redux/selectors/conditions.test.d.ts +0 -1
  200. package/dist/redux/selectors/conditions.test.js +0 -70
  201. package/dist/redux/selectors/inputs.test.d.ts +0 -1
  202. package/dist/redux/selectors/inputs.test.js +0 -44
  203. package/dist/redux/selectors/references.test.d.ts +0 -1
  204. package/dist/redux/selectors/references.test.js +0 -471
  205. package/dist/redux/selectors/selectors.test.d.ts +0 -1
  206. package/dist/redux/selectors/selectors.test.js +0 -16
  207. package/dist/redux/selectors/user.test.d.ts +0 -1
  208. package/dist/redux/selectors/user.test.js +0 -29
  209. package/dist/redux/store.test.d.ts +0 -1
  210. package/dist/redux/store.test.js +0 -16
  211. /package/dist/{App.test.d.ts → routing/types.js} +0 -0
@@ -1,175 +0,0 @@
1
- import { appReducer } from './app';
2
- const appStateMock = {
3
- meta: {
4
- fetchStatus: 'waiting',
5
- id: 0,
6
- prefix: '',
7
- permalink: 'permalink',
8
- title: 'title',
9
- modelVersion: 1,
10
- productType: 'demarche',
11
- metadata: {
12
- metaTypology: "contract"
13
- }
14
- },
15
- wizard: {
16
- availableSections: [1, 2, 3],
17
- currentSectionId: 1,
18
- },
19
- pagination: {
20
- currentPage: 1,
21
- greatestPage: 1,
22
- currentAppState: 'wizard',
23
- availableAppStates: ['wizard'],
24
- isFirstPage: true,
25
- isLastPage: false,
26
- totalPages: 3,
27
- },
28
- instance: {
29
- companyUuid: undefined,
30
- employeeUuid: undefined,
31
- filename: undefined,
32
- dataStatus: 'saved',
33
- uniqid: '3jHD42343sDE',
34
- isPaid: false,
35
- steps: '*',
36
- },
37
- customization: {},
38
- };
39
- describe('App Reducer test suit', () => {
40
- it('Combines meta reducer', () => {
41
- const reducer = appReducer(appStateMock, {
42
- type: 'INIT_META',
43
- prefix: '',
44
- id: 123,
45
- permalink: 'some-other-permalink',
46
- title: 'Some other title',
47
- modelVersion: 1,
48
- productType: 'demarche',
49
- metadata: {
50
- metaTypology: "contract"
51
- }
52
- });
53
- return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { meta: {
54
- fetchStatus: 'waiting',
55
- id: 123,
56
- prefix: '',
57
- permalink: 'some-other-permalink',
58
- title: 'Some other title',
59
- modelVersion: 1,
60
- productType: 'demarche',
61
- metadata: {
62
- metaTypology: "contract"
63
- }
64
- } }));
65
- });
66
- it('Combines pagination reducer', () => {
67
- const reducer = appReducer(appStateMock, {
68
- type: 'INIT_PAGINATION',
69
- currentPage: 11,
70
- currentSectionId: 13,
71
- greatestPage: 11,
72
- availableSections: [1, 12, 13, 14, 15],
73
- currentAppState: 'wizard',
74
- availableAppStates: ['wizard'],
75
- });
76
- return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: {
77
- currentPage: 11,
78
- greatestPage: 11,
79
- currentAppState: 'wizard',
80
- availableAppStates: ['wizard'],
81
- isFirstPage: false,
82
- isLastPage: false,
83
- totalPages: 5,
84
- }, wizard: {
85
- currentSectionId: 13,
86
- availableSections: [1, 12, 13, 14, 15],
87
- } }));
88
- });
89
- it('Combines instance reducer', () => {
90
- const reducer = appReducer(appStateMock, {
91
- type: 'INIT_INSTANCE',
92
- dataStatus: 'saved',
93
- uniqid: 'SomeUniqid123',
94
- isPaid: true,
95
- steps: '*',
96
- });
97
- return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { instance: {
98
- dataStatus: 'saved',
99
- uniqid: 'SomeUniqid123',
100
- employeeUuid: undefined,
101
- companyUuid: undefined,
102
- filename: undefined,
103
- isPaid: true,
104
- steps: '*',
105
- } }));
106
- });
107
- it('App Reducer INIT_INSTANCE Action', () => {
108
- const reducer = appReducer(appStateMock, {
109
- type: 'INIT_INSTANCE',
110
- dataStatus: 'saved',
111
- uniqid: '3jHD42343sDE',
112
- isPaid: false,
113
- steps: '*',
114
- });
115
- return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { instance: {
116
- dataStatus: 'saved',
117
- employeeUuid: undefined,
118
- companyUuid: undefined,
119
- filename: undefined,
120
- uniqid: '3jHD42343sDE',
121
- isPaid: false,
122
- steps: '*',
123
- } }));
124
- });
125
- it('App Reducer UPDATE_INSTANCE_PAID Action', () => {
126
- const reducer = appReducer(appStateMock, {
127
- type: 'UPDATE_INSTANCE_PAID',
128
- isPaid: true,
129
- });
130
- return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { instance: Object.assign(Object.assign({}, appStateMock.instance), { isPaid: true }) }));
131
- });
132
- it('appReducer INIT_PAGINATION Action', () => {
133
- const reducer = appReducer(appStateMock, {
134
- type: 'INIT_PAGINATION',
135
- currentSectionId: 32,
136
- currentPage: 32,
137
- greatestPage: 32,
138
- availableSections: [32, 2, 3],
139
- availableAppStates: ['wizard'],
140
- currentAppState: 'wizard',
141
- });
142
- return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 32, greatestPage: 32, availableAppStates: ['wizard'], currentAppState: 'wizard', isFirstPage: false }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 32, availableSections: [32, 2, 3] }) }));
143
- });
144
- it('appReducer GO_PAGE Action', () => {
145
- const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 1, greatestPage: 1 }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 1, availableSections: [1, 6, 3] }) });
146
- const reducer = appReducer(state, {
147
- type: 'GO_PAGE',
148
- currentPage: 2,
149
- pushHistory: false,
150
- });
151
- return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 2, greatestPage: 2, isFirstPage: false }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 6, availableSections: [1, 6, 3] }) }));
152
- });
153
- it('appReducer UPDATE_AVAILABLE_SECTIONS Action', () => {
154
- const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 1, greatestPage: 14 }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 1, availableSections: [1, 2, 3] }) });
155
- const reducer = appReducer(state, {
156
- type: 'UPDATE_AVAILABLE_SECTIONS',
157
- availableSections: [1, 3, 4],
158
- });
159
- return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 1, greatestPage: 14 }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 1, availableSections: [1, 3, 4] }) }));
160
- });
161
- it('appReducer GO_NEXT_PAGE Action', () => {
162
- const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 1, greatestPage: 1 }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 1, availableSections: [1, 6, 3] }) });
163
- const reducer = appReducer(state, {
164
- type: 'GO_NEXT_PAGE',
165
- });
166
- return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 2, greatestPage: 2, isFirstPage: false }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 6, availableSections: [1, 6, 3] }) }));
167
- });
168
- it('appReducer GO_PREVIOUS_PAGE Action', () => {
169
- const state = Object.assign(Object.assign({}, appStateMock), { pagination: Object.assign(Object.assign({}, appStateMock.pagination), { currentPage: 3, greatestPage: 3, isFirstPage: false }), wizard: Object.assign(Object.assign({}, appStateMock.wizard), { currentSectionId: 3, availableSections: [1, 5, 3] }) });
170
- const reducer = appReducer(state, {
171
- type: 'GO_PREVIOUS_PAGE',
172
- });
173
- return expect(reducer).toStrictEqual(Object.assign(Object.assign({}, state), { pagination: Object.assign(Object.assign({}, state.pagination), { currentPage: 2, greatestPage: 3 }), wizard: Object.assign(Object.assign({}, state.wizard), { currentSectionId: 5, availableSections: [1, 5, 3] }) }));
174
- });
175
- });
@@ -1,108 +0,0 @@
1
- import { addMultipleOccurencyReducer } from './addMultipleOccurency';
2
- const state = {
3
- options: {
4
- 4: [true],
5
- },
6
- variables: {
7
- 2: [false],
8
- },
9
- validators: {
10
- options: {
11
- 4: [false],
12
- },
13
- variables: {
14
- 3: [false],
15
- },
16
- },
17
- documents: {},
18
- sections: {},
19
- prefillers: {
20
- 3: [[false, false, false]],
21
- },
22
- };
23
- describe('addMultipleOccurencyReducer test suit', () => {
24
- it('Throws an error if optionRelations or prefillersVariables are undefined', () => {
25
- expect(() => {
26
- addMultipleOccurencyReducer(state, {
27
- id: 3,
28
- optionRelations: undefined,
29
- prefillersVariables: undefined,
30
- });
31
- }).toThrowError('ADD_MULTIPLE_OCCURENCY reducer did not recieve complete data when adding occurency for 3,' +
32
- ' please make sure "multiplesActions" middleware is plugged and working properly');
33
- });
34
- it('Adds a multiple occurency conditions correctly', () => {
35
- const optionRelations = {
36
- options: [],
37
- variables: [],
38
- sections: {},
39
- documents: [],
40
- prefillers: [],
41
- validators: {
42
- options: [],
43
- variables: [],
44
- },
45
- parents: [],
46
- children: {
47
- options: [3, 4],
48
- variables: [2, 3],
49
- },
50
- dependants: [7, 8],
51
- };
52
- const prefillersVariables = {
53
- '3': [
54
- {
55
- value: 'Option 2 selected',
56
- conditions: {
57
- selected: [
58
- {
59
- var: 'o.4',
60
- },
61
- ],
62
- },
63
- },
64
- {
65
- value: 'Option 1 selected',
66
- conditions: {
67
- selected: [
68
- {
69
- var: 'o.3',
70
- },
71
- ],
72
- },
73
- },
74
- {
75
- value: 'Variable 1 = Hello',
76
- conditions: {
77
- contains: [
78
- {
79
- var: 'v.1',
80
- },
81
- 'Hello',
82
- ],
83
- },
84
- },
85
- ],
86
- };
87
- const reducerResult = addMultipleOccurencyReducer(state, {
88
- id: 2,
89
- optionRelations,
90
- prefillersVariables,
91
- });
92
- expect(reducerResult).toStrictEqual(Object.assign(Object.assign({}, state), { options: Object.assign(Object.assign({}, state.options), { 4: [true, false] }), variables: {
93
- 2: [false, false],
94
- }, prefillers: {
95
- 3: [
96
- [false, false, false],
97
- [false, false, false],
98
- ],
99
- }, validators: {
100
- options: {
101
- 4: [false, false],
102
- },
103
- variables: {
104
- 3: [false, false],
105
- },
106
- } }));
107
- });
108
- });
@@ -1,77 +0,0 @@
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
- });
@@ -1,35 +0,0 @@
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
- });
@@ -1,35 +0,0 @@
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
- });
@@ -1,35 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,196 +0,0 @@
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
- });