@ukhomeoffice/cop-react-form-renderer 6.0.6-peter → 6.7.0-alpha

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 (390) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +12 -12
  2. package/dist/components/CheckYourAnswers/Answer.test.js +92 -127
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +101 -131
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.scss +2 -2
  5. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +463 -769
  6. package/dist/components/CollectionPage/CollectionPage.js +75 -59
  7. package/dist/components/CollectionPage/CollectionPage.test.js +316 -366
  8. package/dist/components/CollectionSummary/BannerStrip.js +15 -14
  9. package/dist/components/CollectionSummary/BannerStrip.scss +2 -2
  10. package/dist/components/CollectionSummary/BannerStrip.test.js +98 -59
  11. package/dist/components/CollectionSummary/CollectionSummary.js +144 -135
  12. package/dist/components/CollectionSummary/CollectionSummary.scss +1 -1
  13. package/dist/components/CollectionSummary/CollectionSummary.test.js +167 -197
  14. package/dist/components/CollectionSummary/Confirmation.js +14 -12
  15. package/dist/components/CollectionSummary/Confirmation.scss +1 -1
  16. package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
  17. package/dist/components/CollectionSummary/RenderListView.js +54 -56
  18. package/dist/components/CollectionSummary/RenderListView.scss +10 -1
  19. package/dist/components/CollectionSummary/RenderListView.test.js +89 -78
  20. package/dist/components/CollectionSummary/SummaryCard.js +135 -145
  21. package/dist/components/CollectionSummary/SummaryCard.scss +2 -1
  22. package/dist/components/CollectionSummary/SummaryCard.test.js +943 -932
  23. package/dist/components/CollectionSummary/SummaryCardDetails.js +120 -62
  24. package/dist/components/CollectionSummary/SummaryCardDetails.scss +43 -6
  25. package/dist/components/CollectionSummary/SummaryCardDetails.test.js +261 -120
  26. package/dist/components/CollectionSummary/SummaryCardValidationContext.js +38 -33
  27. package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +62 -73
  28. package/dist/components/FormComponent/Collection.js +81 -108
  29. package/dist/components/FormComponent/Collection.test.js +909 -943
  30. package/dist/components/FormComponent/Container.js +40 -38
  31. package/dist/components/FormComponent/Container.test.js +314 -345
  32. package/dist/components/FormComponent/FormComponent.js +80 -71
  33. package/dist/components/FormComponent/FormComponent.test.js +353 -414
  34. package/dist/components/FormComponent/helpers/addLabel.js +4 -7
  35. package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
  36. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
  37. package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
  38. package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
  39. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
  40. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
  41. package/dist/components/FormComponent/helpers/index.js +4 -4
  42. package/dist/components/FormPage/FormPage.js +65 -80
  43. package/dist/components/FormPage/FormPage.scss +1 -1
  44. package/dist/components/FormPage/FormPage.test.js +127 -163
  45. package/dist/components/FormRenderer/FormRenderer.js +150 -183
  46. package/dist/components/FormRenderer/FormRenderer.scss +1 -1
  47. package/dist/components/FormRenderer/FormRenderer.test.js +730 -1115
  48. package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
  49. package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
  50. package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
  51. package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
  52. package/dist/components/FormRenderer/handlers/index.js +1 -1
  53. package/dist/components/FormRenderer/handlers/navigate.js +3 -3
  54. package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
  55. package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
  56. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +15 -15
  57. package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
  58. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +16 -20
  59. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +17 -22
  60. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
  61. package/dist/components/FormRenderer/helpers/getCYA.js +3 -5
  62. package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
  63. package/dist/components/FormRenderer/helpers/getFormState.js +5 -7
  64. package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
  65. package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -24
  66. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
  67. package/dist/components/FormRenderer/helpers/getPage.js +2 -4
  68. package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
  69. package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
  70. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
  71. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
  72. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +103 -97
  73. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
  74. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -78
  75. package/dist/components/FormRenderer/helpers/index.js +2 -4
  76. package/dist/components/FormRenderer/onCYAAction.js +59 -51
  77. package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
  78. package/dist/components/FormRenderer/onPageAction.js +50 -48
  79. package/dist/components/FormRenderer/onPageAction.test.js +241 -217
  80. package/dist/components/FormRenderer/onTaskAction.js +9 -13
  81. package/dist/components/FormRenderer/onTaskAction.test.js +93 -88
  82. package/dist/components/PageActions/ActionButton.js +12 -15
  83. package/dist/components/PageActions/ActionButton.test.js +56 -78
  84. package/dist/components/PageActions/PageActions.js +10 -10
  85. package/dist/components/PageActions/PageActions.test.js +86 -115
  86. package/dist/components/SummaryList/GroupAction.js +9 -17
  87. package/dist/components/SummaryList/GroupAction.test.js +37 -33
  88. package/dist/components/SummaryList/RowAction.js +11 -16
  89. package/dist/components/SummaryList/RowAction.test.js +37 -33
  90. package/dist/components/SummaryList/SummaryList.js +21 -26
  91. package/dist/components/SummaryList/SummaryList.scss +2 -2
  92. package/dist/components/SummaryList/SummaryList.test.js +143 -166
  93. package/dist/components/SummaryList/SummaryListHeadingRow.js +6 -4
  94. package/dist/components/SummaryList/SummaryListRow.js +6 -4
  95. package/dist/components/SummaryList/SummaryListTitleRow.js +5 -3
  96. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
  97. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
  98. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
  99. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
  100. package/dist/components/SummaryList/helpers/index.js +1 -1
  101. package/dist/components/TaskList/Task.js +19 -29
  102. package/dist/components/TaskList/Task.test.js +83 -76
  103. package/dist/components/TaskList/TaskList.js +45 -71
  104. package/dist/components/TaskList/TaskList.scss +1 -1
  105. package/dist/components/TaskList/TaskList.test.js +113 -111
  106. package/dist/components/TaskList/TaskState.js +7 -5
  107. package/dist/components/TaskList/TaskState.test.js +52 -45
  108. package/dist/components/index.js +7 -7
  109. package/dist/context/HooksContext/HooksContext.js +57 -80
  110. package/dist/context/HooksContext/HooksContext.test.js +26 -35
  111. package/dist/context/HooksContext/index.js +3 -4
  112. package/dist/context/ValidationContext/ValidationContext.js +65 -72
  113. package/dist/context/ValidationContext/ValidationContext.test.js +58 -61
  114. package/dist/context/ValidationContext/index.js +3 -4
  115. package/dist/context/index.js +2 -2
  116. package/dist/hooks/index.js +9 -10
  117. package/dist/hooks/useAxios.js +14 -40
  118. package/dist/hooks/useGetRequest.js +61 -97
  119. package/dist/hooks/useHooks.js +1 -3
  120. package/dist/hooks/useRefData.js +27 -40
  121. package/dist/hooks/useValidation.js +1 -3
  122. package/dist/index.js +13 -14
  123. package/dist/models/CollectionLabels.js +1 -1
  124. package/dist/models/ComponentTypes.js +25 -25
  125. package/dist/models/EventTypes.js +4 -4
  126. package/dist/models/FormPages.js +4 -4
  127. package/dist/models/FormTypes.js +8 -8
  128. package/dist/models/HubFormats.js +3 -3
  129. package/dist/models/PageAction.js +44 -38
  130. package/dist/models/TaskStates.js +29 -28
  131. package/dist/models/index.js +9 -9
  132. package/dist/setupTests.js +30 -31
  133. package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
  134. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +52 -54
  135. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +15 -25
  136. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +33 -35
  137. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -31
  138. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +42 -44
  139. package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
  140. package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
  141. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +18 -24
  142. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +15 -16
  143. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +33 -36
  144. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +58 -61
  145. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +83 -89
  146. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +164 -138
  147. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +25 -20
  148. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +103 -97
  149. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +13 -18
  150. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +70 -76
  151. package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +11 -11
  152. package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +7 -7
  153. package/dist/utils/CheckYourAnswers/index.js +1 -1
  154. package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -5
  155. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +29 -24
  156. package/dist/utils/CollectionPage/addCollectionPageEntry.js +3 -4
  157. package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +7 -27
  158. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
  159. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -18
  160. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +29 -19
  161. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +66 -22
  162. package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
  163. package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
  164. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
  165. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
  166. package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
  167. package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
  168. package/dist/utils/CollectionPage/getErrorsForCollection.js +55 -0
  169. package/dist/utils/CollectionPage/getErrorsForCollection.test.js +153 -0
  170. package/dist/utils/CollectionPage/getQuickEditPage.js +37 -23
  171. package/dist/utils/CollectionPage/getQuickEditPage.test.js +26 -45
  172. package/dist/utils/CollectionPage/index.js +3 -1
  173. package/dist/utils/CollectionPage/mergeCollectionPages.js +31 -35
  174. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +20 -20
  175. package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
  176. package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
  177. package/dist/utils/CollectionPage/setCollectionPageData.js +16 -17
  178. package/dist/utils/CollectionPage/setCollectionPageData.test.js +38 -20
  179. package/dist/utils/Component/addShowWhen.js +4 -8
  180. package/dist/utils/Component/addShowWhen.test.js +37 -37
  181. package/dist/utils/Component/applyToComponentTree.js +18 -18
  182. package/dist/utils/Component/applyToComponentTree.test.js +27 -32
  183. package/dist/utils/Component/cleanAttributes.js +10 -13
  184. package/dist/utils/Component/cleanAttributes.test.js +17 -18
  185. package/dist/utils/Component/elevateNestedComponents.js +5 -5
  186. package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
  187. package/dist/utils/Component/getComponent.js +88 -94
  188. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +18 -17
  189. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +46 -59
  190. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +39 -48
  191. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +23 -33
  192. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +20 -18
  193. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +17 -22
  194. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +20 -25
  195. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +10 -9
  196. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +17 -15
  197. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +9 -8
  198. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +17 -15
  199. package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +22 -26
  200. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
  201. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +17 -15
  202. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +17 -22
  203. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +57 -72
  204. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +17 -22
  205. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +17 -22
  206. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +31 -38
  207. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +20 -29
  208. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
  209. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +9 -8
  210. package/dist/utils/Component/getDefaultValue.js +6 -8
  211. package/dist/utils/Component/getDefaultValue.test.js +12 -12
  212. package/dist/utils/Component/getDefaultValueFromConfig.js +22 -21
  213. package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
  214. package/dist/utils/Component/index.js +1 -1
  215. package/dist/utils/Component/isEditable.js +2 -4
  216. package/dist/utils/Component/isEditable.test.js +14 -15
  217. package/dist/utils/Component/optionIsSelected.js +1 -1
  218. package/dist/utils/Component/optionIsSelected.test.js +9 -9
  219. package/dist/utils/Component/setupContainerComponentsPath.js +27 -29
  220. package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
  221. package/dist/utils/Component/showComponent.js +1 -1
  222. package/dist/utils/Component/showComponent.test.js +28 -28
  223. package/dist/utils/Component/wrapInFormGroup.js +2 -2
  224. package/dist/utils/Condition/index.js +1 -1
  225. package/dist/utils/Condition/meetsAllConditions.js +8 -8
  226. package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
  227. package/dist/utils/Condition/meetsCondition.js +28 -19
  228. package/dist/utils/Condition/meetsCondition.test.js +476 -376
  229. package/dist/utils/Condition/meetsOneCondition.js +5 -5
  230. package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
  231. package/dist/utils/Condition/setupConditions.js +13 -18
  232. package/dist/utils/Condition/setupConditions.test.js +7 -7
  233. package/dist/utils/Container/getEditableComponents.js +3 -5
  234. package/dist/utils/Container/getEditableComponents.test.js +43 -45
  235. package/dist/utils/Container/index.js +1 -1
  236. package/dist/utils/Container/setupNesting.js +16 -20
  237. package/dist/utils/Container/setupNesting.test.js +27 -30
  238. package/dist/utils/Container/showContainer.js +3 -7
  239. package/dist/utils/Container/showContainer.test.js +30 -30
  240. package/dist/utils/Data/applyFormula.js +38 -48
  241. package/dist/utils/Data/applyFormula.test.js +20 -20
  242. package/dist/utils/Data/getAutocompleteSource.js +18 -26
  243. package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
  244. package/dist/utils/Data/getDataPath.js +18 -28
  245. package/dist/utils/Data/getDataPath.test.js +12 -12
  246. package/dist/utils/Data/getOptions.js +29 -25
  247. package/dist/utils/Data/getOptions.test.js +93 -20
  248. package/dist/utils/Data/getSourceData.js +6 -19
  249. package/dist/utils/Data/getSourceData.test.js +84 -80
  250. package/dist/utils/Data/index.js +1 -1
  251. package/dist/utils/Data/nestInRefdataOptions.js +42 -0
  252. package/dist/utils/Data/nestInRefdataOptions.test.js +236 -0
  253. package/dist/utils/Data/refDataToOptions.js +10 -13
  254. package/dist/utils/Data/refDataToOptions.test.js +19 -19
  255. package/dist/utils/Data/setDataItem.js +7 -8
  256. package/dist/utils/Data/setDataItem.test.js +37 -37
  257. package/dist/utils/Data/setupFormData.js +13 -21
  258. package/dist/utils/Data/setupFormData.test.js +51 -50
  259. package/dist/utils/Data/setupRefDataUrlForComponent.js +20 -26
  260. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
  261. package/dist/utils/FormPage/applyConditionalProperties.js +5 -9
  262. package/dist/utils/FormPage/applyConditionalProperties.test.js +15 -18
  263. package/dist/utils/FormPage/getConditionalText.js +3 -3
  264. package/dist/utils/FormPage/getConditionalText.test.js +29 -29
  265. package/dist/utils/FormPage/getFormPage.js +15 -16
  266. package/dist/utils/FormPage/getFormPage.test.js +47 -46
  267. package/dist/utils/FormPage/getFormPages.js +7 -12
  268. package/dist/utils/FormPage/getFormPages.test.js +20 -23
  269. package/dist/utils/FormPage/getPageActions.js +9 -15
  270. package/dist/utils/FormPage/getPageActions.test.js +32 -32
  271. package/dist/utils/FormPage/getParagraphFromText.js +5 -7
  272. package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
  273. package/dist/utils/FormPage/index.js +2 -4
  274. package/dist/utils/FormPage/showFormPage.js +3 -7
  275. package/dist/utils/FormPage/showFormPage.test.js +32 -32
  276. package/dist/utils/FormPage/showFormPageCYA.js +1 -1
  277. package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
  278. package/dist/utils/FormPage/useComponent.js +21 -28
  279. package/dist/utils/FormPage/useComponent.test.js +77 -79
  280. package/dist/utils/Format/formatData.js +1 -1
  281. package/dist/utils/Format/formatData.test.js +18 -18
  282. package/dist/utils/Format/formatDataForComponent.js +5 -6
  283. package/dist/utils/Format/formatDataForComponent.test.js +50 -78
  284. package/dist/utils/Format/formatDataForForm.js +6 -8
  285. package/dist/utils/Format/formatDataForForm.test.js +13 -16
  286. package/dist/utils/Format/formatDataForPage.js +4 -5
  287. package/dist/utils/Format/formatDataForPage.test.js +20 -25
  288. package/dist/utils/Format/index.js +1 -1
  289. package/dist/utils/Hub/getFormHub.js +1 -1
  290. package/dist/utils/Hub/getFormHub.test.js +28 -31
  291. package/dist/utils/Hub/index.js +1 -1
  292. package/dist/utils/Meta/constants.js +2 -2
  293. package/dist/utils/Meta/documents/getDocuments.js +1 -1
  294. package/dist/utils/Meta/documents/getDocuments.test.js +24 -16
  295. package/dist/utils/Meta/documents/index.js +1 -1
  296. package/dist/utils/Meta/documents/setDocumentsForField.js +14 -16
  297. package/dist/utils/Meta/documents/setDocumentsForField.test.js +68 -34
  298. package/dist/utils/Meta/index.js +1 -1
  299. package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
  300. package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
  301. package/dist/utils/Operate/getFirstOf.js +5 -5
  302. package/dist/utils/Operate/getFirstOf.test.js +31 -31
  303. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
  304. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -52
  305. package/dist/utils/Operate/index.js +1 -1
  306. package/dist/utils/Operate/persistValueInFormData.js +3 -3
  307. package/dist/utils/Operate/persistValueInFormData.test.js +22 -20
  308. package/dist/utils/Operate/runPageOperations.js +7 -7
  309. package/dist/utils/Operate/runPageOperations.test.js +35 -36
  310. package/dist/utils/Operate/setValueInFormData.js +2 -2
  311. package/dist/utils/Operate/setValueInFormData.test.js +16 -16
  312. package/dist/utils/Operate/shouldRun.js +6 -6
  313. package/dist/utils/Operate/shouldRun.test.js +21 -27
  314. package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
  315. package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
  316. package/dist/utils/Validate/additional/index.js +6 -6
  317. package/dist/utils/Validate/additional/index.test.js +12 -12
  318. package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
  319. package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
  320. package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
  321. package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
  322. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +7 -11
  323. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -41
  324. package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
  325. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
  326. package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
  327. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
  328. package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
  329. package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
  330. package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
  331. package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
  332. package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
  333. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
  334. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
  335. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
  336. package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
  337. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
  338. package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +8 -4
  339. package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +64 -32
  340. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
  341. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +14 -16
  342. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
  343. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
  344. package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
  345. package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
  346. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
  347. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +28 -26
  348. package/dist/utils/Validate/additional/utils.js +9 -22
  349. package/dist/utils/Validate/index.js +1 -1
  350. package/dist/utils/Validate/validateCollection.js +19 -25
  351. package/dist/utils/Validate/validateCollection.test.js +74 -66
  352. package/dist/utils/Validate/validateComponent.js +17 -15
  353. package/dist/utils/Validate/validateComponent.test.js +167 -146
  354. package/dist/utils/Validate/validateContainer.js +16 -19
  355. package/dist/utils/Validate/validateContainer.test.js +84 -45
  356. package/dist/utils/Validate/validateDate.js +15 -21
  357. package/dist/utils/Validate/validateDate.test.js +31 -32
  358. package/dist/utils/Validate/validateEmail.js +6 -8
  359. package/dist/utils/Validate/validateEmail.test.js +25 -25
  360. package/dist/utils/Validate/validateMultifile.js +5 -7
  361. package/dist/utils/Validate/validateMultifile.test.js +17 -18
  362. package/dist/utils/Validate/validatePage.js +24 -18
  363. package/dist/utils/Validate/validatePage.test.js +263 -182
  364. package/dist/utils/Validate/validateRegex.js +3 -5
  365. package/dist/utils/Validate/validateRegex.test.js +14 -14
  366. package/dist/utils/Validate/validateRequired.js +4 -6
  367. package/dist/utils/Validate/validateRequired.test.js +18 -18
  368. package/dist/utils/Validate/validateTextArea.js +4 -6
  369. package/dist/utils/Validate/validateTextArea.test.js +20 -20
  370. package/dist/utils/Validate/validateTime.js +11 -18
  371. package/dist/utils/Validate/validateTime.test.js +16 -16
  372. package/dist/utils/index.js +7 -9
  373. package/package.json +5 -5
  374. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-data.json +0 -4
  375. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-form.json +0 -61
  376. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collection-data-removed.json +0 -4
  377. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collections.json +0 -8
  378. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components-removed.json +0 -3
  379. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components.json +0 -5
  380. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-entire-collection-removed.json +0 -3
  381. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-component-removed.json +0 -10
  382. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-components.json +0 -11
  383. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-for-nested-components.json +0 -96
  384. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections-delete-entire.json +0 -47
  385. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections.json +0 -46
  386. package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-components.json +0 -48
  387. package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +0 -175
  388. package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +0 -113
  389. package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +0 -20
  390. package/dist/components/FormRenderer/helpers/deleteNodeByPath.test.js +0 -56
@@ -4,32 +4,30 @@ var _models = require("../../models");
4
4
  var _setupTests = require("../../setupTests");
5
5
  var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
6
6
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
- 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; }
9
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
10
- 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); } // Local imports
11
- describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
12
- var OUTER_ID = 'a';
13
- var INNER_ID = 'b';
14
- it('should get an appropriate row for a container with a single readonly text component', function () {
15
- var FORM_DATA = {
7
+ // Local imports
8
+
9
+ describe('utils.CheckYourAnswers.getCYARowsForContainer', () => {
10
+ const OUTER_ID = 'a';
11
+ const INNER_ID = 'b';
12
+ it('should get an appropriate row for a container with a single readonly text component', () => {
13
+ const FORM_DATA = {
16
14
  container: {
17
15
  a: 'Bravo'
18
16
  }
19
17
  };
20
- var PAGE = {
18
+ const PAGE = {
21
19
  id: 'page',
22
20
  formData: FORM_DATA,
23
21
  cya_link: {}
24
22
  };
25
- var COMPONENT = {
23
+ const COMPONENT = {
26
24
  type: 'text',
27
25
  readonly: true,
28
26
  id: 'a',
29
27
  fieldId: 'a',
30
28
  label: 'Alpha'
31
29
  };
32
- var CONTAINER = {
30
+ const CONTAINER = {
33
31
  id: 'container',
34
32
  fieldId: 'container',
35
33
  type: _models.ComponentTypes.CONTAINER,
@@ -37,10 +35,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
37
35
  value: FORM_DATA.container,
38
36
  formData: FORM_DATA
39
37
  };
40
- var ON_ACTION = function ON_ACTION() {};
41
- var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
38
+ const ON_ACTION = () => {};
39
+ const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
42
40
  expect(ROWS.length).toEqual(1);
43
- ROWS.forEach(function (row, index) {
41
+ ROWS.forEach((row, index) => {
44
42
  (0, _setupTests.expectObjectLike)(row, {
45
43
  pageId: PAGE.id,
46
44
  fieldId: CONTAINER.components[index].fieldId,
@@ -51,31 +49,31 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
51
49
  });
52
50
  });
53
51
  });
54
- it('should get appropriate rows for a container with two editable text components', function () {
55
- var FORM_DATA = {
52
+ it('should get appropriate rows for a container with two editable text components', () => {
53
+ const FORM_DATA = {
56
54
  container: {
57
55
  a: 'Alpha Charlie',
58
56
  b: 'Bravo Charlie'
59
57
  }
60
58
  };
61
- var PAGE = {
59
+ const PAGE = {
62
60
  id: 'page',
63
61
  formData: FORM_DATA,
64
62
  cya_link: {}
65
63
  };
66
- var COMPONENT_A = {
64
+ const COMPONENT_A = {
67
65
  type: 'text',
68
66
  id: 'a',
69
67
  fieldId: 'a',
70
68
  label: 'Alpha'
71
69
  };
72
- var COMPONENT_B = {
70
+ const COMPONENT_B = {
73
71
  type: 'text',
74
72
  id: 'b',
75
73
  fieldId: 'b',
76
74
  label: 'Bravo'
77
75
  };
78
- var CONTAINER = {
76
+ const CONTAINER = {
79
77
  id: 'container',
80
78
  fieldId: 'container',
81
79
  type: _models.ComponentTypes.CONTAINER,
@@ -83,10 +81,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
83
81
  value: FORM_DATA.container,
84
82
  formData: FORM_DATA
85
83
  };
86
- var ON_ACTION = function ON_ACTION() {};
87
- var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
84
+ const ON_ACTION = () => {};
85
+ const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
88
86
  expect(ROWS.length).toEqual(2);
89
- ROWS.forEach(function (row, index) {
87
+ ROWS.forEach((row, index) => {
90
88
  (0, _setupTests.expectObjectLike)(row, {
91
89
  pageId: PAGE.id,
92
90
  fieldId: CONTAINER.components[index].fieldId,
@@ -99,35 +97,35 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
99
97
  });
100
98
  });
101
99
  });
102
- it("should filter out any components that shouldn't be shown", function () {
103
- var FORM_DATA = {
100
+ it("should filter out any components that shouldn't be shown", () => {
101
+ const FORM_DATA = {
104
102
  container: {
105
103
  a: 'Alpha Charlie',
106
104
  b: 'Bravo Charlie'
107
105
  }
108
106
  };
109
- var PAGE = {
107
+ const PAGE = {
110
108
  id: 'page',
111
109
  formData: FORM_DATA,
112
110
  cya_link: {}
113
111
  };
114
- var COMPONENT_A = {
112
+ const COMPONENT_A = {
115
113
  type: 'text',
116
114
  id: 'a',
117
115
  fieldId: 'a',
118
116
  label: 'Alpha'
119
117
  };
120
- var COMPONENT_B = {
118
+ const COMPONENT_B = {
121
119
  type: 'text',
122
120
  id: 'b',
123
121
  fieldId: 'b',
124
122
  label: 'Bravo'
125
123
  };
126
- var COMPONENT_C = {
124
+ const COMPONENT_C = {
127
125
  type: 'heading',
128
126
  content: 'Heading component'
129
127
  };
130
- var CONTAINER = {
128
+ const CONTAINER = {
131
129
  id: 'container',
132
130
  fieldId: 'container',
133
131
  type: _models.ComponentTypes.CONTAINER,
@@ -135,10 +133,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
135
133
  value: FORM_DATA.container,
136
134
  formData: FORM_DATA
137
135
  };
138
- var ON_ACTION = function ON_ACTION() {};
139
- var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
136
+ const ON_ACTION = () => {};
137
+ const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
140
138
  expect(ROWS.length).toEqual(2);
141
- ROWS.forEach(function (row, index) {
139
+ ROWS.forEach((row, index) => {
142
140
  (0, _setupTests.expectObjectLike)(row, {
143
141
  pageId: PAGE.id,
144
142
  fieldId: CONTAINER.components[index].fieldId,
@@ -151,27 +149,27 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
151
149
  });
152
150
  });
153
151
  });
154
- it('should get an appropriate row for a container with a single readonly text component inside a nested container', function () {
155
- var FORM_DATA = {
152
+ it('should get an appropriate row for a container with a single readonly text component inside a nested container', () => {
153
+ const FORM_DATA = {
156
154
  container: {
157
155
  nested: {
158
156
  a: 'Bravo'
159
157
  }
160
158
  }
161
159
  };
162
- var PAGE = {
160
+ const PAGE = {
163
161
  id: 'page',
164
162
  formData: FORM_DATA,
165
163
  cya_link: {}
166
164
  };
167
- var COMPONENT = {
165
+ const COMPONENT = {
168
166
  type: 'text',
169
167
  readonly: true,
170
168
  id: 'a',
171
169
  fieldId: 'a',
172
170
  label: 'Alpha'
173
171
  };
174
- var NESTED_CONTAINER = {
172
+ const NESTED_CONTAINER = {
175
173
  id: 'nested',
176
174
  fieldId: 'nested',
177
175
  type: _models.ComponentTypes.CONTAINER,
@@ -179,7 +177,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
179
177
  value: FORM_DATA.container.nested,
180
178
  formData: FORM_DATA
181
179
  };
182
- var CONTAINER = {
180
+ const CONTAINER = {
183
181
  id: 'container',
184
182
  fieldId: 'container',
185
183
  type: _models.ComponentTypes.CONTAINER,
@@ -187,10 +185,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
187
185
  value: FORM_DATA.container,
188
186
  formData: FORM_DATA
189
187
  };
190
- var ON_ACTION = function ON_ACTION() {};
191
- var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
188
+ const ON_ACTION = () => {};
189
+ const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
192
190
  expect(ROWS.length).toEqual(1);
193
- ROWS.forEach(function (row, index) {
191
+ ROWS.forEach((row, index) => {
194
192
  (0, _setupTests.expectObjectLike)(row, {
195
193
  pageId: PAGE.id,
196
194
  fieldId: NESTED_CONTAINER.components[index].fieldId,
@@ -201,36 +199,36 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
201
199
  });
202
200
  });
203
201
  });
204
- it('should get an appropriate row for a container with a single readonly text component inside a nested container but no formData', function () {
205
- var FORM_DATA = undefined;
206
- var PAGE = {
202
+ it('should get an appropriate row for a container with a single readonly text component inside a nested container but no formData', () => {
203
+ const FORM_DATA = undefined;
204
+ const PAGE = {
207
205
  id: 'page',
208
206
  formData: FORM_DATA,
209
207
  cya_link: {}
210
208
  };
211
- var COMPONENT = {
209
+ const COMPONENT = {
212
210
  type: 'text',
213
211
  readonly: true,
214
212
  id: 'a',
215
213
  fieldId: 'a',
216
214
  label: 'Alpha'
217
215
  };
218
- var NESTED_CONTAINER = {
216
+ const NESTED_CONTAINER = {
219
217
  id: 'nested',
220
218
  fieldId: 'nested',
221
219
  type: _models.ComponentTypes.CONTAINER,
222
220
  components: [COMPONENT]
223
221
  };
224
- var CONTAINER = {
222
+ const CONTAINER = {
225
223
  id: 'container',
226
224
  fieldId: 'container',
227
225
  type: _models.ComponentTypes.CONTAINER,
228
226
  components: [NESTED_CONTAINER]
229
227
  };
230
- var ON_ACTION = function ON_ACTION() {};
231
- var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, undefined, ON_ACTION);
228
+ const ON_ACTION = () => {};
229
+ const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, undefined, ON_ACTION);
232
230
  expect(ROWS.length).toEqual(1);
233
- ROWS.forEach(function (row, index) {
231
+ ROWS.forEach((row, index) => {
234
232
  (0, _setupTests.expectObjectLike)(row, {
235
233
  pageId: PAGE.id,
236
234
  fieldId: NESTED_CONTAINER.components[index].fieldId,
@@ -241,15 +239,21 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
241
239
  });
242
240
  });
243
241
  });
244
- it('should get an appropriate row for a collection with a single text component inside a container', function () {
245
- var FORM_DATA = _defineProperty({}, OUTER_ID, [_defineProperty({}, INNER_ID, 'Bravo'), _defineProperty({}, INNER_ID, 'Charlie')]);
246
- var PAGE = {
242
+ it('should get an appropriate row for a collection with a single text component inside a container', () => {
243
+ const FORM_DATA = {
244
+ [OUTER_ID]: [{
245
+ [INNER_ID]: 'Bravo'
246
+ }, {
247
+ [INNER_ID]: 'Charlie'
248
+ }]
249
+ };
250
+ const PAGE = {
247
251
  id: 'page',
248
252
  formData: FORM_DATA,
249
253
  cya_link: {},
250
254
  collection: 'collectionName'
251
255
  };
252
- var COLLECTION_COMPONENT = {
256
+ const COLLECTION_COMPONENT = {
253
257
  type: 'collection',
254
258
  id: OUTER_ID,
255
259
  fieldId: OUTER_ID,
@@ -261,7 +265,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
261
265
  type: 'text'
262
266
  }]
263
267
  };
264
- var CONTAINER = {
268
+ const CONTAINER = {
265
269
  id: 'container',
266
270
  fieldId: 'container',
267
271
  type: _models.ComponentTypes.CONTAINER,
@@ -269,9 +273,9 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
269
273
  value: FORM_DATA.container,
270
274
  formData: FORM_DATA
271
275
  };
272
- var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA, function () {});
276
+ const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA, () => {});
273
277
  expect(ROWS.length).toEqual(4);
274
- var checkTitleRow = function checkTitleRow(index, row) {
278
+ const checkTitleRow = (index, row) => {
275
279
  expect(row).toEqual({
276
280
  pageId: PAGE.id,
277
281
  fieldId: CONTAINER.components[0].fieldId,
@@ -281,7 +285,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
281
285
  type: 'title'
282
286
  });
283
287
  };
284
- var checkValueRow = function checkValueRow(index, row, value) {
288
+ const checkValueRow = (index, row, value) => {
285
289
  (0, _setupTests.expectObjectLike)(row, {
286
290
  pageId: PAGE.id,
287
291
  fieldId: INNER_ID,
@@ -294,7 +298,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
294
298
  label: INNER_ID,
295
299
  type: 'text'
296
300
  },
297
- value: value,
301
+ value,
298
302
  full_path: "".concat(OUTER_ID, "[").concat(index, "].").concat(INNER_ID)
299
303
  });
300
304
  };
@@ -303,23 +307,27 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
303
307
  checkTitleRow(1, ROWS[2]);
304
308
  checkValueRow(1, ROWS[3], 'Charlie');
305
309
  });
306
- it('should conditionally show an appropriate row for a single text component inside a container belonging to a partial-collection', function () {
307
- var FORM_DATA = {
310
+ it('should conditionally show an appropriate row for a single text component inside a container belonging to a partial-collection', () => {
311
+ const FORM_DATA = {
308
312
  collectionName: [{
309
- container: _defineProperty({}, INNER_ID, 'Bravo'),
313
+ container: {
314
+ [INNER_ID]: 'Bravo'
315
+ },
310
316
  other_data: true
311
317
  }, {
312
- container: _defineProperty({}, INNER_ID, 'Charlie'),
318
+ container: {
319
+ [INNER_ID]: 'Charlie'
320
+ },
313
321
  other_data: false
314
322
  }]
315
323
  };
316
- var PAGE = {
324
+ const PAGE = {
317
325
  id: 'page',
318
326
  formData: FORM_DATA,
319
327
  cya_link: {},
320
328
  collection: 'collectionName'
321
329
  };
322
- var CONTAINER = {
330
+ const CONTAINER = {
323
331
  id: 'container',
324
332
  fieldId: 'container',
325
333
  type: _models.ComponentTypes.CONTAINER,
@@ -336,27 +344,27 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
336
344
  value: true
337
345
  }
338
346
  };
339
- expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[0], function () {}).length).toEqual(1);
340
- expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[1], function () {})).toBeFalsy();
347
+ expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[0], () => {}).length).toEqual(1);
348
+ expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[1], () => {})).toBeFalsy();
341
349
  });
342
- it('should get the appropriate number for rows components with nested components inside a container', function () {
343
- var FORM_DATA = {
350
+ it('should get the appropriate number for rows components with nested components inside a container', () => {
351
+ const FORM_DATA = {
344
352
  container: {
345
353
  a: 'B',
346
354
  nested: 'Bravo'
347
355
  }
348
356
  };
349
- var PAGE = {
357
+ const PAGE = {
350
358
  id: 'page',
351
359
  formData: FORM_DATA,
352
360
  cya_link: {}
353
361
  };
354
- var NESTED_COMPONENT = {
362
+ const NESTED_COMPONENT = {
355
363
  id: 'nested',
356
364
  fieldId: 'nested',
357
365
  type: _models.ComponentTypes.TEXT
358
366
  };
359
- var COMPONENT = {
367
+ const COMPONENT = {
360
368
  type: 'radios',
361
369
  id: 'a',
362
370
  fieldId: 'a',
@@ -372,7 +380,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
372
380
  }]
373
381
  }
374
382
  };
375
- var CONTAINER = {
383
+ const CONTAINER = {
376
384
  id: 'container',
377
385
  fieldId: 'container',
378
386
  type: _models.ComponentTypes.CONTAINER,
@@ -380,35 +388,35 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
380
388
  value: FORM_DATA.container,
381
389
  formData: FORM_DATA
382
390
  };
383
- var ON_ACTION = function ON_ACTION() {};
384
- var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
391
+ const ON_ACTION = () => {};
392
+ const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
385
393
  expect(ROWS.length).toEqual(2);
386
394
  });
387
- it('should ignore the result of the override function if it returns nullish', function () {
388
- var FORM_DATA = {
395
+ it('should ignore the result of the override function if it returns nullish', () => {
396
+ const FORM_DATA = {
389
397
  container: {
390
398
  a: 'Alpha Charlie',
391
399
  b: 'Bravo Charlie'
392
400
  }
393
401
  };
394
- var PAGE = {
402
+ const PAGE = {
395
403
  id: 'page',
396
404
  formData: FORM_DATA,
397
405
  cya_link: {}
398
406
  };
399
- var COMPONENT_A = {
407
+ const COMPONENT_A = {
400
408
  type: 'text',
401
409
  id: 'a',
402
410
  fieldId: 'a',
403
411
  label: 'Alpha'
404
412
  };
405
- var COMPONENT_B = {
413
+ const COMPONENT_B = {
406
414
  type: 'text',
407
415
  id: 'b',
408
416
  fieldId: 'b',
409
417
  label: 'Bravo'
410
418
  };
411
- var CONTAINER = {
419
+ const CONTAINER = {
412
420
  id: 'container',
413
421
  fieldId: 'container',
414
422
  type: _models.ComponentTypes.CONTAINER,
@@ -416,12 +424,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
416
424
  value: FORM_DATA.container,
417
425
  formData: FORM_DATA
418
426
  };
419
- var ON_ACTION = function ON_ACTION() {};
420
- var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION, function () {
421
- return null;
422
- });
427
+ const ON_ACTION = () => {};
428
+ const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION, () => null);
423
429
  expect(ROWS.length).toEqual(2);
424
- ROWS.forEach(function (row, index) {
430
+ ROWS.forEach((row, index) => {
425
431
  (0, _setupTests.expectObjectLike)(row, {
426
432
  pageId: PAGE.id,
427
433
  fieldId: CONTAINER.components[index].fieldId,
@@ -434,31 +440,31 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
434
440
  });
435
441
  });
436
442
  });
437
- it('should use rows produced by the override function if provided', function () {
438
- var FORM_DATA = {
443
+ it('should use rows produced by the override function if provided', () => {
444
+ const FORM_DATA = {
439
445
  container: {
440
446
  a: 'Alpha Charlie',
441
447
  b: 'Bravo Charlie'
442
448
  }
443
449
  };
444
- var PAGE = {
450
+ const PAGE = {
445
451
  id: 'page',
446
452
  formData: FORM_DATA,
447
453
  cya_link: {}
448
454
  };
449
- var COMPONENT_A = {
455
+ const COMPONENT_A = {
450
456
  type: 'text',
451
457
  id: 'a',
452
458
  fieldId: 'a',
453
459
  label: 'Alpha'
454
460
  };
455
- var COMPONENT_B = {
461
+ const COMPONENT_B = {
456
462
  type: 'text',
457
463
  id: 'b',
458
464
  fieldId: 'b',
459
465
  label: 'Bravo'
460
466
  };
461
- var CONTAINER = {
467
+ const CONTAINER = {
462
468
  id: 'container',
463
469
  fieldId: 'container',
464
470
  type: _models.ComponentTypes.CONTAINER,
@@ -466,16 +472,16 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
466
472
  value: FORM_DATA.container,
467
473
  formData: FORM_DATA
468
474
  };
469
- var ON_ACTION = function ON_ACTION() {};
475
+ const ON_ACTION = () => {};
470
476
  // eslint-disable-next-line arrow-body-style
471
- var OVERRIDE = function OVERRIDE(page, comp) {
477
+ const OVERRIDE = (page, comp) => {
472
478
  // This will be called for each component in the container,
473
479
  // returning a custom row object.
474
480
  return {
475
481
  key: "CustomRowFor".concat(comp.label)
476
482
  };
477
483
  };
478
- var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION, OVERRIDE);
484
+ const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION, OVERRIDE);
479
485
  expect(ROWS.length).toEqual(2);
480
486
  expect(ROWS).toEqual([{
481
487
  key: 'CustomRowForAlpha'
@@ -9,7 +9,7 @@ var _models = require("../../models");
9
9
  var _FormPage = _interopRequireDefault(require("../FormPage"));
10
10
  var _getCYARow = _interopRequireDefault(require("./getCYARow"));
11
11
  var _getCYARowsForCollectionPage = _interopRequireDefault(require("./getCYARowsForCollectionPage"));
12
- var _getCYARowForGroup2 = _interopRequireDefault(require("./getCYARowForGroup"));
12
+ var _getCYARowForGroup = _interopRequireDefault(require("./getCYARowForGroup"));
13
13
  var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
14
14
  var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
15
15
  var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
@@ -25,19 +25,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
25
25
  *
26
26
  * @returns An array of configuration objects for Check your answers rows.
27
27
  */
28
- var getCYARowsForPage = function getCYARowsForPage(page, onAction) {
29
- var fnOverride = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
28
+ const getCYARowsForPage = function (page, onAction) {
29
+ let fnOverride = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
30
30
  if (_FormPage.default.showCYA(page, page.formData)) {
31
31
  var _page$groups;
32
32
  if (page.collection) {
33
33
  return (0, _getCYARowsForCollectionPage.default)(page, onAction, fnOverride, page.formData);
34
34
  }
35
- var allComponents = (0, _elevateNestedComponents.default)(page.components, page.formData);
36
- var rows = allComponents.filter(function (c) {
37
- return (0, _showComponentCYA.default)(c, page.formData);
38
- }).flatMap(function (component) {
35
+ const allComponents = (0, _elevateNestedComponents.default)(page.components, page.formData);
36
+ const rows = allComponents.filter(c => (0, _showComponentCYA.default)(c, page.formData)).flatMap(component => {
39
37
  if (typeof fnOverride === 'function') {
40
- var overrideRows = fnOverride(page, component, onAction);
38
+ const overrideRows = fnOverride(page, component, onAction);
41
39
  if (overrideRows) {
42
40
  return overrideRows;
43
41
  }
@@ -52,22 +50,19 @@ var getCYARowsForPage = function getCYARowsForPage(page, onAction) {
52
50
  }
53
51
  });
54
52
  if (((_page$groups = page.groups) === null || _page$groups === void 0 ? void 0 : _page$groups.length) > 0) {
55
- page.groups.forEach(function (group) {
56
- var _getCYARowForGroup = (0, _getCYARowForGroup2.default)(page, group, rows, onAction),
57
- row = _getCYARowForGroup.row,
58
- insertAt = _getCYARowForGroup.insertAt;
53
+ page.groups.forEach(group => {
54
+ const {
55
+ row,
56
+ insertAt
57
+ } = (0, _getCYARowForGroup.default)(page, group, rows, onAction);
59
58
  if (insertAt > -1) {
60
59
  rows.splice(insertAt, 0, row);
61
60
  } else {
62
61
  rows.push(row);
63
62
  }
64
63
  });
65
- var allReplacedIds = page.groups.flatMap(function (g) {
66
- return g.components;
67
- });
68
- return rows.filter(function (r) {
69
- return !allReplacedIds.includes(r.id);
70
- });
64
+ const allReplacedIds = page.groups.flatMap(g => g.components);
65
+ return rows.filter(r => !allReplacedIds.includes(r.id));
71
66
  }
72
67
  return rows;
73
68
  }