@ukhomeoffice/cop-react-form-renderer 6.14.0 → 6.14.1

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 (385) hide show
  1. package/README.md +5 -0
  2. package/dist/components/CheckYourAnswers/Answer.js +12 -11
  3. package/dist/components/CheckYourAnswers/Answer.test.js +132 -181
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +98 -133
  5. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +544 -939
  6. package/dist/components/CheckYourAnswers/index.js +1 -1
  7. package/dist/components/CollectionPage/CollectionPage.js +62 -60
  8. package/dist/components/CollectionPage/CollectionPage.test.js +315 -365
  9. package/dist/components/CollectionPage/index.js +1 -1
  10. package/dist/components/CollectionSummary/BannerStrip.js +14 -14
  11. package/dist/components/CollectionSummary/BannerStrip.test.js +79 -74
  12. package/dist/components/CollectionSummary/CollectionSummary.js +75 -97
  13. package/dist/components/CollectionSummary/CollectionSummary.test.js +182 -166
  14. package/dist/components/CollectionSummary/Confirmation.js +15 -13
  15. package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
  16. package/dist/components/CollectionSummary/RenderListView.js +34 -47
  17. package/dist/components/CollectionSummary/RenderListView.test.js +113 -111
  18. package/dist/components/CollectionSummary/SummaryCard.js +101 -133
  19. package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
  20. package/dist/components/CollectionSummary/SummaryCardButtons.js +25 -30
  21. package/dist/components/CollectionSummary/SummaryCardButtons.test.js +30 -28
  22. package/dist/components/CollectionSummary/SummaryCardDetails.js +59 -76
  23. package/dist/components/CollectionSummary/SummaryCardDetails.test.js +170 -180
  24. package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
  25. package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +63 -75
  26. package/dist/components/CollectionSummary/index.js +1 -1
  27. package/dist/components/FormComponent/Collection.js +63 -100
  28. package/dist/components/FormComponent/Collection.test.js +907 -1080
  29. package/dist/components/FormComponent/Container.js +35 -29
  30. package/dist/components/FormComponent/Container.test.js +378 -409
  31. package/dist/components/FormComponent/FormComponent.js +59 -63
  32. package/dist/components/FormComponent/FormComponent.test.js +354 -415
  33. package/dist/components/FormComponent/helpers/addLabel.js +4 -7
  34. package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
  35. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
  36. package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
  37. package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
  38. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
  39. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
  40. package/dist/components/FormComponent/helpers/index.js +5 -5
  41. package/dist/components/FormComponent/index.js +1 -1
  42. package/dist/components/FormPage/FormPage.js +70 -93
  43. package/dist/components/FormPage/FormPage.test.js +150 -202
  44. package/dist/components/FormPage/index.js +1 -1
  45. package/dist/components/FormRenderer/FormRenderer.js +131 -173
  46. package/dist/components/FormRenderer/FormRenderer.test.js +732 -1114
  47. package/dist/components/FormRenderer/handlers/cyaAction.js +3 -3
  48. package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
  49. package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
  50. package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
  51. package/dist/components/FormRenderer/handlers/index.js +2 -2
  52. package/dist/components/FormRenderer/handlers/navigate.js +4 -4
  53. package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
  54. package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
  55. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +16 -16
  56. package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
  57. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
  58. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -25
  59. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
  60. package/dist/components/FormRenderer/helpers/getCYA.js +4 -6
  61. package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
  62. package/dist/components/FormRenderer/helpers/getFormState.js +6 -8
  63. package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
  64. package/dist/components/FormRenderer/helpers/getNextPageId.js +14 -25
  65. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
  66. package/dist/components/FormRenderer/helpers/getPage.js +2 -4
  67. package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
  68. package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
  69. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
  70. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +6 -6
  71. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +104 -98
  72. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +44 -51
  73. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +68 -74
  74. package/dist/components/FormRenderer/helpers/index.js +2 -2
  75. package/dist/components/FormRenderer/index.js +1 -1
  76. package/dist/components/FormRenderer/onCYAAction.js +43 -44
  77. package/dist/components/FormRenderer/onCYAAction.test.js +126 -133
  78. package/dist/components/FormRenderer/onPageAction.js +26 -35
  79. package/dist/components/FormRenderer/onPageAction.test.js +177 -186
  80. package/dist/components/FormRenderer/onTaskAction.js +11 -12
  81. package/dist/components/FormRenderer/onTaskAction.test.js +63 -68
  82. package/dist/components/PageActions/ActionButton.js +14 -14
  83. package/dist/components/PageActions/ActionButton.test.js +57 -79
  84. package/dist/components/PageActions/PageActions.js +11 -11
  85. package/dist/components/PageActions/PageActions.test.js +87 -116
  86. package/dist/components/PageActions/index.js +1 -1
  87. package/dist/components/SummaryList/GroupAction.js +10 -18
  88. package/dist/components/SummaryList/GroupAction.test.js +38 -34
  89. package/dist/components/SummaryList/RowAction.js +12 -17
  90. package/dist/components/SummaryList/RowAction.test.js +38 -34
  91. package/dist/components/SummaryList/SummaryList.js +23 -25
  92. package/dist/components/SummaryList/SummaryList.test.js +162 -189
  93. package/dist/components/SummaryList/SummaryListHeadingRow.js +7 -5
  94. package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
  95. package/dist/components/SummaryList/SummaryListRow.js +7 -5
  96. package/dist/components/SummaryList/SummaryListTitleRow.js +6 -4
  97. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
  98. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +23 -23
  99. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
  100. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +23 -23
  101. package/dist/components/SummaryList/helpers/index.js +2 -2
  102. package/dist/components/SummaryList/index.js +1 -1
  103. package/dist/components/TaskList/Task.js +20 -30
  104. package/dist/components/TaskList/Task.test.js +84 -77
  105. package/dist/components/TaskList/TaskList.js +56 -79
  106. package/dist/components/TaskList/TaskList.test.js +149 -149
  107. package/dist/components/TaskList/TaskState.js +8 -6
  108. package/dist/components/TaskList/TaskState.test.js +53 -46
  109. package/dist/components/TaskList/index.js +1 -1
  110. package/dist/components/index.js +8 -8
  111. package/dist/context/HooksContext/HooksContext.js +56 -79
  112. package/dist/context/HooksContext/HooksContext.test.js +27 -36
  113. package/dist/context/HooksContext/index.js +3 -4
  114. package/dist/context/ValidationContext/ValidationContext.js +44 -95
  115. package/dist/context/ValidationContext/ValidationContext.test.js +57 -69
  116. package/dist/context/ValidationContext/index.js +3 -4
  117. package/dist/context/index.js +3 -3
  118. package/dist/hooks/index.js +10 -11
  119. package/dist/hooks/useAxios.js +15 -41
  120. package/dist/hooks/useGetRequest.js +62 -98
  121. package/dist/hooks/useHooks.js +1 -3
  122. package/dist/hooks/useRefData.js +25 -37
  123. package/dist/hooks/useValidation.js +1 -3
  124. package/dist/index.js +14 -15
  125. package/dist/models/CollectionLabels.js +1 -1
  126. package/dist/models/ComponentTypes.js +25 -25
  127. package/dist/models/EventTypes.js +4 -4
  128. package/dist/models/FormPages.js +4 -4
  129. package/dist/models/FormTypes.js +8 -8
  130. package/dist/models/HubFormats.js +3 -3
  131. package/dist/models/PageAction.js +44 -38
  132. package/dist/models/TaskStates.js +29 -28
  133. package/dist/models/index.js +10 -10
  134. package/dist/setupTests.js +30 -31
  135. package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
  136. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
  137. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +12 -21
  138. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +32 -33
  139. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +15 -28
  140. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +41 -42
  141. package/dist/utils/CheckYourAnswers/getCYARow.js +7 -7
  142. package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
  143. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -21
  144. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
  145. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +27 -34
  146. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +48 -52
  147. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +76 -93
  148. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
  149. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -16
  150. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
  151. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +14 -19
  152. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +69 -73
  153. package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +7 -8
  154. package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +15 -16
  155. package/dist/utils/CheckYourAnswers/index.js +2 -2
  156. package/dist/utils/CheckYourAnswers/showComponentCYA.js +5 -5
  157. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
  158. package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
  159. package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
  160. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
  161. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -19
  162. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -20
  163. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +48 -39
  164. package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
  165. package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
  166. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
  167. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
  168. package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
  169. package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
  170. package/dist/utils/CollectionPage/getErrorsForCollection.js +20 -21
  171. package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
  172. package/dist/utils/CollectionPage/getQuickEditPage.js +22 -23
  173. package/dist/utils/CollectionPage/getQuickEditPage.test.js +17 -18
  174. package/dist/utils/CollectionPage/index.js +2 -2
  175. package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -35
  176. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +18 -18
  177. package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
  178. package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
  179. package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
  180. package/dist/utils/CollectionPage/setCollectionPageData.test.js +25 -25
  181. package/dist/utils/Component/addShowWhen.js +5 -6
  182. package/dist/utils/Component/addShowWhen.test.js +38 -38
  183. package/dist/utils/Component/applyToComponentTree.js +12 -15
  184. package/dist/utils/Component/applyToComponentTree.test.js +28 -31
  185. package/dist/utils/Component/cleanAttributes.js +12 -11
  186. package/dist/utils/Component/cleanAttributes.test.js +17 -18
  187. package/dist/utils/Component/elevateNestedComponents.js +6 -6
  188. package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
  189. package/dist/utils/Component/getComponent.js +79 -85
  190. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
  191. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +41 -58
  192. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
  193. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +24 -34
  194. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
  195. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +18 -23
  196. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +21 -26
  197. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +11 -10
  198. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
  199. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
  200. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
  201. package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +23 -27
  202. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +201 -226
  203. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
  204. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +18 -23
  205. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +58 -73
  206. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +18 -23
  207. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +18 -23
  208. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +32 -39
  209. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +21 -30
  210. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
  211. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
  212. package/dist/utils/Component/getDefaultValue.js +7 -9
  213. package/dist/utils/Component/getDefaultValue.test.js +13 -13
  214. package/dist/utils/Component/getDefaultValueFromConfig.js +16 -20
  215. package/dist/utils/Component/getDefaultValueFromConfig.test.js +32 -32
  216. package/dist/utils/Component/index.js +2 -2
  217. package/dist/utils/Component/isEditable.js +2 -4
  218. package/dist/utils/Component/isEditable.test.js +14 -15
  219. package/dist/utils/Component/optionIsSelected.js +2 -4
  220. package/dist/utils/Component/optionIsSelected.test.js +12 -12
  221. package/dist/utils/Component/setupContainerComponentsPath.js +23 -28
  222. package/dist/utils/Component/setupContainerComponentsPath.test.js +12 -12
  223. package/dist/utils/Component/showComponent.js +2 -2
  224. package/dist/utils/Component/showComponent.test.js +29 -29
  225. package/dist/utils/Component/wrapInFormGroup.js +4 -4
  226. package/dist/utils/Condition/index.js +2 -2
  227. package/dist/utils/Condition/meetsAllConditions.js +9 -9
  228. package/dist/utils/Condition/meetsAllConditions.test.js +21 -21
  229. package/dist/utils/Condition/meetsCondition.js +17 -26
  230. package/dist/utils/Condition/meetsCondition.test.js +403 -403
  231. package/dist/utils/Condition/meetsOneCondition.js +6 -6
  232. package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
  233. package/dist/utils/Condition/setupConditions.js +12 -15
  234. package/dist/utils/Condition/setupConditions.test.js +8 -8
  235. package/dist/utils/Container/getEditableComponents.js +4 -6
  236. package/dist/utils/Container/getEditableComponents.test.js +44 -46
  237. package/dist/utils/Container/index.js +2 -2
  238. package/dist/utils/Container/setupNesting.js +14 -15
  239. package/dist/utils/Container/setupNesting.test.js +20 -23
  240. package/dist/utils/Container/showContainer.js +4 -8
  241. package/dist/utils/Container/showContainer.test.js +31 -31
  242. package/dist/utils/Data/applyFormula.js +30 -44
  243. package/dist/utils/Data/applyFormula.test.js +21 -21
  244. package/dist/utils/Data/deleteValues.js +4 -8
  245. package/dist/utils/Data/deleteValues.test.js +11 -11
  246. package/dist/utils/Data/getAutocompleteSource.js +19 -27
  247. package/dist/utils/Data/getAutocompleteSource.test.js +76 -81
  248. package/dist/utils/Data/getDataPath.js +18 -28
  249. package/dist/utils/Data/getDataPath.test.js +13 -13
  250. package/dist/utils/Data/getOptions.js +35 -42
  251. package/dist/utils/Data/getOptions.test.js +37 -38
  252. package/dist/utils/Data/getSourceData.js +6 -19
  253. package/dist/utils/Data/getSourceData.test.js +85 -81
  254. package/dist/utils/Data/index.js +2 -2
  255. package/dist/utils/Data/nestInRefdataOptions.js +9 -12
  256. package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
  257. package/dist/utils/Data/refDataToOptions.js +9 -10
  258. package/dist/utils/Data/refDataToOptions.test.js +20 -20
  259. package/dist/utils/Data/setDataItem.js +7 -8
  260. package/dist/utils/Data/setDataItem.test.js +38 -38
  261. package/dist/utils/Data/setupFormData.js +13 -20
  262. package/dist/utils/Data/setupFormData.test.js +48 -47
  263. package/dist/utils/Data/setupRefDataUrlForComponent.js +11 -20
  264. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +25 -25
  265. package/dist/utils/FormPage/applyConditionalProperties.js +7 -8
  266. package/dist/utils/FormPage/applyConditionalProperties.test.js +14 -15
  267. package/dist/utils/FormPage/getConditionalText.js +4 -4
  268. package/dist/utils/FormPage/getConditionalText.test.js +30 -30
  269. package/dist/utils/FormPage/getFormPage.js +12 -15
  270. package/dist/utils/FormPage/getFormPage.test.js +23 -24
  271. package/dist/utils/FormPage/getFormPages.js +8 -11
  272. package/dist/utils/FormPage/getFormPages.test.js +15 -16
  273. package/dist/utils/FormPage/getPageActions.js +10 -13
  274. package/dist/utils/FormPage/getPageActions.test.js +33 -33
  275. package/dist/utils/FormPage/getParagraphFromText.js +5 -7
  276. package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
  277. package/dist/utils/FormPage/index.js +3 -5
  278. package/dist/utils/FormPage/showFormPage.js +4 -8
  279. package/dist/utils/FormPage/showFormPage.test.js +33 -33
  280. package/dist/utils/FormPage/showFormPageCYA.js +2 -2
  281. package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
  282. package/dist/utils/FormPage/useComponent.js +15 -23
  283. package/dist/utils/FormPage/useComponent.test.js +49 -50
  284. package/dist/utils/Format/formatData.js +1 -1
  285. package/dist/utils/Format/formatData.test.js +19 -19
  286. package/dist/utils/Format/formatDataForComponent.js +6 -7
  287. package/dist/utils/Format/formatDataForComponent.test.js +50 -78
  288. package/dist/utils/Format/formatDataForForm.js +5 -6
  289. package/dist/utils/Format/formatDataForForm.test.js +14 -17
  290. package/dist/utils/Format/formatDataForPage.js +4 -5
  291. package/dist/utils/Format/formatDataForPage.test.js +20 -25
  292. package/dist/utils/Format/index.js +2 -2
  293. package/dist/utils/Hub/getFormHub.js +2 -2
  294. package/dist/utils/Hub/getFormHub.test.js +23 -24
  295. package/dist/utils/Hub/index.js +2 -2
  296. package/dist/utils/Meta/constants.js +2 -2
  297. package/dist/utils/Meta/documents/getDocuments.js +1 -1
  298. package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
  299. package/dist/utils/Meta/documents/index.js +2 -2
  300. package/dist/utils/Meta/documents/setDocumentsForField.js +12 -13
  301. package/dist/utils/Meta/documents/setDocumentsForField.test.js +70 -33
  302. package/dist/utils/Meta/index.js +2 -2
  303. package/dist/utils/Operate/checkValueIsTruthy.js +3 -3
  304. package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
  305. package/dist/utils/Operate/deleteValueInFormData.js +2 -2
  306. package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
  307. package/dist/utils/Operate/getFirstOf.js +6 -6
  308. package/dist/utils/Operate/getFirstOf.test.js +32 -32
  309. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +11 -11
  310. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
  311. package/dist/utils/Operate/getLength.js +9 -9
  312. package/dist/utils/Operate/getLength.test.js +19 -19
  313. package/dist/utils/Operate/index.js +2 -2
  314. package/dist/utils/Operate/persistValueInFormData.js +4 -4
  315. package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
  316. package/dist/utils/Operate/runPageOperations.js +8 -8
  317. package/dist/utils/Operate/runPageOperations.test.js +24 -25
  318. package/dist/utils/Operate/setValueInFormData.js +3 -3
  319. package/dist/utils/Operate/setValueInFormData.test.js +17 -17
  320. package/dist/utils/Operate/shouldRun.js +7 -7
  321. package/dist/utils/Operate/shouldRun.test.js +22 -24
  322. package/dist/utils/Validate/additional/conditionallyPermittedChange.js +1 -1
  323. package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +15 -15
  324. package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
  325. package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
  326. package/dist/utils/Validate/additional/index.js +8 -8
  327. package/dist/utils/Validate/additional/index.test.js +22 -22
  328. package/dist/utils/Validate/additional/mustBeAfter.js +3 -3
  329. package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
  330. package/dist/utils/Validate/additional/mustBeBefore.js +3 -3
  331. package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
  332. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -12
  333. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -38
  334. package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
  335. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
  336. package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -3
  337. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
  338. package/dist/utils/Validate/additional/mustBeInThePast.js +4 -4
  339. package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
  340. package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
  341. package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
  342. package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
  343. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
  344. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
  345. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
  346. package/dist/utils/Validate/additional/mustBeOneOf.js +1 -1
  347. package/dist/utils/Validate/additional/mustBeOneOf.test.js +13 -13
  348. package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
  349. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
  350. package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +5 -5
  351. package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +35 -36
  352. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
  353. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
  354. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
  355. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
  356. package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
  357. package/dist/utils/Validate/additional/mustNotContainSql.test.js +15 -15
  358. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
  359. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
  360. package/dist/utils/Validate/additional/utils.js +9 -22
  361. package/dist/utils/Validate/index.js +2 -2
  362. package/dist/utils/Validate/validateCollection.js +18 -23
  363. package/dist/utils/Validate/validateCollection.test.js +75 -67
  364. package/dist/utils/Validate/validateComponent.js +19 -19
  365. package/dist/utils/Validate/validateComponent.test.js +179 -154
  366. package/dist/utils/Validate/validateContainer.js +14 -17
  367. package/dist/utils/Validate/validateContainer.test.js +59 -53
  368. package/dist/utils/Validate/validateDate.js +16 -22
  369. package/dist/utils/Validate/validateDate.test.js +31 -32
  370. package/dist/utils/Validate/validateEmail.js +7 -9
  371. package/dist/utils/Validate/validateEmail.test.js +27 -27
  372. package/dist/utils/Validate/validateMultifile.js +5 -7
  373. package/dist/utils/Validate/validateMultifile.test.js +17 -18
  374. package/dist/utils/Validate/validatePage.js +13 -18
  375. package/dist/utils/Validate/validatePage.test.js +198 -195
  376. package/dist/utils/Validate/validateRegex.js +3 -5
  377. package/dist/utils/Validate/validateRegex.test.js +15 -15
  378. package/dist/utils/Validate/validateRequired.js +4 -6
  379. package/dist/utils/Validate/validateRequired.test.js +19 -19
  380. package/dist/utils/Validate/validateTextArea.js +4 -6
  381. package/dist/utils/Validate/validateTextArea.test.js +21 -21
  382. package/dist/utils/Validate/validateTime.js +12 -19
  383. package/dist/utils/Validate/validateTime.test.js +27 -27
  384. package/dist/utils/index.js +5 -6
  385. package/package.json +2 -4
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -12,61 +11,49 @@ var _models = require("../../models");
12
11
  var _Task = _interopRequireDefault(require("./Task"));
13
12
  var _showComponent = _interopRequireDefault(require("../../utils/Component/showComponent"));
14
13
  require("./TaskList.scss");
15
- var _excluded = ["id", "refTitle", "refNumber", "notes", "incompleteTitle", "showCompletionOverview", "sections", "fieldId", "onTaskAction", "classBlock", "classModifiers", "className", "formData", "annotations"];
14
+ const _excluded = ["id", "refTitle", "refNumber", "notes", "incompleteTitle", "showCompletionOverview", "sections", "fieldId", "onTaskAction", "classBlock", "classModifiers", "className", "formData", "annotations"];
16
15
  /* eslint-disable import/no-duplicates */
17
16
  // Global Imports
18
17
  // Local Imports
19
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
24
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
26
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
27
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
28
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
29
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
30
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
31
- var DEFAULT_CLASS = exports.DEFAULT_CLASS = 'hods-task-list';
32
- var DEFAULT_INCOMPLETE_TITLE = exports.DEFAULT_INCOMPLETE_TITLE = 'Incomplete form';
33
- var TaskList = function TaskList(_ref) {
34
- var id = _ref.id,
35
- refTitle = _ref.refTitle,
36
- refNumber = _ref.refNumber,
37
- notes = _ref.notes,
38
- incompleteTitle = _ref.incompleteTitle,
39
- showCompletionOverview = _ref.showCompletionOverview,
40
- sections = _ref.sections,
41
- fieldId = _ref.fieldId,
42
- onTaskAction = _ref.onTaskAction,
43
- classBlock = _ref.classBlock,
44
- classModifiers = _ref.classModifiers,
45
- className = _ref.className,
46
- formData = _ref.formData,
47
- annotations = _ref.annotations,
18
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
22
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
23
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
24
+ const DEFAULT_CLASS = exports.DEFAULT_CLASS = 'hods-task-list';
25
+ const DEFAULT_INCOMPLETE_TITLE = exports.DEFAULT_INCOMPLETE_TITLE = 'Incomplete form';
26
+ const TaskList = _ref => {
27
+ let {
28
+ id,
29
+ refTitle,
30
+ refNumber,
31
+ notes,
32
+ incompleteTitle,
33
+ showCompletionOverview,
34
+ sections,
35
+ fieldId,
36
+ onTaskAction,
37
+ classBlock,
38
+ classModifiers,
39
+ className,
40
+ formData,
41
+ annotations
42
+ } = _ref,
48
43
  attrs = _objectWithoutProperties(_ref, _excluded);
49
- var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
50
- var cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
44
+ const classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
45
+ const cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
51
46
  // TODO state will be retrieved from a document in S3 rather than given in the component definition, covered under COP-9885
52
- var _sections$filter$redu = sections.filter(function (section) {
53
- return !section.skipped;
54
- }).reduce(function (acc, current) {
55
- var _current$tasks$filter, _current$tasks, _current$tasks$filter2, _current$tasks2;
56
- return [acc[0] + ((_current$tasks$filter = (_current$tasks = current.tasks) === null || _current$tasks === void 0 ? void 0 : _current$tasks.filter(function (t) {
57
- return t.state === _models.TaskStates.TYPES.COMPLETE;
58
- }).length) !== null && _current$tasks$filter !== void 0 ? _current$tasks$filter : 0), acc[1] + ((_current$tasks$filter2 = (_current$tasks2 = current.tasks) === null || _current$tasks2 === void 0 ? void 0 : _current$tasks2.filter(function (task) {
59
- return task.state !== _models.TaskStates.TYPES.SKIPPED;
60
- }).length) !== null && _current$tasks$filter2 !== void 0 ? _current$tasks$filter2 : 0)];
61
- }, [0, 0]),
62
- _sections$filter$redu2 = _slicedToArray(_sections$filter$redu, 2),
63
- completeSections = _sections$filter$redu2[0],
64
- totalSections = _sections$filter$redu2[1];
65
- var notesId = "".concat(id, "Notes");
66
- var _ref2 = notes && notes || {},
67
- notesTitle = _ref2.title,
68
- notesText = _ref2.text;
69
- var onClick = function onClick(task) {
47
+ const [completeSections, totalSections] = sections.filter(section => !section.skipped).reduce((acc, current) => {
48
+ var _current$tasks$filter, _current$tasks, _current$tasks$filter2, _current$tasks2;
49
+ return [acc[0] + ((_current$tasks$filter = (_current$tasks = current.tasks) === null || _current$tasks === void 0 ? void 0 : _current$tasks.filter(t => t.state === _models.TaskStates.TYPES.COMPLETE).length) !== null && _current$tasks$filter !== void 0 ? _current$tasks$filter : 0), acc[1] + ((_current$tasks$filter2 = (_current$tasks2 = current.tasks) === null || _current$tasks2 === void 0 ? void 0 : _current$tasks2.filter(task => task.state !== _models.TaskStates.TYPES.SKIPPED).length) !== null && _current$tasks$filter2 !== void 0 ? _current$tasks$filter2 : 0)];
50
+ }, [0, 0]);
51
+ const notesId = "".concat(id, "Notes");
52
+ const {
53
+ title: notesTitle,
54
+ text: notesText
55
+ } = notes && notes || {};
56
+ const onClick = task => {
70
57
  if (typeof onTaskAction === 'function') {
71
58
  onTaskAction(task);
72
59
  }
@@ -80,15 +67,13 @@ var TaskList = function TaskList(_ref) {
80
67
  className: "tasklist-summary"
81
68
  }, "".concat(refTitle))), /*#__PURE__*/_react.default.createElement("p", {
82
69
  className: "govuk-body govuk-!-font-weight-regular"
83
- }, "".concat(refNumber))), annotations.length > 0 && annotations.map(function (annotation) {
84
- return /*#__PURE__*/_react.default.createElement("div", {
85
- className: classes('annotation')
86
- }, /*#__PURE__*/_react.default.createElement("p", {
87
- className: "".concat(classes('annotation-key'), " govuk-body")
88
- }, _copReactComponents.Utils.interpolateString(annotation.key, formData)), /*#__PURE__*/_react.default.createElement("p", {
89
- className: "".concat(classes('annotation-value'), " govuk-body")
90
- }, _copReactComponents.Utils.interpolateString(annotation.value, formData)));
91
- }), showCompletionOverview && totalSections !== completeSections && /*#__PURE__*/_react.default.createElement("p", {
70
+ }, "".concat(refNumber))), annotations.length > 0 && annotations.map(annotation => /*#__PURE__*/_react.default.createElement("div", {
71
+ className: classes('annotation')
72
+ }, /*#__PURE__*/_react.default.createElement("p", {
73
+ className: "".concat(classes('annotation-key'), " govuk-body")
74
+ }, _copReactComponents.Utils.interpolateString(annotation.key, formData)), /*#__PURE__*/_react.default.createElement("p", {
75
+ className: "".concat(classes('annotation-value'), " govuk-body")
76
+ }, _copReactComponents.Utils.interpolateString(annotation.value, formData)))), showCompletionOverview && totalSections !== completeSections && /*#__PURE__*/_react.default.createElement("p", {
92
77
  className: "govuk-body govuk-!-margin-bottom-0"
93
78
  }, /*#__PURE__*/_react.default.createElement("strong", {
94
79
  className: "tasklist-summary"
@@ -103,25 +88,17 @@ var TaskList = function TaskList(_ref) {
103
88
  fieldId: notesId,
104
89
  readOnly: true,
105
90
  value: _copReactComponents.Utils.interpolateString(notesText, formData)
106
- })), sections.filter(function (section) {
107
- return !section.skipped;
108
- }).map(function (section, index) {
109
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
110
- key: "".concat(section.name)
111
- }, /*#__PURE__*/_react.default.createElement("h2", {
112
- className: classes('section')
113
- }, sections.length > 1 ? "".concat(index + 1, ". ") : '', section.name), section.label && /*#__PURE__*/_react.default.createElement(_copReactComponents.Hint, null, section.label), /*#__PURE__*/_react.default.createElement("ol", {
114
- className: classes('items')
115
- }, section.tasks.filter(function (task) {
116
- return task.state !== _models.TaskStates.TYPES.SKIPPED;
117
- }).map(function (task) {
118
- return /*#__PURE__*/_react.default.createElement(_Task.default, {
119
- key: "".concat(section.name, "-").concat(task.name),
120
- task: task,
121
- onClick: onClick
122
- });
123
- })));
124
- }));
91
+ })), sections.filter(section => !section.skipped).map((section, index) => /*#__PURE__*/_react.default.createElement(_react.Fragment, {
92
+ key: "".concat(section.name)
93
+ }, /*#__PURE__*/_react.default.createElement("h2", {
94
+ className: classes('section')
95
+ }, sections.length > 1 ? "".concat(index + 1, ". ") : '', section.name), section.label && /*#__PURE__*/_react.default.createElement(_copReactComponents.Hint, null, section.label), /*#__PURE__*/_react.default.createElement("ol", {
96
+ className: classes('items')
97
+ }, section.tasks.filter(task => task.state !== _models.TaskStates.TYPES.SKIPPED).map(task => /*#__PURE__*/_react.default.createElement(_Task.default, {
98
+ key: "".concat(section.name, "-").concat(task.name),
99
+ task: task,
100
+ onClick: onClick
101
+ }))))));
125
102
  };
126
103
  TaskList.propTypes = {
127
104
  classBlock: _propTypes.default.string,
@@ -1,25 +1,21 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  var _react = require("@testing-library/react");
5
4
  var _react2 = _interopRequireDefault(require("react"));
6
5
  var _TaskList = _interopRequireWildcard(require("./TaskList"));
7
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
8
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
6
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
7
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ // Global imports
10
+
16
11
  // Local imports
17
- describe('components', function () {
18
- describe('TaskList', function () {
19
- it('should render a TaskList', function () {
20
- var COP_REF = '123';
21
- var REF_TITLE = 'COP reference number';
22
- var sections = [{
12
+
13
+ describe('components', () => {
14
+ describe('TaskList', () => {
15
+ it('should render a TaskList', () => {
16
+ const COP_REF = '123';
17
+ const REF_TITLE = 'COP reference number';
18
+ const sections = [{
23
19
  name: 'These are your tasks',
24
20
  label: 'This is the label for your first tasks',
25
21
  tasks: [{
@@ -52,26 +48,19 @@ describe('components', function () {
52
48
  pages: ['pageSix']
53
49
  }]
54
50
  }];
55
- var _render = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
56
- refNumber: COP_REF,
57
- refTitle: REF_TITLE,
58
- sections: sections
59
- })),
60
- container = _render.container;
61
- var childNodes = container.childNodes;
51
+ const {
52
+ container
53
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
54
+ refNumber: COP_REF,
55
+ refTitle: REF_TITLE,
56
+ sections: sections
57
+ }));
58
+ const {
59
+ childNodes
60
+ } = container;
62
61
  expect(childNodes.length).toEqual(1);
63
62
  expect(childNodes[0].childNodes.length).toEqual(10);
64
- var _childNodes$0$childNo = _slicedToArray(childNodes[0].childNodes, 10),
65
- referenceHeading = _childNodes$0$childNo[0],
66
- referenceNumber = _childNodes$0$childNo[1],
67
- incompleteForm = _childNodes$0$childNo[2],
68
- numComplete = _childNodes$0$childNo[3],
69
- subSectionOneHeading = _childNodes$0$childNo[4],
70
- subSectionOneLabel = _childNodes$0$childNo[5],
71
- subSectionOneList = _childNodes$0$childNo[6],
72
- subSectionTwoHeading = _childNodes$0$childNo[7],
73
- subSectionTwoLabel = _childNodes$0$childNo[8],
74
- subSectionTwoList = _childNodes$0$childNo[9];
63
+ const [referenceHeading, referenceNumber, incompleteForm, numComplete, subSectionOneHeading, subSectionOneLabel, subSectionOneList, subSectionTwoHeading, subSectionTwoLabel, subSectionTwoList] = childNodes[0].childNodes;
75
64
  expect(referenceHeading).toMatchObject({
76
65
  tagName: 'P',
77
66
  textContent: 'COP reference number'
@@ -101,10 +90,10 @@ describe('components', function () {
101
90
  expect(subSectionTwoLabel.textContent).toEqual('This is the label for your extra tasks');
102
91
  expect(subSectionTwoList.childNodes.length).toEqual(3);
103
92
  });
104
- it('should not render the incomplete title and message when showCompletionOverview is false', function () {
105
- var COP_REF = '123';
106
- var REF_TITLE = 'COP reference number';
107
- var sections = [{
93
+ it('should not render the incomplete title and message when showCompletionOverview is false', () => {
94
+ const COP_REF = '123';
95
+ const REF_TITLE = 'COP reference number';
96
+ const sections = [{
108
97
  name: 'These are your tasks',
109
98
  label: 'This is the label for your first tasks',
110
99
  tasks: [{
@@ -137,26 +126,21 @@ describe('components', function () {
137
126
  pages: ['pageSix']
138
127
  }]
139
128
  }];
140
- var _render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
141
- refNumber: COP_REF,
142
- refTitle: REF_TITLE,
143
- sections: sections,
144
- showCompletionOverview: false
145
- })),
146
- container = _render2.container;
147
- var childNodes = container.childNodes;
129
+ const {
130
+ container
131
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
132
+ refNumber: COP_REF,
133
+ refTitle: REF_TITLE,
134
+ sections: sections,
135
+ showCompletionOverview: false
136
+ }));
137
+ const {
138
+ childNodes
139
+ } = container;
148
140
  expect(childNodes.length).toEqual(1);
149
141
  expect(childNodes[0].childNodes.length).toEqual(8); // Without incomplete heading and message.
150
142
 
151
- var _childNodes$0$childNo2 = _slicedToArray(childNodes[0].childNodes, 8),
152
- referenceHeading = _childNodes$0$childNo2[0],
153
- referenceNumber = _childNodes$0$childNo2[1],
154
- subSectionOneHeading = _childNodes$0$childNo2[2],
155
- subSectionOneLabel = _childNodes$0$childNo2[3],
156
- subSectionOneList = _childNodes$0$childNo2[4],
157
- subSectionTwoHeading = _childNodes$0$childNo2[5],
158
- subSectionTwoLabel = _childNodes$0$childNo2[6],
159
- subSectionTwoList = _childNodes$0$childNo2[7];
143
+ const [referenceHeading, referenceNumber, subSectionOneHeading, subSectionOneLabel, subSectionOneList, subSectionTwoHeading, subSectionTwoLabel, subSectionTwoList] = childNodes[0].childNodes;
160
144
  expect(referenceHeading).toMatchObject({
161
145
  tagName: 'P',
162
146
  textContent: 'COP reference number'
@@ -178,10 +162,10 @@ describe('components', function () {
178
162
  expect(subSectionTwoLabel.textContent).toEqual('This is the label for your extra tasks');
179
163
  expect(subSectionTwoList.childNodes.length).toEqual(3);
180
164
  });
181
- it('should render any provided annotations', function () {
182
- var COP_REF = '123';
183
- var REF_TITLE = 'COP reference number';
184
- var sections = [{
165
+ it('should render any provided annotations', () => {
166
+ const COP_REF = '123';
167
+ const REF_TITLE = 'COP reference number';
168
+ const sections = [{
185
169
  name: 'These are your tasks',
186
170
  label: 'This is the label for your first tasks',
187
171
  tasks: [{
@@ -214,28 +198,31 @@ describe('components', function () {
214
198
  pages: ['pageSix']
215
199
  }]
216
200
  }];
217
- var FORM_DATA = {
201
+ const FORM_DATA = {
218
202
  port: {
219
203
  name: 'Heathrow Airport'
220
204
  }
221
205
  };
222
- var ANNOTATIONS = [{
206
+ const ANNOTATIONS = [{
223
207
  key: 'Port',
224
208
  // eslint-disable-next-line no-template-curly-in-string
225
209
  value: '${port.name}'
226
210
  }];
227
- var _render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
228
- refNumber: COP_REF,
229
- refTitle: REF_TITLE,
230
- sections: sections,
231
- annotations: ANNOTATIONS,
232
- formData: FORM_DATA
233
- })),
234
- container = _render3.container;
235
- var childNodes = container.childNodes;
211
+ const {
212
+ container
213
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
214
+ refNumber: COP_REF,
215
+ refTitle: REF_TITLE,
216
+ sections: sections,
217
+ annotations: ANNOTATIONS,
218
+ formData: FORM_DATA
219
+ }));
220
+ const {
221
+ childNodes
222
+ } = container;
236
223
  expect(childNodes.length).toEqual(1);
237
224
  expect(childNodes[0].childNodes.length).toEqual(11);
238
- var annotation = childNodes[0].childNodes[2];
225
+ const annotation = childNodes[0].childNodes[2];
239
226
  expect(annotation.children[0]).toMatchObject({
240
227
  tagName: 'P',
241
228
  textContent: 'Port'
@@ -245,10 +232,10 @@ describe('components', function () {
245
232
  textContent: 'Heathrow Airport'
246
233
  });
247
234
  });
248
- it('should not show incomplete title if form is complete', function () {
249
- var COP_REF = '123';
250
- var REF_TITLE = 'COP reference number';
251
- var sections = [{
235
+ it('should not show incomplete title if form is complete', () => {
236
+ const COP_REF = '123';
237
+ const REF_TITLE = 'COP reference number';
238
+ const sections = [{
252
239
  name: 'These are your tasks',
253
240
  tasks: [{
254
241
  name: 'Nice task',
@@ -279,18 +266,18 @@ describe('components', function () {
279
266
  pages: ['pageSix']
280
267
  }]
281
268
  }];
282
- var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
283
- refNumber: COP_REF,
284
- refTitle: REF_TITLE,
285
- sections: sections
286
- })),
287
- container = _render4.container;
288
- var childNodes = container.childNodes;
269
+ const {
270
+ container
271
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
272
+ refNumber: COP_REF,
273
+ refTitle: REF_TITLE,
274
+ sections: sections
275
+ }));
276
+ const {
277
+ childNodes
278
+ } = container;
289
279
  expect(childNodes[0].childNodes.length).toEqual(7);
290
- var _childNodes$0$childNo3 = _slicedToArray(childNodes[0].childNodes, 3),
291
- referenceHeading = _childNodes$0$childNo3[0],
292
- referenceNumber = _childNodes$0$childNo3[1],
293
- numComplete = _childNodes$0$childNo3[2];
280
+ const [referenceHeading, referenceNumber, numComplete] = childNodes[0].childNodes;
294
281
  expect(referenceHeading).toMatchObject({
295
282
  tagName: 'P',
296
283
  textContent: 'COP reference number'
@@ -304,10 +291,10 @@ describe('components', function () {
304
291
  textContent: 'You have completed 6 of 6 sections'
305
292
  });
306
293
  });
307
- it('should not show numbers on section headings if there is only one section', function () {
308
- var COP_REF = '123';
309
- var REF_TITLE = 'COP reference number';
310
- var sections = [{
294
+ it('should not show numbers on section headings if there is only one section', () => {
295
+ const COP_REF = '123';
296
+ const REF_TITLE = 'COP reference number';
297
+ const sections = [{
311
298
  name: 'These are your tasks',
312
299
  tasks: [{
313
300
  name: 'Nice task',
@@ -323,20 +310,23 @@ describe('components', function () {
323
310
  pages: ['pageThree']
324
311
  }]
325
312
  }];
326
- var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
327
- refNumber: COP_REF,
328
- refTitle: REF_TITLE,
329
- sections: sections
330
- })),
331
- container = _render5.container;
332
- var childNodes = container.childNodes;
333
- var subSectionOne = childNodes[0].childNodes[4];
313
+ const {
314
+ container
315
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
316
+ refNumber: COP_REF,
317
+ refTitle: REF_TITLE,
318
+ sections: sections
319
+ }));
320
+ const {
321
+ childNodes
322
+ } = container;
323
+ const subSectionOne = childNodes[0].childNodes[4];
334
324
  expect(subSectionOne.childNodes[0].textContent).toEqual('');
335
325
  expect(subSectionOne.childNodes[1].textContent).toEqual('These are your tasks');
336
326
  });
337
- it('should not display the reference if there is no reference title', function () {
338
- var COP_REF = '123';
339
- var sections = [{
327
+ it('should not display the reference if there is no reference title', () => {
328
+ const COP_REF = '123';
329
+ const sections = [{
340
330
  name: 'These are your tasks',
341
331
  tasks: [{
342
332
  name: 'Nice task',
@@ -367,26 +357,29 @@ describe('components', function () {
367
357
  pages: ['pageSix']
368
358
  }]
369
359
  }];
370
- var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
371
- refNumber: COP_REF,
372
- sections: sections
373
- })),
374
- container = _render6.container;
375
- var childNodes = container.childNodes;
360
+ const {
361
+ container
362
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
363
+ refNumber: COP_REF,
364
+ sections: sections
365
+ }));
366
+ const {
367
+ childNodes
368
+ } = container;
376
369
  expect(childNodes.length).toEqual(1);
377
370
  expect(childNodes[0].childNodes.length).toEqual(6);
378
371
 
379
372
  // The first child is now the incomplete text.
380
- var incompleteForm = childNodes[0].childNodes[0];
373
+ const incompleteForm = childNodes[0].childNodes[0];
381
374
  expect(incompleteForm).toMatchObject({
382
375
  tagName: 'P',
383
376
  textContent: _TaskList.DEFAULT_INCOMPLETE_TITLE
384
377
  });
385
378
  });
386
- it('should show the correct incomplete title', function () {
387
- var INCOMPLETE_TITLE = 'Alpha Bravo';
388
- var COP_REF = '123';
389
- var sections = [{
379
+ it('should show the correct incomplete title', () => {
380
+ const INCOMPLETE_TITLE = 'Alpha Bravo';
381
+ const COP_REF = '123';
382
+ const sections = [{
390
383
  name: 'These are your tasks',
391
384
  tasks: [{
392
385
  name: 'Nice task',
@@ -417,21 +410,24 @@ describe('components', function () {
417
410
  pages: ['pageSix']
418
411
  }]
419
412
  }];
420
- var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
421
- refNumber: COP_REF,
422
- sections: sections,
423
- incompleteTitle: INCOMPLETE_TITLE
424
- })),
425
- container = _render7.container;
426
- var childNodes = container.childNodes;
413
+ const {
414
+ container
415
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
416
+ refNumber: COP_REF,
417
+ sections: sections,
418
+ incompleteTitle: INCOMPLETE_TITLE
419
+ }));
420
+ const {
421
+ childNodes
422
+ } = container;
427
423
  // The first child is now the incomplete text.
428
- var incompleteForm = childNodes[0].childNodes[0];
424
+ const incompleteForm = childNodes[0].childNodes[0];
429
425
  expect(incompleteForm.textContent).toEqual(INCOMPLETE_TITLE);
430
426
  });
431
- it('should not show skipped sections', function () {
432
- var INCOMPLETE_TITLE = 'Alpha Bravo';
433
- var COP_REF = '123';
434
- var sections = [{
427
+ it('should not show skipped sections', () => {
428
+ const INCOMPLETE_TITLE = 'Alpha Bravo';
429
+ const COP_REF = '123';
430
+ const sections = [{
435
431
  name: 'These are your tasks',
436
432
  skipped: true,
437
433
  tasks: [{
@@ -463,29 +459,32 @@ describe('components', function () {
463
459
  pages: ['pageSix']
464
460
  }]
465
461
  }];
466
- var _render8 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
467
- refNumber: COP_REF,
468
- sections: sections,
469
- incompleteTitle: INCOMPLETE_TITLE
470
- })),
471
- container = _render8.container;
472
- var childNodes = container.childNodes;
462
+ const {
463
+ container
464
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
465
+ refNumber: COP_REF,
466
+ sections: sections,
467
+ incompleteTitle: INCOMPLETE_TITLE
468
+ }));
469
+ const {
470
+ childNodes
471
+ } = container;
473
472
  expect(childNodes.length).toEqual(1);
474
- var children = childNodes[0].childNodes;
473
+ const children = childNodes[0].childNodes;
475
474
  expect(children.length).toEqual(4);
476
475
  expect(children[0].textContent).toEqual(INCOMPLETE_TITLE);
477
476
  expect(children[1].textContent).toEqual('You have completed 1 of 3 sections');
478
477
  expect(children[2].textContent).toEqual("1. ".concat(sections[1].name));
479
478
  });
480
479
  });
481
- it('should pass the selected task to the given onTaskAction function', function () {
482
- var COP_REF = '123';
483
- var REF_TITLE = 'COP reference number';
484
- var ON_CLICK_CALLS = [];
485
- var ON_CLICK = function ON_CLICK(value) {
480
+ it('should pass the selected task to the given onTaskAction function', () => {
481
+ const COP_REF = '123';
482
+ const REF_TITLE = 'COP reference number';
483
+ const ON_CLICK_CALLS = [];
484
+ const ON_CLICK = value => {
486
485
  ON_CLICK_CALLS.push(value);
487
486
  };
488
- var sections = [{
487
+ const sections = [{
489
488
  name: 'These are your tasks',
490
489
  tasks: [{
491
490
  name: 'Nice task',
@@ -501,17 +500,18 @@ describe('components', function () {
501
500
  pages: ['pageThree']
502
501
  }]
503
502
  }];
504
- var _render9 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
505
- refNumber: COP_REF,
506
- refTitle: REF_TITLE,
507
- sections: sections,
508
- onTaskAction: ON_CLICK
509
- })),
510
- container = _render9.container;
511
- var taskList = container.childNodes[0].childNodes[5].childNodes;
512
- var firstTask = taskList[0].childNodes[0].childNodes[0];
513
- var secondTask = taskList[1].childNodes[0].childNodes[0];
514
- var thirdTask = taskList[2].childNodes[0].childNodes[0];
503
+ const {
504
+ container
505
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
506
+ refNumber: COP_REF,
507
+ refTitle: REF_TITLE,
508
+ sections: sections,
509
+ onTaskAction: ON_CLICK
510
+ }));
511
+ const taskList = container.childNodes[0].childNodes[5].childNodes;
512
+ const firstTask = taskList[0].childNodes[0].childNodes[0];
513
+ const secondTask = taskList[1].childNodes[0].childNodes[0];
514
+ const thirdTask = taskList[2].childNodes[0].childNodes[0];
515
515
  _react.fireEvent.click(firstTask.childNodes[0]);
516
516
  expect(ON_CLICK_CALLS[0]).toEqual({
517
517
  pages: ['pageOne'],