@ukhomeoffice/cop-react-form-renderer 5.14.0 → 5.14.4

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 (328) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +15 -15
  2. package/dist/components/CheckYourAnswers/Answer.test.js +94 -128
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +99 -129
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +291 -501
  5. package/dist/components/CheckYourAnswers/index.js +2 -3
  6. package/dist/components/CollectionPage/CollectionPage.js +64 -58
  7. package/dist/components/CollectionPage/CollectionPage.test.js +212 -238
  8. package/dist/components/CollectionPage/index.js +2 -3
  9. package/dist/components/FormComponent/Collection.js +77 -113
  10. package/dist/components/FormComponent/Collection.test.js +688 -787
  11. package/dist/components/FormComponent/Container.js +44 -43
  12. package/dist/components/FormComponent/Container.test.js +316 -346
  13. package/dist/components/FormComponent/FormComponent.js +58 -64
  14. package/dist/components/FormComponent/FormComponent.test.js +180 -219
  15. package/dist/components/FormComponent/helpers/addLabel.js +5 -9
  16. package/dist/components/FormComponent/helpers/getComponentDisabled.js +2 -3
  17. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
  18. package/dist/components/FormComponent/helpers/getComponentError.js +4 -7
  19. package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
  20. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +2 -2
  21. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
  22. package/dist/components/FormComponent/helpers/index.js +5 -5
  23. package/dist/components/FormComponent/index.js +2 -3
  24. package/dist/components/FormPage/FormPage.js +65 -79
  25. package/dist/components/FormPage/FormPage.test.js +134 -170
  26. package/dist/components/FormPage/index.js +2 -3
  27. package/dist/components/FormRenderer/FormRenderer.js +151 -193
  28. package/dist/components/FormRenderer/FormRenderer.test.js +598 -920
  29. package/dist/components/FormRenderer/handlers/cyaAction.js +4 -5
  30. package/dist/components/FormRenderer/handlers/getPageId.js +2 -5
  31. package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
  32. package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
  33. package/dist/components/FormRenderer/handlers/index.js +3 -4
  34. package/dist/components/FormRenderer/handlers/navigate.js +5 -6
  35. package/dist/components/FormRenderer/handlers/submissionError.js +2 -3
  36. package/dist/components/FormRenderer/helpers/canActionProceed.js +2 -3
  37. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +10 -10
  38. package/dist/components/FormRenderer/helpers/canCYASubmit.js +2 -5
  39. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
  40. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +19 -27
  41. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +17 -17
  42. package/dist/components/FormRenderer/helpers/getCYA.js +6 -9
  43. package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
  44. package/dist/components/FormRenderer/helpers/getFormState.js +7 -10
  45. package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
  46. package/dist/components/FormRenderer/helpers/getNextPageId.js +19 -34
  47. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
  48. package/dist/components/FormRenderer/helpers/getPage.js +3 -6
  49. package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
  50. package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -13
  51. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
  52. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +12 -13
  53. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +98 -92
  54. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +66 -66
  55. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +72 -79
  56. package/dist/components/FormRenderer/helpers/index.js +3 -4
  57. package/dist/components/FormRenderer/index.js +2 -3
  58. package/dist/components/FormRenderer/onCYAAction.js +52 -62
  59. package/dist/components/FormRenderer/onCYAAction.test.js +146 -138
  60. package/dist/components/FormRenderer/onPageAction.js +48 -47
  61. package/dist/components/FormRenderer/onPageAction.test.js +219 -205
  62. package/dist/components/FormRenderer/onTaskAction.js +12 -17
  63. package/dist/components/FormRenderer/onTaskAction.test.js +94 -89
  64. package/dist/components/PageActions/ActionButton.js +15 -19
  65. package/dist/components/PageActions/ActionButton.test.js +58 -79
  66. package/dist/components/PageActions/PageActions.js +12 -13
  67. package/dist/components/PageActions/PageActions.test.js +88 -116
  68. package/dist/components/PageActions/index.js +2 -3
  69. package/dist/components/SummaryList/GroupAction.js +15 -23
  70. package/dist/components/SummaryList/GroupAction.test.js +41 -37
  71. package/dist/components/SummaryList/RowAction.js +14 -19
  72. package/dist/components/SummaryList/RowAction.test.js +41 -37
  73. package/dist/components/SummaryList/SummaryList.js +25 -30
  74. package/dist/components/SummaryList/SummaryList.test.js +160 -182
  75. package/dist/components/SummaryList/SummaryListHeadingRow.js +9 -8
  76. package/dist/components/SummaryList/SummaryListRow.js +9 -8
  77. package/dist/components/SummaryList/SummaryListTitleRow.js +8 -7
  78. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -8
  79. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +24 -24
  80. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -8
  81. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +24 -24
  82. package/dist/components/SummaryList/helpers/index.js +2 -2
  83. package/dist/components/SummaryList/index.js +2 -3
  84. package/dist/components/TaskList/Task.js +22 -33
  85. package/dist/components/TaskList/Task.test.js +84 -77
  86. package/dist/components/TaskList/TaskList.js +46 -75
  87. package/dist/components/TaskList/TaskList.test.js +118 -113
  88. package/dist/components/TaskList/TaskState.js +9 -9
  89. package/dist/components/TaskList/TaskState.test.js +56 -49
  90. package/dist/components/TaskList/index.js +2 -3
  91. package/dist/components/index.js +8 -8
  92. package/dist/context/HooksContext/HooksContext.js +59 -85
  93. package/dist/context/HooksContext/HooksContext.test.js +28 -36
  94. package/dist/context/HooksContext/index.js +4 -6
  95. package/dist/context/ValidationContext/ValidationContext.js +35 -76
  96. package/dist/context/ValidationContext/ValidationContext.test.js +50 -61
  97. package/dist/context/ValidationContext/index.js +4 -6
  98. package/dist/context/index.js +3 -3
  99. package/dist/hooks/index.js +10 -11
  100. package/dist/hooks/useAxios.js +17 -43
  101. package/dist/hooks/useGetRequest.js +65 -106
  102. package/dist/hooks/useHooks.js +2 -5
  103. package/dist/hooks/useRefData.js +30 -45
  104. package/dist/hooks/useValidation.js +2 -5
  105. package/dist/index.js +15 -17
  106. package/dist/models/CollectionLabels.js +2 -3
  107. package/dist/models/ComponentTypes.js +25 -26
  108. package/dist/models/EventTypes.js +5 -6
  109. package/dist/models/FormPages.js +5 -6
  110. package/dist/models/FormTypes.js +9 -10
  111. package/dist/models/HubFormats.js +4 -5
  112. package/dist/models/PageAction.js +45 -42
  113. package/dist/models/TaskStates.js +30 -31
  114. package/dist/models/index.js +11 -12
  115. package/dist/setupTests.js +20 -24
  116. package/dist/utils/CheckYourAnswers/getCYAAction.js +6 -7
  117. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
  118. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +18 -20
  119. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +21 -23
  120. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -21
  121. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +18 -20
  122. package/dist/utils/CheckYourAnswers/getCYARow.js +8 -10
  123. package/dist/utils/CheckYourAnswers/getCYARow.test.js +72 -72
  124. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +20 -27
  125. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
  126. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +41 -47
  127. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +72 -75
  128. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +71 -78
  129. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +133 -114
  130. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +27 -23
  131. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
  132. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +16 -23
  133. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +77 -83
  134. package/dist/utils/CheckYourAnswers/index.js +3 -4
  135. package/dist/utils/CheckYourAnswers/showComponentCYA.js +7 -9
  136. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
  137. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +9 -16
  138. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +19 -20
  139. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +4 -8
  140. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +15 -15
  141. package/dist/utils/CollectionPage/index.js +3 -4
  142. package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -29
  143. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +15 -15
  144. package/dist/utils/Component/addShowWhen.js +5 -10
  145. package/dist/utils/Component/addShowWhen.test.js +38 -38
  146. package/dist/utils/Component/applyToComponentTree.js +20 -22
  147. package/dist/utils/Component/applyToComponentTree.test.js +28 -33
  148. package/dist/utils/Component/cleanAttributes.js +11 -16
  149. package/dist/utils/Component/cleanAttributes.test.js +17 -18
  150. package/dist/utils/Component/elevateNestedComponents.js +7 -9
  151. package/dist/utils/Component/elevateNestedComponents.test.js +19 -19
  152. package/dist/utils/Component/getComponent.js +91 -99
  153. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
  154. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +51 -63
  155. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +41 -49
  156. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -37
  157. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
  158. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +19 -23
  159. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +23 -27
  160. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +12 -11
  161. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
  162. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
  163. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
  164. package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +24 -27
  165. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
  166. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
  167. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +19 -23
  168. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +59 -73
  169. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +19 -23
  170. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +19 -23
  171. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +35 -41
  172. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +24 -32
  173. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
  174. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
  175. package/dist/utils/Component/getDefaultValue.js +7 -9
  176. package/dist/utils/Component/getDefaultValue.test.js +14 -14
  177. package/dist/utils/Component/index.js +3 -4
  178. package/dist/utils/Component/isEditable.js +3 -7
  179. package/dist/utils/Component/isEditable.test.js +14 -15
  180. package/dist/utils/Component/optionIsSelected.js +2 -3
  181. package/dist/utils/Component/optionIsSelected.test.js +10 -10
  182. package/dist/utils/Component/setupContainerComponentsPath.js +30 -33
  183. package/dist/utils/Component/setupContainerComponentsPath.test.js +16 -16
  184. package/dist/utils/Component/showComponent.js +4 -6
  185. package/dist/utils/Component/showComponent.test.js +29 -29
  186. package/dist/utils/Component/wrapInFormGroup.js +6 -6
  187. package/dist/utils/Condition/index.js +3 -4
  188. package/dist/utils/Condition/meetsAllConditions.js +9 -10
  189. package/dist/utils/Condition/meetsAllConditions.test.js +18 -18
  190. package/dist/utils/Condition/meetsCondition.js +19 -27
  191. package/dist/utils/Condition/meetsCondition.test.js +377 -377
  192. package/dist/utils/Condition/meetsOneCondition.js +7 -8
  193. package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
  194. package/dist/utils/Condition/setupConditions.js +15 -21
  195. package/dist/utils/Condition/setupConditions.test.js +8 -8
  196. package/dist/utils/Container/getEditableComponents.js +5 -8
  197. package/dist/utils/Container/getEditableComponents.test.js +44 -46
  198. package/dist/utils/Container/index.js +3 -4
  199. package/dist/utils/Container/setupNesting.js +17 -24
  200. package/dist/utils/Container/setupNesting.test.js +28 -31
  201. package/dist/utils/Container/showContainer.js +5 -10
  202. package/dist/utils/Container/showContainer.test.js +31 -31
  203. package/dist/utils/Data/applyFormula.js +41 -52
  204. package/dist/utils/Data/applyFormula.test.js +26 -26
  205. package/dist/utils/Data/getAutocompleteSource.js +11 -14
  206. package/dist/utils/Data/getAutocompleteSource.test.js +59 -59
  207. package/dist/utils/Data/getDataPath.js +21 -32
  208. package/dist/utils/Data/getDataPath.test.js +20 -20
  209. package/dist/utils/Data/getOptions.js +22 -28
  210. package/dist/utils/Data/getOptions.test.js +21 -21
  211. package/dist/utils/Data/getSourceData.js +7 -21
  212. package/dist/utils/Data/getSourceData.test.js +85 -81
  213. package/dist/utils/Data/index.js +3 -4
  214. package/dist/utils/Data/refDataToOptions.js +12 -17
  215. package/dist/utils/Data/refDataToOptions.test.js +20 -20
  216. package/dist/utils/Data/setDataItem.js +8 -10
  217. package/dist/utils/Data/setDataItem.test.js +38 -38
  218. package/dist/utils/Data/setupFormData.js +32 -48
  219. package/dist/utils/Data/setupFormData.test.js +99 -98
  220. package/dist/utils/Data/setupRefDataUrlForComponent.js +22 -30
  221. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +28 -28
  222. package/dist/utils/FormPage/applyConditionalProperties.js +7 -12
  223. package/dist/utils/FormPage/applyConditionalProperties.test.js +16 -19
  224. package/dist/utils/FormPage/getFormPage.js +17 -19
  225. package/dist/utils/FormPage/getFormPage.test.js +49 -48
  226. package/dist/utils/FormPage/getFormPages.js +9 -15
  227. package/dist/utils/FormPage/getFormPages.test.js +22 -25
  228. package/dist/utils/FormPage/getPageActions.js +11 -19
  229. package/dist/utils/FormPage/getPageActions.test.js +33 -33
  230. package/dist/utils/FormPage/getParagraphFromText.js +6 -9
  231. package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
  232. package/dist/utils/FormPage/index.js +3 -4
  233. package/dist/utils/FormPage/showFormPage.js +5 -10
  234. package/dist/utils/FormPage/showFormPage.test.js +33 -33
  235. package/dist/utils/FormPage/showFormPageCYA.js +4 -5
  236. package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
  237. package/dist/utils/FormPage/useComponent.js +21 -29
  238. package/dist/utils/FormPage/useComponent.test.js +71 -73
  239. package/dist/utils/Format/formatData.js +2 -3
  240. package/dist/utils/Format/formatData.test.js +19 -19
  241. package/dist/utils/Format/formatDataForComponent.js +6 -9
  242. package/dist/utils/Format/formatDataForComponent.test.js +50 -78
  243. package/dist/utils/Format/formatDataForForm.js +7 -10
  244. package/dist/utils/Format/formatDataForForm.test.js +14 -17
  245. package/dist/utils/Format/formatDataForPage.js +4 -7
  246. package/dist/utils/Format/formatDataForPage.test.js +20 -25
  247. package/dist/utils/Format/index.js +3 -4
  248. package/dist/utils/Hub/getFormHub.js +3 -4
  249. package/dist/utils/Hub/getFormHub.test.js +29 -32
  250. package/dist/utils/Hub/index.js +3 -4
  251. package/dist/utils/Meta/constants.js +2 -4
  252. package/dist/utils/Meta/documents/getDocuments.js +2 -6
  253. package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
  254. package/dist/utils/Meta/documents/index.js +3 -4
  255. package/dist/utils/Meta/documents/setDocumentsForField.js +16 -19
  256. package/dist/utils/Meta/documents/setDocumentsForField.test.js +69 -35
  257. package/dist/utils/Meta/index.js +3 -4
  258. package/dist/utils/Operate/checkValueIsTruthy.js +5 -6
  259. package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
  260. package/dist/utils/Operate/getFirstOf.js +9 -10
  261. package/dist/utils/Operate/getFirstOf.test.js +33 -33
  262. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +13 -14
  263. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
  264. package/dist/utils/Operate/index.js +3 -4
  265. package/dist/utils/Operate/persistValueInFormData.js +7 -8
  266. package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
  267. package/dist/utils/Operate/runPageOperations.js +10 -11
  268. package/dist/utils/Operate/runPageOperations.test.js +36 -37
  269. package/dist/utils/Operate/setValueInFormData.js +6 -7
  270. package/dist/utils/Operate/setValueInFormData.test.js +17 -17
  271. package/dist/utils/Operate/shouldRun.js +9 -10
  272. package/dist/utils/Operate/shouldRun.test.js +22 -28
  273. package/dist/utils/Validate/additional/conditionallyRequired.js +5 -7
  274. package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
  275. package/dist/utils/Validate/additional/index.js +8 -9
  276. package/dist/utils/Validate/additional/index.test.js +13 -13
  277. package/dist/utils/Validate/additional/mustBeAfter.js +4 -5
  278. package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
  279. package/dist/utils/Validate/additional/mustBeBefore.js +4 -5
  280. package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
  281. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -14
  282. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +34 -38
  283. package/dist/utils/Validate/additional/mustBeGreaterThan.js +3 -4
  284. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
  285. package/dist/utils/Validate/additional/mustBeInTheFuture.js +5 -6
  286. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
  287. package/dist/utils/Validate/additional/mustBeInThePast.js +6 -7
  288. package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
  289. package/dist/utils/Validate/additional/mustBeLessThan.js +3 -4
  290. package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
  291. package/dist/utils/Validate/additional/mustBeLongerThan.js +2 -3
  292. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
  293. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +3 -4
  294. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
  295. package/dist/utils/Validate/additional/mustBeShorterThan.js +2 -3
  296. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
  297. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +4 -7
  298. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
  299. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +2 -3
  300. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
  301. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +4 -7
  302. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
  303. package/dist/utils/Validate/additional/utils.js +9 -25
  304. package/dist/utils/Validate/index.js +3 -4
  305. package/dist/utils/Validate/validateCollection.js +22 -29
  306. package/dist/utils/Validate/validateCollection.test.js +85 -77
  307. package/dist/utils/Validate/validateComponent.js +19 -19
  308. package/dist/utils/Validate/validateComponent.test.js +169 -147
  309. package/dist/utils/Validate/validateContainer.js +16 -22
  310. package/dist/utils/Validate/validateContainer.test.js +52 -48
  311. package/dist/utils/Validate/validateDate.js +14 -21
  312. package/dist/utils/Validate/validateDate.test.js +28 -29
  313. package/dist/utils/Validate/validateEmail.js +8 -11
  314. package/dist/utils/Validate/validateEmail.test.js +26 -26
  315. package/dist/utils/Validate/validateMultifile.js +6 -10
  316. package/dist/utils/Validate/validateMultifile.test.js +17 -18
  317. package/dist/utils/Validate/validatePage.js +20 -22
  318. package/dist/utils/Validate/validatePage.test.js +146 -143
  319. package/dist/utils/Validate/validateRegex.js +6 -10
  320. package/dist/utils/Validate/validateRegex.test.js +17 -17
  321. package/dist/utils/Validate/validateRequired.js +6 -9
  322. package/dist/utils/Validate/validateRequired.test.js +19 -19
  323. package/dist/utils/Validate/validateTextArea.js +6 -9
  324. package/dist/utils/Validate/validateTextArea.test.js +21 -21
  325. package/dist/utils/Validate/validateTime.js +8 -16
  326. package/dist/utils/Validate/validateTime.test.js +15 -15
  327. package/dist/utils/index.js +10 -12
  328. package/package.json +9 -6
@@ -5,77 +5,68 @@ var _utils = _interopRequireDefault(require("../../utils"));
5
5
  var _handlers = _interopRequireDefault(require("./handlers"));
6
6
  var _helpers = _interopRequireDefault(require("./helpers"));
7
7
  var _onPageAction = _interopRequireDefault(require("./onPageAction"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
10
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
- jest.mock('./handlers', function () {
16
- return {
17
- navigateCalls: 0,
18
- navigate: function navigate() {
19
- this.navigateCalls += 1;
20
- },
21
- submissionErrorCalls: 0,
22
- submissionErrorArgs: [],
23
- submissionError: function submissionError(errors, addErrors) {
24
- this.submissionErrorCalls += 1;
25
- this.submissionErrorArgs.push(errors);
26
- if (typeof addErrors === 'function') {
27
- addErrors(errors);
28
- }
29
- },
30
- reset: function reset() {
31
- this.navigateCalls = 0;
32
- this.submissionErrorCalls = 0;
33
- this.submissionErrorArgs = [];
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ jest.mock('./handlers', () => ({
10
+ navigateCalls: 0,
11
+ navigate() {
12
+ this.navigateCalls += 1;
13
+ },
14
+ submissionErrorCalls: 0,
15
+ submissionErrorArgs: [],
16
+ submissionError(errors, addErrors) {
17
+ this.submissionErrorCalls += 1;
18
+ this.submissionErrorArgs.push(errors);
19
+ if (typeof addErrors === 'function') {
20
+ addErrors(errors);
34
21
  }
35
- };
36
- });
37
- jest.mock('./helpers', function () {
38
- return {
39
- canActionProceedCalls: 0,
40
- canActionProceedResult: true,
41
- canActionProceed: function canActionProceed(action, page, validator) {
42
- this.canActionProceedCalls += 1;
43
- if (typeof validator === 'function') {
44
- validator();
45
- }
46
- return this.canActionProceedResult;
47
- },
48
- cleanHiddenNestedDataCalls: 0,
49
- cleanHiddenNestedData: function cleanHiddenNestedData(patch) {
50
- this.cleanHiddenNestedDataCalls += 1;
51
- return patch;
52
- },
53
- getNextPageIdCalls: 0,
54
- getNextPageId: function getNextPageId() {
55
- this.getNextPageIdCalls += 1;
56
- return 'page2';
57
- },
58
- getSubmissionStatusCalls: 0,
59
- getSubmissionStatus: function getSubmissionStatus() {
60
- this.getSubmissionStatusCalls += 1;
61
- return 'Good to go!';
62
- },
63
- reset: function reset() {
64
- this.canActionProceedCalls = 0;
65
- this.canActionProceedResult = true;
66
- this.canCYASubmitResult = true;
67
- this.cleanHiddenNestedDataCalls = 0;
68
- this.getFormStateCalls = 0;
69
- this.getSubmissionStatusCalls = 0;
22
+ },
23
+ reset() {
24
+ this.navigateCalls = 0;
25
+ this.submissionErrorCalls = 0;
26
+ this.submissionErrorArgs = [];
27
+ }
28
+ }));
29
+ jest.mock('./helpers', () => ({
30
+ canActionProceedCalls: 0,
31
+ canActionProceedResult: true,
32
+ canActionProceed(action, page, validator) {
33
+ this.canActionProceedCalls += 1;
34
+ if (typeof validator === 'function') {
35
+ validator();
70
36
  }
71
- };
72
- });
73
- jest.mock('../../utils', function () {
74
- var originalModule = jest.requireActual('../../utils');
75
- return _objectSpread(_objectSpread({}, originalModule.default), {}, {
37
+ return this.canActionProceedResult;
38
+ },
39
+ cleanHiddenNestedDataCalls: 0,
40
+ cleanHiddenNestedData(patch) {
41
+ this.cleanHiddenNestedDataCalls += 1;
42
+ return patch;
43
+ },
44
+ getNextPageIdCalls: 0,
45
+ getNextPageId() {
46
+ this.getNextPageIdCalls += 1;
47
+ return 'page2';
48
+ },
49
+ getSubmissionStatusCalls: 0,
50
+ getSubmissionStatus() {
51
+ this.getSubmissionStatusCalls += 1;
52
+ return 'Good to go!';
53
+ },
54
+ reset() {
55
+ this.canActionProceedCalls = 0;
56
+ this.canActionProceedResult = true;
57
+ this.canCYASubmitResult = true;
58
+ this.cleanHiddenNestedDataCalls = 0;
59
+ this.getFormStateCalls = 0;
60
+ this.getSubmissionStatusCalls = 0;
61
+ }
62
+ }));
63
+ jest.mock('../../utils', () => {
64
+ const originalModule = jest.requireActual('../../utils');
65
+ return {
66
+ ...originalModule.default,
76
67
  Format: {
77
68
  formCalls: 0,
78
- form: function form(_form, data) {
69
+ form(form, data) {
79
70
  this.formCalls += 1;
80
71
  return data;
81
72
  }
@@ -83,29 +74,29 @@ jest.mock('../../utils', function () {
83
74
  CollectionPage: {
84
75
  duplicateActiveEntryCalls: 0,
85
76
  duplicateActiveEntryResult: true,
86
- duplicateActiveEntry: function duplicateActiveEntry() {
77
+ duplicateActiveEntry() {
87
78
  this.duplicateActiveEntryCalls += 1;
88
79
  return this.duplicateActiveEntryResult;
89
80
  }
90
81
  },
91
- reset: function reset() {
82
+ reset() {
92
83
  this.Format.formCalls = 0;
93
84
  this.CollectionPage.duplicateActiveEntryCalls = 0;
94
85
  this.duplicateActiveEntryResult = true;
95
86
  }
96
- });
87
+ };
97
88
  });
98
- describe('components.FormRenderer.onPageAction', function () {
99
- var MOCK_HOOKS = {
89
+ describe('components.FormRenderer.onPageAction', () => {
90
+ const MOCK_HOOKS = {
100
91
  onSubmitCalls: 0,
101
92
  onSubmitArgs: [],
102
- onSubmit: function onSubmit(type, payload, onSuccess, onError, changedFieldName, changedFieldValue) {
93
+ onSubmit(type, payload, onSuccess, onError, changedFieldName, changedFieldValue) {
103
94
  this.onSubmitCalls += 1;
104
95
  this.onSubmitArgs.push({
105
- type: type,
106
- payload: payload,
107
- changedFieldName: changedFieldName,
108
- changedFieldValue: changedFieldValue
96
+ type,
97
+ payload,
98
+ changedFieldName,
99
+ changedFieldValue
109
100
  });
110
101
  if (typeof onSuccess === 'function') {
111
102
  onSuccess();
@@ -118,14 +109,14 @@ describe('components.FormRenderer.onPageAction', function () {
118
109
  }
119
110
  },
120
111
  onFormCompleteCalls: 0,
121
- onFormComplete: function onFormComplete() {
112
+ onFormComplete() {
122
113
  this.onFormCompleteCalls += 1;
123
114
  },
124
115
  onCancelArgs: [],
125
- onCancel: function onCancel(data) {
116
+ onCancel(data) {
126
117
  this.onCancelArgs.push(data);
127
118
  },
128
- reset: function reset() {
119
+ reset() {
129
120
  this.onSubmitCalls = 0;
130
121
  this.onSubmitArgs = [];
131
122
  this.onFormCompleteCalls = 0;
@@ -133,50 +124,50 @@ describe('components.FormRenderer.onPageAction', function () {
133
124
  this.onActionCalls = 0;
134
125
  },
135
126
  onActionCalls: 0,
136
- onAction: function onAction(formData, patch) {
127
+ onAction(formData, patch) {
137
128
  this.onActionCalls += 1;
138
129
  return {
139
- formData: formData,
140
- patch: patch
130
+ formData,
131
+ patch
141
132
  };
142
133
  }
143
134
  };
144
- var MOCK_VALIDATE = {
135
+ const MOCK_VALIDATE = {
145
136
  pageCalls: 0,
146
- page: function page() {
137
+ page() {
147
138
  MOCK_VALIDATE.pageCalls += 1;
148
139
  },
149
- reset: function reset() {
140
+ reset() {
150
141
  this.pageCalls = 0;
151
142
  }
152
143
  };
153
- var setPagePointCalls = 0;
154
- var setPagePointArgs = [];
155
- var mockSetPagePoint = function mockSetPagePoint(point) {
144
+ let setPagePointCalls = 0;
145
+ let setPagePointArgs = [];
146
+ const mockSetPagePoint = point => {
156
147
  setPagePointCalls += 1;
157
148
  setPagePointArgs.push(point);
158
149
  };
159
- var setDataCalls = 0;
160
- var setDataArgs = [];
161
- var mockSetData = function mockSetData(data) {
150
+ let setDataCalls = 0;
151
+ let setDataArgs = [];
152
+ const mockSetData = data => {
162
153
  setDataCalls += 1;
163
154
  setDataArgs.push(data);
164
155
  };
165
- var onPageChangeCalls = 0;
166
- var onPageChangeArgs = [];
167
- var mockOnPageChange = function mockOnPageChange(pageId) {
156
+ let onPageChangeCalls = 0;
157
+ let onPageChangeArgs = [];
158
+ const mockOnPageChange = pageId => {
168
159
  onPageChangeCalls += 1;
169
160
  onPageChangeArgs.push(pageId);
170
161
  };
171
- var addErrorsArgs = [];
172
- var mockAddErrors = function mockAddErrors(errors) {
162
+ let addErrorsArgs = [];
163
+ const mockAddErrors = errors => {
173
164
  addErrorsArgs.push(errors);
174
165
  };
175
- var setSubmittedArgs = [];
176
- var mockSetSubmitted = function mockSetSubmitted(newSubmitted) {
166
+ let setSubmittedArgs = [];
167
+ const mockSetSubmitted = newSubmitted => {
177
168
  setSubmittedArgs.push(newSubmitted);
178
169
  };
179
- var COMPONENTS = [{
170
+ const COMPONENTS = [{
180
171
  id: 'alpha',
181
172
  fieldId: 'alpha'
182
173
  }, {
@@ -189,18 +180,26 @@ describe('components.FormRenderer.onPageAction', function () {
189
180
  id: 'delta',
190
181
  fieldId: 'delta'
191
182
  }];
192
- var PAGES = [{
183
+ const PAGES = [{
193
184
  id: 'page1',
194
- components: [_objectSpread({}, COMPONENTS[0]), _objectSpread({}, COMPONENTS[1])]
185
+ components: [{
186
+ ...COMPONENTS[0]
187
+ }, {
188
+ ...COMPONENTS[1]
189
+ }]
195
190
  }, {
196
191
  id: 'page2',
197
- components: [_objectSpread({}, COMPONENTS[2]), _objectSpread({}, COMPONENTS[3])]
192
+ components: [{
193
+ ...COMPONENTS[2]
194
+ }, {
195
+ ...COMPONENTS[3]
196
+ }]
198
197
  }];
199
- var CURRENT_TASK = {
198
+ const CURRENT_TASK = {
200
199
  name: 'testTask',
201
200
  fullPages: PAGES
202
201
  };
203
- var ARGS = {
202
+ const ARGS = {
204
203
  action: {
205
204
  type: _models.PageAction.TYPES.NAVIGATE
206
205
  },
@@ -226,7 +225,7 @@ describe('components.FormRenderer.onPageAction', function () {
226
225
  setSubmitted: mockSetSubmitted,
227
226
  addErrors: mockAddErrors
228
227
  };
229
- beforeEach(function () {
228
+ beforeEach(() => {
230
229
  _handlers.default.reset();
231
230
  _helpers.default.reset();
232
231
  _utils.default.reset();
@@ -241,12 +240,12 @@ describe('components.FormRenderer.onPageAction', function () {
241
240
  addErrorsArgs = [];
242
241
  setSubmittedArgs = [];
243
242
  });
244
- var preActionChecks = function preActionChecks() {
243
+ const preActionChecks = () => {
245
244
  expect(_helpers.default.canActionProceedCalls).toEqual(1);
246
245
  expect(MOCK_VALIDATE.pageCalls).toEqual(1);
247
246
  expect(_helpers.default.cleanHiddenNestedDataCalls).toEqual(1);
248
247
  };
249
- var postActionChecks = function postActionChecks(argsUsed) {
248
+ const postActionChecks = argsUsed => {
250
249
  expect(_utils.default.Format.formCalls).toEqual(1);
251
250
  expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
252
251
  // setData is always called once in the error callback
@@ -254,8 +253,12 @@ describe('components.FormRenderer.onPageAction', function () {
254
253
  // to this if patch is valid.
255
254
  if (argsUsed.patch) {
256
255
  expect(setDataCalls).toEqual(2);
257
- var dataUsed = _objectSpread(_objectSpread(_objectSpread({}, argsUsed.data), argsUsed.patch), argsUsed.formState.page.formData);
258
- var submissionData = _utils.default.Format.form(null, dataUsed, null);
256
+ const dataUsed = {
257
+ ...argsUsed.data,
258
+ ...argsUsed.patch,
259
+ ...argsUsed.formState.page.formData
260
+ };
261
+ const submissionData = _utils.default.Format.form(null, dataUsed, null);
259
262
  submissionData.formStatus = _helpers.default.getSubmissionStatus();
260
263
  expect(setDataArgs[0]).toEqual(submissionData);
261
264
  } else {
@@ -263,7 +266,7 @@ describe('components.FormRenderer.onPageAction', function () {
263
266
  }
264
267
  expect(MOCK_HOOKS.onSubmitCalls).toEqual(1);
265
268
  if (argsUsed.type === _models.FormTypes.HUB && Object.keys(argsUsed.patchLabel).length > 0) {
266
- var firstKey = Object.keys(argsUsed.patchLabel)[0];
269
+ const firstKey = Object.keys(argsUsed.patchLabel)[0];
267
270
  expect(MOCK_HOOKS.onSubmitArgs[0]).toMatchObject({
268
271
  changedFieldName: firstKey,
269
272
  changedFieldValue: argsUsed.patchLabel[firstKey]
@@ -281,14 +284,14 @@ describe('components.FormRenderer.onPageAction', function () {
281
284
  expect(_handlers.default.submissionErrorCalls).toEqual(1);
282
285
  expect(setDataArgs[setDataCalls - 1]).toEqual(argsUsed.data); // Data is reset in the case of an error.
283
286
  };
284
-
285
- it("should handle the ".concat(_models.PageAction.TYPES.CANCEL, " Page Action type"), function () {
286
- var ACTION = {
287
+ it(`should handle the ${_models.PageAction.TYPES.CANCEL} Page Action type`, () => {
288
+ const ACTION = {
287
289
  type: _models.PageAction.TYPES.CANCEL
288
290
  };
289
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
291
+ const CUSTOM_ARGS = {
292
+ ...ARGS,
290
293
  action: ACTION
291
- });
294
+ };
292
295
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
293
296
  expect(MOCK_HOOKS.onCancelArgs.length).toEqual(1);
294
297
  expect(MOCK_HOOKS.onCancelArgs[0]).toMatchObject({});
@@ -297,13 +300,14 @@ describe('components.FormRenderer.onPageAction', function () {
297
300
  expect(_helpers.default.canActionProceedCalls).toEqual(0);
298
301
  expect(MOCK_VALIDATE.pageCalls).toEqual(0);
299
302
  });
300
- it("should handle the ".concat(_models.PageAction.TYPES.NAVIGATE, " Page Action type"), function () {
301
- var ACTION = {
303
+ it(`should handle the ${_models.PageAction.TYPES.NAVIGATE} Page Action type`, () => {
304
+ const ACTION = {
302
305
  type: _models.PageAction.TYPES.NAVIGATE
303
306
  };
304
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
307
+ const CUSTOM_ARGS = {
308
+ ...ARGS,
305
309
  action: ACTION
306
- });
310
+ };
307
311
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
308
312
  preActionChecks();
309
313
  expect(_handlers.default.navigateCalls).toEqual(1);
@@ -312,27 +316,28 @@ describe('components.FormRenderer.onPageAction', function () {
312
316
  // as a navigate action should stop at calling
313
317
  // hooks.navigate.
314
318
  });
315
-
316
- it("should handle the ".concat(_models.PageAction.TYPES.SUBMIT, " Page Action type"), function () {
317
- var ACTION = {
319
+ it(`should handle the ${_models.PageAction.TYPES.SUBMIT} Page Action type`, () => {
320
+ const ACTION = {
318
321
  type: _models.PageAction.TYPES.SUBMIT
319
322
  };
320
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
323
+ const CUSTOM_ARGS = {
324
+ ...ARGS,
321
325
  action: ACTION
322
- });
326
+ };
323
327
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
324
328
  preActionChecks();
325
329
  expect(setPagePointCalls).toEqual(1);
326
330
  expect(setPagePointArgs[0]).toEqual('submit');
327
331
  postActionChecks(CUSTOM_ARGS);
328
332
  });
329
- it("should handle the ".concat(_models.PageAction.TYPES.SAVE_AND_NAVIGATE, " Page Action type"), function () {
330
- var ACTION = {
333
+ it(`should handle the ${_models.PageAction.TYPES.SAVE_AND_NAVIGATE} Page Action type`, () => {
334
+ const ACTION = {
331
335
  type: _models.PageAction.TYPES.SAVE_AND_NAVIGATE
332
336
  };
333
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
337
+ const CUSTOM_ARGS = {
338
+ ...ARGS,
334
339
  action: ACTION
335
- });
340
+ };
336
341
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
337
342
  preActionChecks();
338
343
  // All the actions does in this case is set a function
@@ -340,48 +345,50 @@ describe('components.FormRenderer.onPageAction', function () {
340
345
  postActionChecks(CUSTOM_ARGS);
341
346
  expect(_handlers.default.navigateCalls).toEqual(1);
342
347
  });
343
- it("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_ADD, " Page Action type"), function () {
344
- var FORM_STATE = {
348
+ it(`should handle the ${_models.PageAction.TYPES.COLLECTION_ADD} Page Action type`, () => {
349
+ const FORM_STATE = {
345
350
  page: {
346
351
  formData: {
347
352
  'testCollection': []
348
353
  }
349
354
  }
350
355
  };
351
- var ACTION = {
356
+ const ACTION = {
352
357
  type: _models.PageAction.TYPES.COLLECTION_ADD,
353
358
  collection: 'testCollection'
354
359
  };
355
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
360
+ const CUSTOM_ARGS = {
361
+ ...ARGS,
356
362
  action: ACTION,
357
363
  formState: FORM_STATE
358
- });
364
+ };
359
365
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
360
366
  preActionChecks();
361
- expect(FORM_STATE.page.formData["".concat(ACTION.collection, "ActiveId")]).toBeDefined();
367
+ expect(FORM_STATE.page.formData[`${ACTION.collection}ActiveId`]).toBeDefined();
362
368
  postActionChecks(CUSTOM_ARGS);
363
369
 
364
370
  // This action type also sets up a call to handlers.navigate
365
371
  // that's called as part of the onSubmit hook's onSuccess callback.
366
372
  expect(_handlers.default.navigateCalls).toEqual(1);
367
373
  });
368
- describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_DUPLICATE, " Page Action type"), function () {
369
- it("calling handlers.navigate if the duplication was successful", function () {
370
- var FORM_STATE = {
374
+ describe(`should handle the ${_models.PageAction.TYPES.COLLECTION_DUPLICATE} Page Action type`, () => {
375
+ it(`calling handlers.navigate if the duplication was successful`, () => {
376
+ const FORM_STATE = {
371
377
  page: {
372
378
  formData: {
373
379
  'testCollection': []
374
380
  }
375
381
  }
376
382
  };
377
- var ACTION = {
383
+ const ACTION = {
378
384
  type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
379
385
  collection: 'testCollection'
380
386
  };
381
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
387
+ const CUSTOM_ARGS = {
388
+ ...ARGS,
382
389
  action: ACTION,
383
390
  formState: FORM_STATE
384
- });
391
+ };
385
392
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
386
393
  preActionChecks();
387
394
  expect(_utils.default.CollectionPage.duplicateActiveEntryCalls).toEqual(1);
@@ -391,22 +398,23 @@ describe('components.FormRenderer.onPageAction', function () {
391
398
  // that's called as part of the onSubmit hook's onSuccess callback.
392
399
  expect(_handlers.default.navigateCalls).toEqual(1);
393
400
  });
394
- it("calling onPageChange if the duplication was unsuccessful", function () {
395
- var FORM_STATE = {
401
+ it(`calling onPageChange if the duplication was unsuccessful`, () => {
402
+ const FORM_STATE = {
396
403
  page: {
397
404
  formData: {
398
405
  'testCollection': []
399
406
  }
400
407
  }
401
408
  };
402
- var ACTION = {
409
+ const ACTION = {
403
410
  type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
404
411
  collection: 'testCollection'
405
412
  };
406
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
413
+ const CUSTOM_ARGS = {
414
+ ...ARGS,
407
415
  action: ACTION,
408
416
  formState: FORM_STATE
409
- });
417
+ };
410
418
  _utils.default.CollectionPage.duplicateActiveEntryResult = false;
411
419
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
412
420
  preActionChecks();
@@ -420,9 +428,9 @@ describe('components.FormRenderer.onPageAction', function () {
420
428
  expect(onPageChangeCalls).toEqual(1);
421
429
  });
422
430
  });
423
- describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_REMOVE, " Page Action type"), function () {
424
- it("should store a reference to the removed item if action.recordRemoval is true", function () {
425
- var FORM_STATE = {
431
+ describe(`should handle the ${_models.PageAction.TYPES.COLLECTION_REMOVE} Page Action type`, () => {
432
+ it(`should store a reference to the removed item if action.recordRemoval is true`, () => {
433
+ const FORM_STATE = {
426
434
  page: {
427
435
  formData: {
428
436
  testCollectionActiveId: 'removeMe',
@@ -434,15 +442,16 @@ describe('components.FormRenderer.onPageAction', function () {
434
442
  }
435
443
  }
436
444
  };
437
- var ACTION = {
445
+ const ACTION = {
438
446
  type: _models.PageAction.TYPES.COLLECTION_REMOVE,
439
447
  collection: 'testCollection',
440
448
  recordRemoval: true
441
449
  };
442
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
450
+ const CUSTOM_ARGS = {
451
+ ...ARGS,
443
452
  action: ACTION,
444
453
  formState: FORM_STATE
445
- });
454
+ };
446
455
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
447
456
  preActionChecks();
448
457
  expect(FORM_STATE.page.formData.testCollection).toEqual([{
@@ -456,8 +465,8 @@ describe('components.FormRenderer.onPageAction', function () {
456
465
  // This action type uses the default onPageChange.
457
466
  expect(onPageChangeCalls).toEqual(1);
458
467
  });
459
- it("should not store a reference to the removed item if action.recordRemoval is false", function () {
460
- var FORM_STATE = {
468
+ it(`should not store a reference to the removed item if action.recordRemoval is false`, () => {
469
+ const FORM_STATE = {
461
470
  page: {
462
471
  formData: {
463
472
  testCollectionActiveId: 'removeMe',
@@ -469,15 +478,16 @@ describe('components.FormRenderer.onPageAction', function () {
469
478
  }
470
479
  }
471
480
  };
472
- var ACTION = {
481
+ const ACTION = {
473
482
  type: _models.PageAction.TYPES.COLLECTION_REMOVE,
474
483
  collection: 'testCollection',
475
484
  recordRemoval: false
476
485
  };
477
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
486
+ const CUSTOM_ARGS = {
487
+ ...ARGS,
478
488
  action: ACTION,
479
489
  formState: FORM_STATE
480
- });
490
+ };
481
491
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
482
492
  preActionChecks();
483
493
  expect(FORM_STATE.page.formData.testCollection).toEqual([{
@@ -489,8 +499,8 @@ describe('components.FormRenderer.onPageAction', function () {
489
499
  // This action type uses the default onPageChange.
490
500
  expect(onPageChangeCalls).toEqual(1);
491
501
  });
492
- it("should not store a reference to the removed item if action.recordRemoval is not defined", function () {
493
- var FORM_STATE = {
502
+ it(`should not store a reference to the removed item if action.recordRemoval is not defined`, () => {
503
+ const FORM_STATE = {
494
504
  page: {
495
505
  formData: {
496
506
  testCollectionActiveId: 'removeMe',
@@ -502,14 +512,15 @@ describe('components.FormRenderer.onPageAction', function () {
502
512
  }
503
513
  }
504
514
  };
505
- var ACTION = {
515
+ const ACTION = {
506
516
  type: _models.PageAction.TYPES.COLLECTION_REMOVE,
507
517
  collection: 'testCollection'
508
518
  };
509
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
519
+ const CUSTOM_ARGS = {
520
+ ...ARGS,
510
521
  action: ACTION,
511
522
  formState: FORM_STATE
512
- });
523
+ };
513
524
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
514
525
  preActionChecks();
515
526
  expect(FORM_STATE.page.formData.testCollection).toEqual([{
@@ -522,18 +533,17 @@ describe('components.FormRenderer.onPageAction', function () {
522
533
  expect(onPageChangeCalls).toEqual(1);
523
534
  });
524
535
  });
525
- describe('if validation fails', function () {
526
- var VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(function (a) {
527
- return a !== _models.PageAction.TYPES.CANCEL;
528
- });
529
- VALID_ACTIONS.forEach(function (actionType) {
530
- it("should not continue for the ".concat(actionType, " action type"), function () {
531
- var ACTION = {
536
+ describe('if validation fails', () => {
537
+ const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL);
538
+ VALID_ACTIONS.forEach(actionType => {
539
+ it(`should not continue for the ${actionType} action type`, () => {
540
+ const ACTION = {
532
541
  type: actionType
533
542
  };
534
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
543
+ const CUSTOM_ARGS = {
544
+ ...ARGS,
535
545
  action: ACTION
536
- });
546
+ };
537
547
  _helpers.default.canActionProceedResult = false;
538
548
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
539
549
  expect(_helpers.default.canActionProceedCalls).toEqual(1);
@@ -544,20 +554,18 @@ describe('components.FormRenderer.onPageAction', function () {
544
554
  });
545
555
  });
546
556
  });
547
- describe('adding a field to formData if specified on the action', function () {
548
- var VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(function (a) {
549
- return a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE;
550
- });
551
- VALID_ACTIONS.forEach(function (actionType) {
552
- it("should work for the ".concat(actionType, " action type"), function () {
553
- var FORM_STATE = {
557
+ describe('adding a field to formData if specified on the action', () => {
558
+ const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE);
559
+ VALID_ACTIONS.forEach(actionType => {
560
+ it(`should work for the ${actionType} action type`, () => {
561
+ const FORM_STATE = {
554
562
  page: {
555
563
  formData: {
556
564
  testCollection: []
557
565
  }
558
566
  }
559
567
  };
560
- var ACTION = {
568
+ const ACTION = {
561
569
  type: actionType,
562
570
  collection: 'testCollection',
563
571
  addToFormData: {
@@ -565,10 +573,11 @@ describe('components.FormRenderer.onPageAction', function () {
565
573
  value: '123'
566
574
  }
567
575
  };
568
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
576
+ const CUSTOM_ARGS = {
577
+ ...ARGS,
569
578
  formState: FORM_STATE,
570
579
  action: ACTION
571
- });
580
+ };
572
581
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
573
582
  preActionChecks();
574
583
  postActionChecks(CUSTOM_ARGS);
@@ -577,15 +586,15 @@ describe('components.FormRenderer.onPageAction', function () {
577
586
  });
578
587
  });
579
588
  });
580
- it("should work for the ".concat(_models.PageAction.TYPES.NAVIGATE, " action type"), function () {
581
- var FORM_STATE = {
589
+ it(`should work for the ${_models.PageAction.TYPES.NAVIGATE} action type`, () => {
590
+ const FORM_STATE = {
582
591
  page: {
583
592
  formData: {
584
593
  testCollection: []
585
594
  }
586
595
  }
587
596
  };
588
- var ACTION = {
597
+ const ACTION = {
589
598
  type: _models.PageAction.TYPES.NAVIGATE,
590
599
  collection: 'testCollection',
591
600
  addToFormData: {
@@ -593,10 +602,11 @@ describe('components.FormRenderer.onPageAction', function () {
593
602
  value: '123'
594
603
  }
595
604
  };
596
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
605
+ const CUSTOM_ARGS = {
606
+ ...ARGS,
597
607
  formState: FORM_STATE,
598
608
  action: ACTION
599
- });
609
+ };
600
610
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
601
611
  preActionChecks();
602
612
  // Not doing the usual post-action checks here
@@ -606,15 +616,15 @@ describe('components.FormRenderer.onPageAction', function () {
606
616
  alpha: '123'
607
617
  });
608
618
  });
609
- it('should work for an array of formData', function () {
610
- var FORM_STATE = {
619
+ it('should work for an array of formData', () => {
620
+ const FORM_STATE = {
611
621
  page: {
612
622
  formData: {
613
623
  testCollection: []
614
624
  }
615
625
  }
616
626
  };
617
- var ACTION = {
627
+ const ACTION = {
618
628
  type: _models.PageAction.TYPES.NAVIGATE,
619
629
  collection: 'testCollection',
620
630
  addToFormData: [{
@@ -625,10 +635,11 @@ describe('components.FormRenderer.onPageAction', function () {
625
635
  value: '456'
626
636
  }]
627
637
  };
628
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
638
+ const CUSTOM_ARGS = {
639
+ ...ARGS,
629
640
  formState: FORM_STATE,
630
641
  action: ACTION
631
- });
642
+ };
632
643
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
633
644
  preActionChecks();
634
645
  // Not doing the usual post-action checks here
@@ -642,34 +653,37 @@ describe('components.FormRenderer.onPageAction', function () {
642
653
  });
643
654
  });
644
655
  });
645
- describe('recording patchLabel fields correctly when it is defined', function () {
646
- var VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(function (a) {
647
- return a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE;
648
- });
649
- VALID_ACTIONS.forEach(function (actionType) {
650
- it("should work for the ".concat(actionType, " action type"), function () {
651
- var FORM_STATE = {
656
+ describe('recording patchLabel fields correctly when it is defined', () => {
657
+ const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE);
658
+ VALID_ACTIONS.forEach(actionType => {
659
+ it(`should work for the ${actionType} action type`, () => {
660
+ const FORM_STATE = {
652
661
  page: {
653
662
  formData: {
654
663
  testCollection: []
655
664
  }
656
665
  }
657
666
  };
658
- var KEY = 'testField';
659
- var VALUE = 'testValue';
660
- var PATCH_LABEL = _defineProperty({}, KEY, VALUE);
661
- var PATCH = _defineProperty({}, KEY, VALUE);
662
- var ACTION = {
667
+ const KEY = 'testField';
668
+ const VALUE = 'testValue';
669
+ const PATCH_LABEL = {
670
+ [KEY]: VALUE
671
+ };
672
+ const PATCH = {
673
+ [KEY]: VALUE
674
+ };
675
+ const ACTION = {
663
676
  type: actionType,
664
677
  collection: 'testCollection'
665
678
  };
666
- var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
679
+ const CUSTOM_ARGS = {
680
+ ...ARGS,
667
681
  action: ACTION,
668
682
  formState: FORM_STATE,
669
683
  patch: PATCH,
670
684
  patchLabel: PATCH_LABEL,
671
685
  type: _models.FormTypes.HUB
672
- });
686
+ };
673
687
  _onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
674
688
  preActionChecks();
675
689
  postActionChecks(CUSTOM_ARGS); // Specific check for patchLabel done in here.