@ukhomeoffice/cop-react-form-renderer 5.45.1 → 5.45.2-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 (350) 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.test.js +464 -769
  5. package/dist/components/CollectionPage/CollectionPage.js +66 -58
  6. package/dist/components/CollectionPage/CollectionPage.test.js +300 -342
  7. package/dist/components/CollectionSummary/BannerStrip.js +12 -12
  8. package/dist/components/CollectionSummary/BannerStrip.test.js +63 -59
  9. package/dist/components/CollectionSummary/CollectionSummary.js +60 -75
  10. package/dist/components/CollectionSummary/CollectionSummary.test.js +102 -96
  11. package/dist/components/CollectionSummary/Confirmation.js +14 -12
  12. package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
  13. package/dist/components/CollectionSummary/SummaryCard.js +93 -133
  14. package/dist/components/CollectionSummary/SummaryCard.test.js +902 -924
  15. package/dist/components/CollectionSummary/SummaryCardValidationContext.js +23 -29
  16. package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +61 -73
  17. package/dist/components/FormComponent/Collection.js +73 -107
  18. package/dist/components/FormComponent/Collection.test.js +809 -945
  19. package/dist/components/FormComponent/Container.js +40 -38
  20. package/dist/components/FormComponent/Container.test.js +314 -345
  21. package/dist/components/FormComponent/FormComponent.js +67 -70
  22. package/dist/components/FormComponent/FormComponent.test.js +284 -342
  23. package/dist/components/FormComponent/helpers/addLabel.js +4 -7
  24. package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
  25. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
  26. package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
  27. package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
  28. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
  29. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
  30. package/dist/components/FormComponent/helpers/index.js +4 -4
  31. package/dist/components/FormPage/FormPage.js +65 -80
  32. package/dist/components/FormPage/FormPage.test.js +127 -163
  33. package/dist/components/FormRenderer/FormRenderer.js +142 -178
  34. package/dist/components/FormRenderer/FormRenderer.test.js +730 -1115
  35. package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
  36. package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
  37. package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
  38. package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
  39. package/dist/components/FormRenderer/handlers/index.js +1 -1
  40. package/dist/components/FormRenderer/handlers/navigate.js +3 -3
  41. package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
  42. package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
  43. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +9 -9
  44. package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
  45. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +16 -20
  46. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +17 -22
  47. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
  48. package/dist/components/FormRenderer/helpers/getCYA.js +3 -5
  49. package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
  50. package/dist/components/FormRenderer/helpers/getFormState.js +5 -7
  51. package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
  52. package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -24
  53. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
  54. package/dist/components/FormRenderer/helpers/getPage.js +2 -4
  55. package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
  56. package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
  57. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
  58. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
  59. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +97 -91
  60. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
  61. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -73
  62. package/dist/components/FormRenderer/helpers/index.js +1 -1
  63. package/dist/components/FormRenderer/onCYAAction.js +59 -51
  64. package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
  65. package/dist/components/FormRenderer/onPageAction.js +43 -39
  66. package/dist/components/FormRenderer/onPageAction.test.js +223 -206
  67. package/dist/components/FormRenderer/onTaskAction.js +9 -13
  68. package/dist/components/FormRenderer/onTaskAction.test.js +93 -88
  69. package/dist/components/PageActions/ActionButton.js +12 -15
  70. package/dist/components/PageActions/ActionButton.test.js +56 -78
  71. package/dist/components/PageActions/PageActions.js +10 -10
  72. package/dist/components/PageActions/PageActions.test.js +86 -115
  73. package/dist/components/SummaryList/GroupAction.js +9 -17
  74. package/dist/components/SummaryList/GroupAction.test.js +37 -33
  75. package/dist/components/SummaryList/RowAction.js +11 -16
  76. package/dist/components/SummaryList/RowAction.test.js +37 -33
  77. package/dist/components/SummaryList/SummaryList.js +21 -26
  78. package/dist/components/SummaryList/SummaryList.test.js +143 -166
  79. package/dist/components/SummaryList/SummaryListHeadingRow.js +6 -4
  80. package/dist/components/SummaryList/SummaryListRow.js +6 -4
  81. package/dist/components/SummaryList/SummaryListTitleRow.js +5 -3
  82. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
  83. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
  84. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
  85. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
  86. package/dist/components/SummaryList/helpers/index.js +1 -1
  87. package/dist/components/TaskList/Task.js +19 -29
  88. package/dist/components/TaskList/Task.test.js +83 -76
  89. package/dist/components/TaskList/TaskList.js +45 -71
  90. package/dist/components/TaskList/TaskList.test.js +113 -111
  91. package/dist/components/TaskList/TaskState.js +7 -5
  92. package/dist/components/TaskList/TaskState.test.js +52 -45
  93. package/dist/components/index.js +7 -7
  94. package/dist/context/HooksContext/HooksContext.js +58 -79
  95. package/dist/context/HooksContext/HooksContext.test.js +26 -35
  96. package/dist/context/HooksContext/index.js +3 -4
  97. package/dist/context/ValidationContext/ValidationContext.js +32 -72
  98. package/dist/context/ValidationContext/ValidationContext.test.js +47 -59
  99. package/dist/context/ValidationContext/index.js +3 -4
  100. package/dist/context/index.js +2 -2
  101. package/dist/hooks/index.js +9 -10
  102. package/dist/hooks/useAxios.js +14 -40
  103. package/dist/hooks/useGetRequest.js +61 -97
  104. package/dist/hooks/useHooks.js +1 -3
  105. package/dist/hooks/useRefData.js +26 -39
  106. package/dist/hooks/useValidation.js +1 -3
  107. package/dist/index.js +13 -14
  108. package/dist/models/CollectionLabels.js +1 -1
  109. package/dist/models/ComponentTypes.js +25 -25
  110. package/dist/models/EventTypes.js +4 -4
  111. package/dist/models/FormPages.js +4 -4
  112. package/dist/models/FormTypes.js +8 -8
  113. package/dist/models/HubFormats.js +3 -3
  114. package/dist/models/PageAction.js +44 -38
  115. package/dist/models/TaskStates.js +30 -28
  116. package/dist/models/index.js +9 -9
  117. package/dist/setupTests.js +30 -31
  118. package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
  119. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +52 -54
  120. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +15 -25
  121. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +33 -35
  122. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -31
  123. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +42 -44
  124. package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
  125. package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
  126. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +18 -24
  127. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +15 -16
  128. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +33 -36
  129. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +58 -60
  130. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +79 -88
  131. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +146 -124
  132. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +25 -20
  133. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +103 -97
  134. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +13 -18
  135. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +70 -76
  136. package/dist/utils/CheckYourAnswers/index.js +1 -1
  137. package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
  138. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +24 -24
  139. package/dist/utils/CollectionPage/addCollectionPageEntry.js +1 -1
  140. package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
  141. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
  142. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -17
  143. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +9 -18
  144. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +27 -22
  145. package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
  146. package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
  147. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
  148. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
  149. package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
  150. package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
  151. package/dist/utils/CollectionPage/getQuickEditPage.js +19 -19
  152. package/dist/utils/CollectionPage/getQuickEditPage.test.js +12 -16
  153. package/dist/utils/CollectionPage/index.js +1 -1
  154. package/dist/utils/CollectionPage/mergeCollectionPages.js +29 -30
  155. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +17 -17
  156. package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
  157. package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
  158. package/dist/utils/CollectionPage/setCollectionPageData.js +8 -12
  159. package/dist/utils/CollectionPage/setCollectionPageData.test.js +17 -17
  160. package/dist/utils/Component/addShowWhen.js +4 -8
  161. package/dist/utils/Component/addShowWhen.test.js +37 -37
  162. package/dist/utils/Component/applyToComponentTree.js +18 -18
  163. package/dist/utils/Component/applyToComponentTree.test.js +27 -32
  164. package/dist/utils/Component/cleanAttributes.js +10 -13
  165. package/dist/utils/Component/cleanAttributes.test.js +17 -18
  166. package/dist/utils/Component/elevateNestedComponents.js +5 -5
  167. package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
  168. package/dist/utils/Component/getComponent.js +88 -94
  169. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +18 -17
  170. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +46 -59
  171. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +39 -48
  172. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +23 -33
  173. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +20 -18
  174. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +17 -22
  175. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +20 -25
  176. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +10 -9
  177. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +17 -15
  178. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +9 -8
  179. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +17 -15
  180. package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +22 -26
  181. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
  182. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +17 -15
  183. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +17 -22
  184. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +57 -70
  185. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +17 -22
  186. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +17 -22
  187. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +31 -38
  188. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +20 -29
  189. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
  190. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +9 -8
  191. package/dist/utils/Component/getDefaultValue.js +6 -8
  192. package/dist/utils/Component/getDefaultValue.test.js +12 -12
  193. package/dist/utils/Component/getDefaultValueFromConfig.js +22 -21
  194. package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
  195. package/dist/utils/Component/index.js +1 -1
  196. package/dist/utils/Component/isEditable.js +2 -4
  197. package/dist/utils/Component/isEditable.test.js +14 -15
  198. package/dist/utils/Component/optionIsSelected.js +1 -1
  199. package/dist/utils/Component/optionIsSelected.test.js +9 -9
  200. package/dist/utils/Component/setupContainerComponentsPath.js +27 -29
  201. package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
  202. package/dist/utils/Component/showComponent.js +1 -1
  203. package/dist/utils/Component/showComponent.test.js +28 -28
  204. package/dist/utils/Component/wrapInFormGroup.js +2 -2
  205. package/dist/utils/Condition/index.js +1 -1
  206. package/dist/utils/Condition/meetsAllConditions.js +7 -7
  207. package/dist/utils/Condition/meetsAllConditions.test.js +17 -17
  208. package/dist/utils/Condition/meetsCondition.js +14 -17
  209. package/dist/utils/Condition/meetsCondition.test.js +376 -376
  210. package/dist/utils/Condition/meetsOneCondition.js +5 -5
  211. package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
  212. package/dist/utils/Condition/setupConditions.js +13 -18
  213. package/dist/utils/Condition/setupConditions.test.js +7 -7
  214. package/dist/utils/Container/getEditableComponents.js +3 -5
  215. package/dist/utils/Container/getEditableComponents.test.js +43 -45
  216. package/dist/utils/Container/index.js +1 -1
  217. package/dist/utils/Container/setupNesting.js +16 -20
  218. package/dist/utils/Container/setupNesting.test.js +27 -30
  219. package/dist/utils/Container/showContainer.js +3 -7
  220. package/dist/utils/Container/showContainer.test.js +30 -30
  221. package/dist/utils/Data/applyFormula.js +38 -48
  222. package/dist/utils/Data/applyFormula.test.js +20 -20
  223. package/dist/utils/Data/getAutocompleteSource.js +18 -26
  224. package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
  225. package/dist/utils/Data/getDataPath.js +18 -28
  226. package/dist/utils/Data/getDataPath.test.js +12 -12
  227. package/dist/utils/Data/getOptions.js +19 -25
  228. package/dist/utils/Data/getOptions.test.js +20 -20
  229. package/dist/utils/Data/getSourceData.js +6 -19
  230. package/dist/utils/Data/getSourceData.test.js +84 -80
  231. package/dist/utils/Data/index.js +1 -1
  232. package/dist/utils/Data/refDataToOptions.js +10 -13
  233. package/dist/utils/Data/refDataToOptions.test.js +19 -19
  234. package/dist/utils/Data/setDataItem.js +7 -8
  235. package/dist/utils/Data/setDataItem.test.js +37 -37
  236. package/dist/utils/Data/setupFormData.js +13 -21
  237. package/dist/utils/Data/setupFormData.test.js +51 -50
  238. package/dist/utils/Data/setupRefDataUrlForComponent.js +20 -26
  239. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
  240. package/dist/utils/FormPage/applyConditionalProperties.js +5 -9
  241. package/dist/utils/FormPage/applyConditionalProperties.test.js +15 -18
  242. package/dist/utils/FormPage/getFormPage.js +15 -16
  243. package/dist/utils/FormPage/getFormPage.test.js +47 -46
  244. package/dist/utils/FormPage/getFormPages.js +7 -12
  245. package/dist/utils/FormPage/getFormPages.test.js +20 -23
  246. package/dist/utils/FormPage/getPageActions.js +9 -15
  247. package/dist/utils/FormPage/getPageActions.test.js +32 -32
  248. package/dist/utils/FormPage/getPageTitle.js +2 -2
  249. package/dist/utils/FormPage/getPageTitle.test.js +22 -22
  250. package/dist/utils/FormPage/getParagraphFromText.js +5 -7
  251. package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
  252. package/dist/utils/FormPage/index.js +1 -1
  253. package/dist/utils/FormPage/showFormPage.js +3 -7
  254. package/dist/utils/FormPage/showFormPage.test.js +32 -32
  255. package/dist/utils/FormPage/showFormPageCYA.js +1 -1
  256. package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
  257. package/dist/utils/FormPage/useComponent.js +21 -28
  258. package/dist/utils/FormPage/useComponent.test.js +78 -79
  259. package/dist/utils/Format/formatData.js +1 -1
  260. package/dist/utils/Format/formatData.test.js +18 -18
  261. package/dist/utils/Format/formatDataForComponent.js +5 -6
  262. package/dist/utils/Format/formatDataForComponent.test.js +50 -77
  263. package/dist/utils/Format/formatDataForForm.js +6 -8
  264. package/dist/utils/Format/formatDataForForm.test.js +13 -15
  265. package/dist/utils/Format/formatDataForPage.js +4 -5
  266. package/dist/utils/Format/formatDataForPage.test.js +20 -23
  267. package/dist/utils/Format/index.js +1 -1
  268. package/dist/utils/Hub/getFormHub.js +1 -1
  269. package/dist/utils/Hub/getFormHub.test.js +28 -31
  270. package/dist/utils/Hub/index.js +1 -1
  271. package/dist/utils/Meta/constants.js +2 -2
  272. package/dist/utils/Meta/documents/getDocuments.js +1 -1
  273. package/dist/utils/Meta/documents/getDocuments.test.js +24 -16
  274. package/dist/utils/Meta/documents/index.js +1 -1
  275. package/dist/utils/Meta/documents/setDocumentsForField.js +14 -16
  276. package/dist/utils/Meta/documents/setDocumentsForField.test.js +68 -34
  277. package/dist/utils/Meta/index.js +1 -1
  278. package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
  279. package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
  280. package/dist/utils/Operate/getFirstOf.js +5 -5
  281. package/dist/utils/Operate/getFirstOf.test.js +31 -31
  282. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
  283. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -46
  284. package/dist/utils/Operate/index.js +1 -1
  285. package/dist/utils/Operate/persistValueInFormData.js +3 -3
  286. package/dist/utils/Operate/persistValueInFormData.test.js +22 -20
  287. package/dist/utils/Operate/runPageOperations.js +7 -7
  288. package/dist/utils/Operate/runPageOperations.test.js +35 -36
  289. package/dist/utils/Operate/setValueInFormData.js +2 -2
  290. package/dist/utils/Operate/setValueInFormData.test.js +16 -16
  291. package/dist/utils/Operate/shouldRun.js +6 -6
  292. package/dist/utils/Operate/shouldRun.test.js +21 -26
  293. package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
  294. package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
  295. package/dist/utils/Validate/additional/index.js +6 -6
  296. package/dist/utils/Validate/additional/index.test.js +12 -12
  297. package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
  298. package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
  299. package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
  300. package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
  301. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +7 -11
  302. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -41
  303. package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
  304. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
  305. package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
  306. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
  307. package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
  308. package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
  309. package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
  310. package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
  311. package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
  312. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
  313. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
  314. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
  315. package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
  316. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
  317. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
  318. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +14 -16
  319. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
  320. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
  321. package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
  322. package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
  323. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
  324. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +28 -26
  325. package/dist/utils/Validate/additional/utils.js +9 -22
  326. package/dist/utils/Validate/index.js +1 -1
  327. package/dist/utils/Validate/validateCollection.js +19 -25
  328. package/dist/utils/Validate/validateCollection.test.js +74 -66
  329. package/dist/utils/Validate/validateComponent.js +17 -15
  330. package/dist/utils/Validate/validateComponent.test.js +167 -146
  331. package/dist/utils/Validate/validateContainer.js +14 -19
  332. package/dist/utils/Validate/validateContainer.test.js +49 -45
  333. package/dist/utils/Validate/validateDate.js +11 -17
  334. package/dist/utils/Validate/validateDate.test.js +28 -29
  335. package/dist/utils/Validate/validateEmail.js +6 -8
  336. package/dist/utils/Validate/validateEmail.test.js +25 -25
  337. package/dist/utils/Validate/validateMultifile.js +5 -7
  338. package/dist/utils/Validate/validateMultifile.test.js +17 -18
  339. package/dist/utils/Validate/validatePage.js +17 -18
  340. package/dist/utils/Validate/validatePage.test.js +185 -182
  341. package/dist/utils/Validate/validateRegex.js +3 -5
  342. package/dist/utils/Validate/validateRegex.test.js +14 -14
  343. package/dist/utils/Validate/validateRequired.js +4 -6
  344. package/dist/utils/Validate/validateRequired.test.js +18 -18
  345. package/dist/utils/Validate/validateTextArea.js +4 -6
  346. package/dist/utils/Validate/validateTextArea.test.js +20 -20
  347. package/dist/utils/Validate/validateTime.js +7 -14
  348. package/dist/utils/Validate/validateTime.test.js +14 -14
  349. package/dist/utils/index.js +7 -9
  350. package/package.json +1 -1
@@ -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
  var _react = require("@testing-library/react");
5
4
  var _react2 = _interopRequireDefault(require("react"));
6
5
  var _copReactComponents = require("@ukhomeoffice/cop-react-components");
@@ -9,22 +8,17 @@ var _setupTests = require("../../setupTests");
9
8
  var _SummaryCard = _interopRequireWildcard(require("./SummaryCard"));
10
9
  var _BannerStrip = require("./BannerStrip");
11
10
  var _SummaryCardValidationContext = _interopRequireDefault(require("./SummaryCardValidationContext"));
12
- 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); }
13
- 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; }
11
+ 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); }
12
+ 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; }
14
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
- 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; }
18
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
- 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); }
20
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
21
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
22
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } // Global imports.
14
+ // Global imports.
15
+
23
16
  // Local imports.
24
- describe('components.CollectionSummary.SummaryCard', function () {
25
- var classes = _copReactComponents.Utils.classBuilder(_SummaryCard.DEFAULT_CLASS, [], '');
26
- var ID = 'summaryCardId';
27
- var ENTRY = {
17
+
18
+ describe('components.CollectionSummary.SummaryCard', () => {
19
+ const classes = _copReactComponents.Utils.classBuilder(_SummaryCard.DEFAULT_CLASS, [], '');
20
+ const ID = 'summaryCardId';
21
+ const ENTRY = {
28
22
  id: '001',
29
23
  bannerText: 'A banner',
30
24
  titleText: 'A title',
@@ -32,217 +26,229 @@ describe('components.CollectionSummary.SummaryCard', function () {
32
26
  index: 0,
33
27
  summaryText: 'Full details'
34
28
  };
35
- var checkSetup = function checkSetup(container) {
36
- var cardDiv = container.children[0];
29
+ const checkSetup = container => {
30
+ const cardDiv = container.children[0];
37
31
  expect(cardDiv.tagName).toEqual('DIV');
38
32
  expect(cardDiv.classList).toContain(_SummaryCard.DEFAULT_CLASS);
39
- var headerDiv = cardDiv.children[0];
33
+ const headerDiv = cardDiv.children[0];
40
34
  expect(headerDiv.tagName).toEqual('DIV');
41
35
  expect(headerDiv.classList).toContain(classes('header'));
42
- var headerContentDiv = headerDiv.children[0];
36
+ const headerContentDiv = headerDiv.children[0];
43
37
  expect(headerContentDiv.tagName).toEqual('DIV');
44
38
  expect(headerContentDiv.classList).toContain(classes('header-content'));
45
- var headerActionDiv = headerDiv.children[1];
39
+ const headerActionDiv = headerDiv.children[1];
46
40
  expect(headerActionDiv.tagName).toEqual('DIV');
47
41
  expect(headerActionDiv.className).toContain(classes('header-actions'));
48
- var bodyDiv = cardDiv.children[1];
42
+ const bodyDiv = cardDiv.children[1];
49
43
  expect(bodyDiv.tagName).toEqual('DIV');
50
44
  expect(bodyDiv.classList).toContain(classes('body'));
51
45
  return {
52
- cardDiv: cardDiv,
53
- headerDiv: headerDiv,
54
- headerContentDiv: headerContentDiv,
55
- headerActionDiv: headerActionDiv,
56
- bodyDiv: bodyDiv
46
+ cardDiv,
47
+ headerDiv,
48
+ headerContentDiv,
49
+ headerActionDiv,
50
+ bodyDiv
57
51
  };
58
52
  };
59
- it('should correctly render a SummaryCard component', function () {
60
- var CONFIG = {
53
+ it('should correctly render a SummaryCard component', () => {
54
+ const CONFIG = {
61
55
  banners: ['Alpha', 'Bravo'],
62
56
  title: 'Title text',
63
57
  details: 'Detail text'
64
58
  };
65
- var _renderWithValidation = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
66
- id: ID,
67
- entryData: ENTRY,
68
- config: CONFIG,
69
- parentCollectionName: "parent",
70
- pages: [],
71
- formData: {},
72
- masterPage: {
73
- childPages: []
74
- }
75
- })),
76
- container = _renderWithValidation.container;
77
- var _checkSetup = checkSetup(container),
78
- headerContentDiv = _checkSetup.headerContentDiv;
59
+ const {
60
+ container
61
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
62
+ id: ID,
63
+ entryData: ENTRY,
64
+ config: CONFIG,
65
+ parentCollectionName: "parent",
66
+ pages: [],
67
+ formData: {},
68
+ masterPage: {
69
+ childPages: []
70
+ }
71
+ }));
72
+ const {
73
+ headerContentDiv
74
+ } = checkSetup(container);
79
75
  expect(headerContentDiv.children.length).toEqual(3);
80
- var headerBanners = headerContentDiv.children[0];
76
+ const headerBanners = headerContentDiv.children[0];
81
77
  expect(headerBanners.tagName).toEqual('DIV');
82
78
  expect(headerBanners.classList).toContain(_BannerStrip.DEFAULT_CLASS);
83
- var headerTitle = headerContentDiv.children[1];
79
+ const headerTitle = headerContentDiv.children[1];
84
80
  expect(headerTitle.tagName).toEqual('DIV');
85
81
  expect(headerTitle.classList).toContain(classes('header-content-title'));
86
82
  expect(headerTitle.textContent).toEqual(CONFIG.title);
87
- var headerDetails = headerContentDiv.children[2];
83
+ const headerDetails = headerContentDiv.children[2];
88
84
  expect(headerDetails.tagName).toEqual('DIV');
89
85
  expect(headerDetails.classList).toContain(classes('header-content-detail'));
90
86
  expect(headerDetails.textContent).toEqual(CONFIG.details);
91
87
  });
92
- it('should not render a banner if none are supplied', function () {
93
- var CONFIG = {
88
+ it('should not render a banner if none are supplied', () => {
89
+ const CONFIG = {
94
90
  title: 'Title text',
95
91
  details: 'Detail text'
96
92
  };
97
- var _renderWithValidation2 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
98
- id: ID,
99
- entryData: ENTRY,
100
- config: CONFIG,
101
- parentCollectionName: "parent",
102
- pages: [],
103
- formData: {},
104
- masterPage: {
105
- childPages: []
106
- }
107
- })),
108
- container = _renderWithValidation2.container;
109
- var _checkSetup2 = checkSetup(container),
110
- headerContentDiv = _checkSetup2.headerContentDiv;
93
+ const {
94
+ container
95
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
96
+ id: ID,
97
+ entryData: ENTRY,
98
+ config: CONFIG,
99
+ parentCollectionName: "parent",
100
+ pages: [],
101
+ formData: {},
102
+ masterPage: {
103
+ childPages: []
104
+ }
105
+ }));
106
+ const {
107
+ headerContentDiv
108
+ } = checkSetup(container);
111
109
  expect(headerContentDiv.children.length).toEqual(2);
112
110
 
113
111
  // The only two children of the content div should be the title
114
112
  // and the details.
115
113
 
116
- var headerTitle = headerContentDiv.children[0];
114
+ const headerTitle = headerContentDiv.children[0];
117
115
  expect(headerTitle.tagName).toEqual('DIV');
118
116
  expect(headerTitle.classList).toContain(classes('header-content-title'));
119
117
  expect(headerTitle.textContent).toEqual(CONFIG.title);
120
- var headerDetails = headerContentDiv.children[1];
118
+ const headerDetails = headerContentDiv.children[1];
121
119
  expect(headerDetails.tagName).toEqual('DIV');
122
120
  expect(headerDetails.classList).toContain(classes('header-content-detail'));
123
121
  expect(headerDetails.textContent).toEqual(CONFIG.details);
124
122
  });
125
- it('should not render details if none are supplied', function () {
126
- var CONFIG = {
123
+ it('should not render details if none are supplied', () => {
124
+ const CONFIG = {
127
125
  banners: ['Alpha', 'Bravo'],
128
126
  title: 'Title text'
129
127
  };
130
- var _renderWithValidation3 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
131
- id: ID,
132
- entryData: ENTRY,
133
- config: CONFIG,
134
- parentCollectionName: "parent",
135
- pages: [],
136
- formData: {},
137
- masterPage: {
138
- childPages: []
139
- }
140
- })),
141
- container = _renderWithValidation3.container;
142
- var _checkSetup3 = checkSetup(container),
143
- headerContentDiv = _checkSetup3.headerContentDiv;
128
+ const {
129
+ container
130
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
131
+ id: ID,
132
+ entryData: ENTRY,
133
+ config: CONFIG,
134
+ parentCollectionName: "parent",
135
+ pages: [],
136
+ formData: {},
137
+ masterPage: {
138
+ childPages: []
139
+ }
140
+ }));
141
+ const {
142
+ headerContentDiv
143
+ } = checkSetup(container);
144
144
  expect(headerContentDiv.children.length).toEqual(2);
145
- var headerBanners = headerContentDiv.children[0];
145
+ const headerBanners = headerContentDiv.children[0];
146
146
  expect(headerBanners.tagName).toEqual('DIV');
147
147
  expect(headerBanners.classList).toContain(_BannerStrip.DEFAULT_CLASS);
148
148
 
149
149
  // The only two children of the content div should be the banner and
150
150
  // the title.
151
151
 
152
- var headerTitle = headerContentDiv.children[1];
152
+ const headerTitle = headerContentDiv.children[1];
153
153
  expect(headerTitle.tagName).toEqual('DIV');
154
154
  expect(headerTitle.classList).toContain(classes('header-content-title'));
155
155
  expect(headerTitle.textContent).toEqual(CONFIG.title);
156
156
  });
157
- it('should correctly interpolate the title', function () {
158
- var CONFIG = {
157
+ it('should correctly interpolate the title', () => {
158
+ const CONFIG = {
159
159
  // eslint-disable-next-line no-template-curly-in-string
160
160
  title: '${titleText} that is interpolated'
161
161
  };
162
- var _renderWithValidation4 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
163
- id: ID,
164
- entryData: ENTRY,
165
- config: CONFIG,
166
- parentCollectionName: "parent",
167
- pages: [],
168
- formData: {},
169
- masterPage: {
170
- childPages: []
171
- }
172
- })),
173
- container = _renderWithValidation4.container;
174
- var _checkSetup4 = checkSetup(container),
175
- headerContentDiv = _checkSetup4.headerContentDiv;
176
- var headerTitle = headerContentDiv.children[0];
162
+ const {
163
+ container
164
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
165
+ id: ID,
166
+ entryData: ENTRY,
167
+ config: CONFIG,
168
+ parentCollectionName: "parent",
169
+ pages: [],
170
+ formData: {},
171
+ masterPage: {
172
+ childPages: []
173
+ }
174
+ }));
175
+ const {
176
+ headerContentDiv
177
+ } = checkSetup(container);
178
+ const headerTitle = headerContentDiv.children[0];
177
179
  expect(headerTitle.tagName).toEqual('DIV');
178
180
  expect(headerTitle.classList).toContain(classes('header-content-title'));
179
181
  expect(headerTitle.textContent).toEqual("".concat(ENTRY.titleText, " that is interpolated"));
180
182
  });
181
- it('should correctly interpolate the details', function () {
182
- var CONFIG = {
183
+ it('should correctly interpolate the details', () => {
184
+ const CONFIG = {
183
185
  title: 'Title',
184
186
  // eslint-disable-next-line no-template-curly-in-string
185
187
  details: '${detailsText} that are interpolated'
186
188
  };
187
- var _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
188
- id: ID,
189
- entryData: ENTRY,
190
- config: CONFIG,
191
- parentCollectionName: "parent",
192
- pages: [],
193
- formData: {},
194
- masterPage: {
195
- childPages: []
196
- }
197
- })),
198
- container = _renderWithValidation5.container;
199
- var _checkSetup5 = checkSetup(container),
200
- headerContentDiv = _checkSetup5.headerContentDiv;
201
- var headerDetails = headerContentDiv.children[1];
189
+ const {
190
+ container
191
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
192
+ id: ID,
193
+ entryData: ENTRY,
194
+ config: CONFIG,
195
+ parentCollectionName: "parent",
196
+ pages: [],
197
+ formData: {},
198
+ masterPage: {
199
+ childPages: []
200
+ }
201
+ }));
202
+ const {
203
+ headerContentDiv
204
+ } = checkSetup(container);
205
+ const headerDetails = headerContentDiv.children[1];
202
206
  expect(headerDetails.tagName).toEqual('DIV');
203
207
  expect(headerDetails.classList).toContain(classes('header-content-detail'));
204
208
  expect(headerDetails.textContent).toEqual("".concat(ENTRY.detailsText, " that are interpolated"));
205
209
  });
206
- describe('Change action button', function () {
207
- var isDuplicatedValue = true;
208
- var onChangeArgs = [];
209
- var onChangeCalls = 0;
210
- var ON_CHANGE = function ON_CHANGE(page, id) {
210
+ describe('Change action button', () => {
211
+ let isDuplicatedValue = true;
212
+ let onChangeArgs = [];
213
+ let onChangeCalls = 0;
214
+ const ON_CHANGE = (page, id) => {
211
215
  onChangeArgs.push({
212
- page: page,
213
- id: id
216
+ page,
217
+ id
214
218
  });
215
219
  onChangeCalls += 1;
216
220
  isDuplicatedValue = false;
217
221
  };
218
- beforeEach(function () {
222
+ beforeEach(() => {
219
223
  onChangeArgs = [];
220
224
  onChangeCalls = 0;
221
225
  });
222
- it('should render correctly', function () {
223
- var CONFIG = {
226
+ it('should render correctly', () => {
227
+ const CONFIG = {
224
228
  changeAction: {
225
229
  label: 'Change label',
226
230
  page: 'testPage'
227
231
  }
228
232
  };
229
- var _renderWithValidation6 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
230
- id: ID,
231
- entryData: ENTRY,
232
- config: CONFIG,
233
- onChange: ON_CHANGE,
234
- parentCollectionName: "parent",
235
- pages: [],
236
- formData: {},
237
- masterPage: {
238
- childPages: []
239
- }
240
- })),
241
- container = _renderWithValidation6.container;
242
- var _checkSetup6 = checkSetup(container),
243
- headerActionDiv = _checkSetup6.headerActionDiv;
233
+ const {
234
+ container
235
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
236
+ id: ID,
237
+ entryData: ENTRY,
238
+ config: CONFIG,
239
+ onChange: ON_CHANGE,
240
+ parentCollectionName: "parent",
241
+ pages: [],
242
+ formData: {},
243
+ masterPage: {
244
+ childPages: []
245
+ }
246
+ }));
247
+ const {
248
+ headerActionDiv
249
+ } = checkSetup(container);
244
250
  expect(headerActionDiv.children.length).toEqual(1);
245
- var changeButton = headerActionDiv.children[0];
251
+ const changeButton = headerActionDiv.children[0];
246
252
  expect(changeButton.tagName).toEqual('BUTTON');
247
253
  expect(changeButton.textContent).toEqual(CONFIG.changeAction.label);
248
254
  _react.fireEvent.click(changeButton, {});
@@ -252,31 +258,33 @@ describe('components.CollectionSummary.SummaryCard', function () {
252
258
  id: ENTRY.id
253
259
  });
254
260
  });
255
- it('should render correctly when isDuplicated is true', function () {
256
- var CONFIG = {
261
+ it('should render correctly when isDuplicated is true', () => {
262
+ const CONFIG = {
257
263
  changeAction: {
258
264
  label: 'Change label',
259
265
  page: 'testPage'
260
266
  }
261
267
  };
262
- var _renderWithValidation7 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
263
- id: ID,
264
- entryData: ENTRY,
265
- config: CONFIG,
266
- onChange: ON_CHANGE,
267
- parentCollectionName: "parent",
268
- pages: [],
269
- formData: {},
270
- masterPage: {
271
- childPages: []
272
- },
273
- isDuplicated: isDuplicatedValue
274
- })),
275
- container = _renderWithValidation7.container;
276
- var _checkSetup7 = checkSetup(container),
277
- headerActionDiv = _checkSetup7.headerActionDiv;
268
+ const {
269
+ container
270
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
271
+ id: ID,
272
+ entryData: ENTRY,
273
+ config: CONFIG,
274
+ onChange: ON_CHANGE,
275
+ parentCollectionName: "parent",
276
+ pages: [],
277
+ formData: {},
278
+ masterPage: {
279
+ childPages: []
280
+ },
281
+ isDuplicated: isDuplicatedValue
282
+ }));
283
+ const {
284
+ headerActionDiv
285
+ } = checkSetup(container);
278
286
  expect(headerActionDiv.children.length).toEqual(1);
279
- var changeButton = headerActionDiv.children[0];
287
+ const changeButton = headerActionDiv.children[0];
280
288
  expect(changeButton.tagName).toEqual('BUTTON');
281
289
  expect(changeButton.textContent).toEqual(CONFIG.changeAction.label);
282
290
  _react.fireEvent.click(changeButton, {});
@@ -289,315 +297,338 @@ describe('components.CollectionSummary.SummaryCard', function () {
289
297
  // Check that the isDuplicated prop is now false
290
298
  expect(isDuplicatedValue).toBe(false);
291
299
  });
292
- it('should use the default label when one is not provided', function () {
293
- var CONFIG = {
300
+ it('should use the default label when one is not provided', () => {
301
+ const CONFIG = {
294
302
  changeAction: {
295
303
  page: 'testPage'
296
304
  }
297
305
  };
298
- var _renderWithValidation8 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
299
- id: ID,
300
- entryData: ENTRY,
301
- config: CONFIG,
302
- onChange: ON_CHANGE,
303
- parentCollectionName: "parent",
304
- pages: [],
305
- formData: {},
306
- masterPage: {
307
- childPages: []
308
- }
309
- })),
310
- container = _renderWithValidation8.container;
311
- var _checkSetup8 = checkSetup(container),
312
- headerActionDiv = _checkSetup8.headerActionDiv;
306
+ const {
307
+ container
308
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
309
+ id: ID,
310
+ entryData: ENTRY,
311
+ config: CONFIG,
312
+ onChange: ON_CHANGE,
313
+ parentCollectionName: "parent",
314
+ pages: [],
315
+ formData: {},
316
+ masterPage: {
317
+ childPages: []
318
+ }
319
+ }));
320
+ const {
321
+ headerActionDiv
322
+ } = checkSetup(container);
313
323
  expect(headerActionDiv.children.length).toEqual(1);
314
- var changeButton = headerActionDiv.children[0];
324
+ const changeButton = headerActionDiv.children[0];
315
325
  expect(changeButton.tagName).toEqual('BUTTON');
316
326
  expect(changeButton.textContent).toEqual(_SummaryCard.DEFAULT_CHANGE_BUTTON_LABEL);
317
327
  });
318
- it('should not render when no config is provided for it', function () {
319
- var _renderWithValidation9 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
320
- id: ID,
321
- entryData: ENTRY,
322
- config: {},
323
- onChange: ON_CHANGE,
324
- parentCollectionName: "parent",
325
- pages: [],
326
- formData: {},
327
- masterPage: {
328
- childPages: []
329
- }
330
- })),
331
- container = _renderWithValidation9.container;
332
- var _checkSetup9 = checkSetup(container),
333
- headerActionDiv = _checkSetup9.headerActionDiv;
328
+ it('should not render when no config is provided for it', () => {
329
+ const {
330
+ container
331
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
332
+ id: ID,
333
+ entryData: ENTRY,
334
+ config: {},
335
+ onChange: ON_CHANGE,
336
+ parentCollectionName: "parent",
337
+ pages: [],
338
+ formData: {},
339
+ masterPage: {
340
+ childPages: []
341
+ }
342
+ }));
343
+ const {
344
+ headerActionDiv
345
+ } = checkSetup(container);
334
346
  expect(headerActionDiv.children.length).toEqual(0);
335
347
  });
336
- it('should not render when onChange is not supplied', function () {
337
- var CONFIG = {
348
+ it('should not render when onChange is not supplied', () => {
349
+ const CONFIG = {
338
350
  changeAction: {
339
351
  label: 'Change label',
340
352
  page: 'testPage'
341
353
  }
342
354
  };
343
- var _renderWithValidation10 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
344
- id: ID,
345
- entryData: ENTRY,
346
- config: CONFIG,
347
- parentCollectionName: "parent",
348
- pages: [],
349
- formData: {},
350
- masterPage: {
351
- childPages: []
352
- }
353
- })),
354
- container = _renderWithValidation10.container;
355
- var _checkSetup10 = checkSetup(container),
356
- headerActionDiv = _checkSetup10.headerActionDiv;
355
+ const {
356
+ container
357
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
358
+ id: ID,
359
+ entryData: ENTRY,
360
+ config: CONFIG,
361
+ parentCollectionName: "parent",
362
+ pages: [],
363
+ formData: {},
364
+ masterPage: {
365
+ childPages: []
366
+ }
367
+ }));
368
+ const {
369
+ headerActionDiv
370
+ } = checkSetup(container);
357
371
  expect(headerActionDiv.children.length).toEqual(0);
358
372
  });
359
373
  });
360
- describe('Delete action button', function () {
361
- var onDeleteArgs = [];
362
- var onDeleteCalls = 0;
363
- var ON_DELETE = function ON_DELETE(entry) {
374
+ describe('Delete action button', () => {
375
+ let onDeleteArgs = [];
376
+ let onDeleteCalls = 0;
377
+ const ON_DELETE = entry => {
364
378
  onDeleteArgs.push(entry);
365
379
  onDeleteCalls += 1;
366
380
  };
367
- beforeEach(function () {
381
+ beforeEach(() => {
368
382
  onDeleteArgs = [];
369
383
  onDeleteCalls = 0;
370
384
  });
371
- it('should render correctly', function () {
372
- var CONFIG = {
385
+ it('should render correctly', () => {
386
+ const CONFIG = {
373
387
  deleteAction: {
374
388
  label: 'Delete label'
375
389
  }
376
390
  };
377
- var _renderWithValidation11 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
378
- id: ID,
379
- entryData: ENTRY,
380
- config: CONFIG,
381
- onDelete: ON_DELETE,
382
- parentCollectionName: "parent",
383
- pages: [],
384
- formData: {},
385
- masterPage: {
386
- childPages: []
387
- }
388
- })),
389
- container = _renderWithValidation11.container;
390
- var _checkSetup11 = checkSetup(container),
391
- headerActionDiv = _checkSetup11.headerActionDiv;
391
+ const {
392
+ container
393
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
394
+ id: ID,
395
+ entryData: ENTRY,
396
+ config: CONFIG,
397
+ onDelete: ON_DELETE,
398
+ parentCollectionName: "parent",
399
+ pages: [],
400
+ formData: {},
401
+ masterPage: {
402
+ childPages: []
403
+ }
404
+ }));
405
+ const {
406
+ headerActionDiv
407
+ } = checkSetup(container);
392
408
  expect(headerActionDiv.children.length).toEqual(1);
393
- var deleteButton = headerActionDiv.children[0];
409
+ const deleteButton = headerActionDiv.children[0];
394
410
  expect(deleteButton.tagName).toEqual('BUTTON');
395
411
  expect(deleteButton.textContent).toEqual(CONFIG.deleteAction.label);
396
412
  _react.fireEvent.click(deleteButton, {});
397
413
  expect(onDeleteCalls).toEqual(1);
398
414
  expect(onDeleteArgs[0]).toMatchObject(ENTRY);
399
415
  });
400
- it('should use the default label when one is not provided', function () {
401
- var CONFIG = {
416
+ it('should use the default label when one is not provided', () => {
417
+ const CONFIG = {
402
418
  deleteAction: {}
403
419
  };
404
- var _renderWithValidation12 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
405
- id: ID,
406
- entryData: ENTRY,
407
- config: CONFIG,
408
- onDelete: ON_DELETE,
409
- parentCollectionName: "parent",
410
- pages: [],
411
- formData: {},
412
- masterPage: {
413
- childPages: []
414
- }
415
- })),
416
- container = _renderWithValidation12.container;
417
- var _checkSetup12 = checkSetup(container),
418
- headerActionDiv = _checkSetup12.headerActionDiv;
420
+ const {
421
+ container
422
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
423
+ id: ID,
424
+ entryData: ENTRY,
425
+ config: CONFIG,
426
+ onDelete: ON_DELETE,
427
+ parentCollectionName: "parent",
428
+ pages: [],
429
+ formData: {},
430
+ masterPage: {
431
+ childPages: []
432
+ }
433
+ }));
434
+ const {
435
+ headerActionDiv
436
+ } = checkSetup(container);
419
437
  expect(headerActionDiv.children.length).toEqual(1);
420
- var deleteButton = headerActionDiv.children[0];
438
+ const deleteButton = headerActionDiv.children[0];
421
439
  expect(deleteButton.tagName).toEqual('BUTTON');
422
440
  expect(deleteButton.textContent).toEqual(_SummaryCard.DEFAULT_DELETE_BUTTON_LABEL);
423
441
  });
424
- it('should not render when no config is provided for it', function () {
425
- var _renderWithValidation13 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
426
- id: ID,
427
- entryData: ENTRY,
428
- config: {},
429
- onDelete: ON_DELETE,
430
- parentCollectionName: "parent",
431
- pages: [],
432
- formData: {},
433
- masterPage: {
434
- childPages: []
435
- }
436
- })),
437
- container = _renderWithValidation13.container;
438
- var _checkSetup13 = checkSetup(container),
439
- headerActionDiv = _checkSetup13.headerActionDiv;
442
+ it('should not render when no config is provided for it', () => {
443
+ const {
444
+ container
445
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
446
+ id: ID,
447
+ entryData: ENTRY,
448
+ config: {},
449
+ onDelete: ON_DELETE,
450
+ parentCollectionName: "parent",
451
+ pages: [],
452
+ formData: {},
453
+ masterPage: {
454
+ childPages: []
455
+ }
456
+ }));
457
+ const {
458
+ headerActionDiv
459
+ } = checkSetup(container);
440
460
  expect(headerActionDiv.children.length).toEqual(0);
441
461
  });
442
- it('should not render when onDelete is not supplied', function () {
443
- var CONFIG = {
462
+ it('should not render when onDelete is not supplied', () => {
463
+ const CONFIG = {
444
464
  deleteAction: {
445
465
  label: 'Delete label'
446
466
  }
447
467
  };
448
- var _renderWithValidation14 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
449
- id: ID,
450
- entryData: ENTRY,
451
- config: CONFIG,
452
- parentCollectionName: "parent",
453
- pages: [],
454
- formData: {},
455
- masterPage: {
456
- childPages: []
457
- }
458
- })),
459
- container = _renderWithValidation14.container;
460
- var _checkSetup14 = checkSetup(container),
461
- headerActionDiv = _checkSetup14.headerActionDiv;
468
+ const {
469
+ container
470
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
471
+ id: ID,
472
+ entryData: ENTRY,
473
+ config: CONFIG,
474
+ parentCollectionName: "parent",
475
+ pages: [],
476
+ formData: {},
477
+ masterPage: {
478
+ childPages: []
479
+ }
480
+ }));
481
+ const {
482
+ headerActionDiv
483
+ } = checkSetup(container);
462
484
  expect(headerActionDiv.children.length).toEqual(0);
463
485
  });
464
- it('should correctly render the Details section with entry data', function () {
465
- var CONFIG = {
486
+ it('should correctly render the Details section with entry data', () => {
487
+ const CONFIG = {
466
488
  deleteAction: {
467
489
  label: 'Delete label'
468
490
  }
469
491
  };
470
- var _renderWithValidation15 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
471
- id: ID,
472
- entryData: ENTRY,
473
- config: CONFIG,
474
- parentCollectionName: "parent",
475
- pages: [],
476
- formData: {},
477
- masterPage: {
478
- childPages: []
479
- }
480
- })),
481
- container = _renderWithValidation15.container;
482
- var detailsSection = container.querySelector('.details');
492
+ const {
493
+ container
494
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
495
+ id: ID,
496
+ entryData: ENTRY,
497
+ config: CONFIG,
498
+ parentCollectionName: "parent",
499
+ pages: [],
500
+ formData: {},
501
+ masterPage: {
502
+ childPages: []
503
+ }
504
+ }));
505
+ const detailsSection = container.querySelector('.details');
483
506
  expect(detailsSection).not.toBeNull();
484
507
  expect(detailsSection.textContent).toContain(ENTRY.summaryText);
485
508
  });
486
509
  });
487
- describe('Duplicate action button', function () {
488
- var onDuplicateArgs = [];
489
- var onDuplicateCalls = 0;
490
- var ON_DUPLICATE = function ON_DUPLICATE(entry) {
510
+ describe('Duplicate action button', () => {
511
+ let onDuplicateArgs = [];
512
+ let onDuplicateCalls = 0;
513
+ const ON_DUPLICATE = entry => {
491
514
  onDuplicateArgs.push(entry);
492
515
  onDuplicateCalls += 1;
493
516
  };
494
- beforeEach(function () {
517
+ beforeEach(() => {
495
518
  onDuplicateArgs = [];
496
519
  onDuplicateCalls = 0;
497
520
  });
498
- it('should render correctly', function () {
499
- var CONFIG = {
521
+ it('should render correctly', () => {
522
+ const CONFIG = {
500
523
  duplicateAction: {
501
524
  label: 'Duplicate label'
502
525
  }
503
526
  };
504
- var _renderWithValidation16 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
505
- id: ID,
506
- entryData: ENTRY,
507
- config: CONFIG,
508
- onDuplicate: ON_DUPLICATE,
509
- parentCollectionName: "parent",
510
- pages: [],
511
- formData: {},
512
- masterPage: {
513
- childPages: []
514
- }
515
- })),
516
- container = _renderWithValidation16.container;
517
- var _checkSetup15 = checkSetup(container),
518
- headerActionDiv = _checkSetup15.headerActionDiv;
527
+ const {
528
+ container
529
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
530
+ id: ID,
531
+ entryData: ENTRY,
532
+ config: CONFIG,
533
+ onDuplicate: ON_DUPLICATE,
534
+ parentCollectionName: "parent",
535
+ pages: [],
536
+ formData: {},
537
+ masterPage: {
538
+ childPages: []
539
+ }
540
+ }));
541
+ const {
542
+ headerActionDiv
543
+ } = checkSetup(container);
519
544
  expect(headerActionDiv.children.length).toEqual(1);
520
- var duplicateButton = headerActionDiv.children[0];
545
+ const duplicateButton = headerActionDiv.children[0];
521
546
  expect(duplicateButton.tagName).toEqual('BUTTON');
522
547
  expect(duplicateButton.textContent).toEqual(CONFIG.duplicateAction.label);
523
548
  _react.fireEvent.click(duplicateButton, {});
524
549
  expect(onDuplicateCalls).toEqual(1);
525
550
  expect(onDuplicateArgs[0]).toMatchObject(ENTRY);
526
551
  });
527
- it('should use the default label when one is not provided', function () {
528
- var CONFIG = {
552
+ it('should use the default label when one is not provided', () => {
553
+ const CONFIG = {
529
554
  duplicateAction: {}
530
555
  };
531
- var _renderWithValidation17 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
532
- id: ID,
533
- entryData: ENTRY,
534
- config: CONFIG,
535
- onDuplicate: ON_DUPLICATE,
536
- parentCollectionName: "parent",
537
- pages: [],
538
- formData: {},
539
- masterPage: {
540
- childPages: []
541
- }
542
- })),
543
- container = _renderWithValidation17.container;
544
- var _checkSetup16 = checkSetup(container),
545
- headerActionDiv = _checkSetup16.headerActionDiv;
556
+ const {
557
+ container
558
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
559
+ id: ID,
560
+ entryData: ENTRY,
561
+ config: CONFIG,
562
+ onDuplicate: ON_DUPLICATE,
563
+ parentCollectionName: "parent",
564
+ pages: [],
565
+ formData: {},
566
+ masterPage: {
567
+ childPages: []
568
+ }
569
+ }));
570
+ const {
571
+ headerActionDiv
572
+ } = checkSetup(container);
546
573
  expect(headerActionDiv.children.length).toEqual(1);
547
- var duplicateButton = headerActionDiv.children[0];
574
+ const duplicateButton = headerActionDiv.children[0];
548
575
  expect(duplicateButton.tagName).toEqual('BUTTON');
549
576
  expect(duplicateButton.textContent).toEqual(_SummaryCard.DEFAULT_DUPLICATE_BUTTON_LABEL);
550
577
  });
551
- it('should not render when no config is provided for it', function () {
552
- var _renderWithValidation18 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
553
- id: ID,
554
- entryData: ENTRY,
555
- config: {},
556
- onDuplicate: ON_DUPLICATE,
557
- parentCollectionName: "parent",
558
- pages: [],
559
- formData: {},
560
- masterPage: {
561
- childPages: []
562
- }
563
- })),
564
- container = _renderWithValidation18.container;
565
- var _checkSetup17 = checkSetup(container),
566
- headerActionDiv = _checkSetup17.headerActionDiv;
578
+ it('should not render when no config is provided for it', () => {
579
+ const {
580
+ container
581
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
582
+ id: ID,
583
+ entryData: ENTRY,
584
+ config: {},
585
+ onDuplicate: ON_DUPLICATE,
586
+ parentCollectionName: "parent",
587
+ pages: [],
588
+ formData: {},
589
+ masterPage: {
590
+ childPages: []
591
+ }
592
+ }));
593
+ const {
594
+ headerActionDiv
595
+ } = checkSetup(container);
567
596
  expect(headerActionDiv.children.length).toEqual(0);
568
597
  });
569
- it('should not render when onDuplicate is not supplied', function () {
570
- var CONFIG = {
598
+ it('should not render when onDuplicate is not supplied', () => {
599
+ const CONFIG = {
571
600
  duplicateAction: {
572
601
  label: 'Duplicate label'
573
602
  }
574
603
  };
575
- var _renderWithValidation19 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
576
- id: ID,
577
- entryData: ENTRY,
578
- config: CONFIG,
579
- parentCollectionName: "parent",
580
- pages: [],
581
- formData: {},
582
- masterPage: {
583
- childPages: []
584
- }
585
- })),
586
- container = _renderWithValidation19.container;
587
- var _checkSetup18 = checkSetup(container),
588
- headerActionDiv = _checkSetup18.headerActionDiv;
604
+ const {
605
+ container
606
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
607
+ id: ID,
608
+ entryData: ENTRY,
609
+ config: CONFIG,
610
+ parentCollectionName: "parent",
611
+ pages: [],
612
+ formData: {},
613
+ masterPage: {
614
+ childPages: []
615
+ }
616
+ }));
617
+ const {
618
+ headerActionDiv
619
+ } = checkSetup(container);
589
620
  expect(headerActionDiv.children.length).toEqual(0);
590
621
  });
591
622
  });
592
- describe('Quick Edit action button', function () {
593
- var CONFIG = {
623
+ describe('Quick Edit action button', () => {
624
+ const CONFIG = {
594
625
  quickEdit: {
595
626
  components: [{
596
627
  use: 'testText'
597
628
  }]
598
629
  }
599
630
  };
600
- var PAGES = [{
631
+ const PAGES = [{
601
632
  id: 'parentPage',
602
633
  name: 'parentPage',
603
634
  components: [{
@@ -619,26 +650,28 @@ describe('components.CollectionSummary.SummaryCard', function () {
619
650
  }]
620
651
  }
621
652
  }];
622
- it('should render correctly', function () {
623
- var _renderWithValidation20 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
624
- id: ID,
625
- entryData: ENTRY,
626
- config: CONFIG,
627
- pages: PAGES,
628
- parentCollectionName: "parent",
629
- formData: {},
630
- masterPage: {
631
- childPages: []
632
- },
633
- isDuplicated: true
634
- })),
635
- container = _renderWithValidation20.container;
636
- var _checkSetup19 = checkSetup(container),
637
- headerActionDiv = _checkSetup19.headerActionDiv;
653
+ it('should render correctly', () => {
654
+ const {
655
+ container
656
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
657
+ id: ID,
658
+ entryData: ENTRY,
659
+ config: CONFIG,
660
+ pages: PAGES,
661
+ parentCollectionName: "parent",
662
+ formData: {},
663
+ masterPage: {
664
+ childPages: []
665
+ },
666
+ isDuplicated: true
667
+ }));
668
+ const {
669
+ headerActionDiv
670
+ } = checkSetup(container);
638
671
  expect(headerActionDiv.children.length).toEqual(1);
639
672
 
640
673
  // Shows edit button but no quick edit
641
- var editButton = headerActionDiv.children[0];
674
+ const editButton = headerActionDiv.children[0];
642
675
  expect(editButton.tagName).toEqual('BUTTON');
643
676
  expect(editButton.textContent).toEqual('Quick Edit');
644
677
  expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
@@ -646,13 +679,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
646
679
  // shows quickedit once clicked
647
680
  _react.fireEvent.click(editButton, {});
648
681
  expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
649
- var quickEdit = container.childNodes[0].childNodes[1];
682
+ const quickEdit = container.childNodes[0].childNodes[1];
650
683
  expect(quickEdit.textContent).toContain('Test text');
651
684
 
652
685
  // quick edit has proper buttons
653
- var quickEditButtons = quickEdit.childNodes[2];
654
- var saveButton = quickEditButtons.childNodes[0];
655
- var cancelButton = quickEditButtons.childNodes[1];
686
+ const quickEditButtons = quickEdit.childNodes[2];
687
+ const saveButton = quickEditButtons.childNodes[0];
688
+ const cancelButton = quickEditButtons.childNodes[1];
656
689
  expect(saveButton.textContent).toContain('Save');
657
690
  expect(cancelButton.textContent).toContain('Cancel');
658
691
 
@@ -661,38 +694,40 @@ describe('components.CollectionSummary.SummaryCard', function () {
661
694
  expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
662
695
  });
663
696
 
664
- it('should not render when no config is provided for it', function () {
665
- var _renderWithValidation21 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
666
- id: ID,
667
- entryData: ENTRY,
668
- config: {},
669
- parentCollectionName: "parent",
670
- pages: [],
671
- formData: {},
672
- masterPage: {
673
- childPages: []
674
- },
675
- isDuplicated: true
676
- })),
677
- container = _renderWithValidation21.container;
678
- var _checkSetup20 = checkSetup(container),
679
- headerActionDiv = _checkSetup20.headerActionDiv;
697
+ it('should not render when no config is provided for it', () => {
698
+ const {
699
+ container
700
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
701
+ id: ID,
702
+ entryData: ENTRY,
703
+ config: {},
704
+ parentCollectionName: "parent",
705
+ pages: [],
706
+ formData: {},
707
+ masterPage: {
708
+ childPages: []
709
+ },
710
+ isDuplicated: true
711
+ }));
712
+ const {
713
+ headerActionDiv
714
+ } = checkSetup(container);
680
715
  expect(headerActionDiv.children.length).toEqual(0);
681
716
  });
682
717
  });
683
- describe('Quick Edit errors', function () {
684
- var CUSTOM_ENTRY = {
718
+ describe('Quick Edit errors', () => {
719
+ const CUSTOM_ENTRY = {
685
720
  id: '123',
686
721
  testText: 'value'
687
722
  };
688
- var CONFIG = {
723
+ const CONFIG = {
689
724
  quickEdit: {
690
725
  components: [{
691
726
  use: 'testText'
692
727
  }]
693
728
  }
694
729
  };
695
- var PAGES = [{
730
+ const PAGES = [{
696
731
  id: 'parentPage',
697
732
  name: 'parentPage',
698
733
  components: [{
@@ -716,34 +751,36 @@ describe('components.CollectionSummary.SummaryCard', function () {
716
751
  }]
717
752
  }
718
753
  }];
719
- it('should initally show errors passed in from top-level', function () {
720
- var TOP_LEVEL_ERRORS = [{
754
+ it('should initally show errors passed in from top-level', () => {
755
+ const TOP_LEVEL_ERRORS = [{
721
756
  id: 'testText',
722
757
  entryId: '123',
723
758
  error: 'top-level error message'
724
759
  }];
725
- var _renderWithValidation22 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
726
- entryId: CUSTOM_ENTRY.id,
727
- topLevelErrors: TOP_LEVEL_ERRORS
728
- }, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
729
- id: ID,
730
- entryData: CUSTOM_ENTRY,
731
- config: CONFIG,
732
- pages: PAGES,
733
- parentCollectionName: "parent",
734
- formData: {},
735
- masterPage: {
736
- childPages: []
737
- },
738
- isDuplicated: true
739
- }))),
740
- container = _renderWithValidation22.container;
741
- var _checkSetup21 = checkSetup(container),
742
- headerActionDiv = _checkSetup21.headerActionDiv;
760
+ const {
761
+ container
762
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
763
+ entryId: CUSTOM_ENTRY.id,
764
+ topLevelErrors: TOP_LEVEL_ERRORS
765
+ }, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
766
+ id: ID,
767
+ entryData: CUSTOM_ENTRY,
768
+ config: CONFIG,
769
+ pages: PAGES,
770
+ parentCollectionName: "parent",
771
+ formData: {},
772
+ masterPage: {
773
+ childPages: []
774
+ },
775
+ isDuplicated: true
776
+ })));
777
+ const {
778
+ headerActionDiv
779
+ } = checkSetup(container);
743
780
  expect(headerActionDiv.children.length).toEqual(1);
744
781
 
745
782
  // Shows edit button but no quick edit
746
- var editButton = headerActionDiv.children[0];
783
+ const editButton = headerActionDiv.children[0];
747
784
  expect(editButton.tagName).toEqual('BUTTON');
748
785
  expect(editButton.textContent).toEqual('Quick Edit');
749
786
  expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
@@ -751,114 +788,91 @@ describe('components.CollectionSummary.SummaryCard', function () {
751
788
  // shows quickedit once clicked
752
789
  _react.fireEvent.click(editButton, {});
753
790
  expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
754
- var quickEdit = container.childNodes[0].childNodes[1];
791
+ const quickEdit = container.childNodes[0].childNodes[1];
755
792
  expect(quickEdit.textContent).toContain('Test text');
756
793
 
757
794
  // quick edit is showing top-level error
758
- var errorSummary = quickEdit.childNodes[0];
795
+ const errorSummary = quickEdit.childNodes[0];
759
796
  expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
760
797
  });
761
- it('should only show errors from validation when it happens, ignoring top-level errors', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
762
- var TOP_LEVEL_ERRORS, _renderWithValidation23, container, _checkSetup22, headerActionDiv, editButton, quickEdit, errorSummary, component, componentInput, quickEditButtons, saveButton;
763
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
764
- while (1) switch (_context3.prev = _context3.next) {
765
- case 0:
766
- TOP_LEVEL_ERRORS = [{
767
- id: 'testText',
768
- entryId: '123',
769
- error: 'top-level error message'
770
- }];
771
- _renderWithValidation23 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
772
- entryId: CUSTOM_ENTRY.id,
773
- topLevelErrors: TOP_LEVEL_ERRORS
774
- }, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
775
- id: ID,
776
- entryData: CUSTOM_ENTRY,
777
- config: CONFIG,
778
- pages: PAGES,
779
- parentCollectionName: "parent",
780
- formData: {},
781
- masterPage: {
782
- childPages: []
783
- },
784
- onQuickEdit: function onQuickEdit() {},
785
- isDuplicated: true
786
- }))), container = _renderWithValidation23.container;
787
- _checkSetup22 = checkSetup(container), headerActionDiv = _checkSetup22.headerActionDiv;
788
- expect(headerActionDiv.children.length).toEqual(1);
798
+ it('should only show errors from validation when it happens, ignoring top-level errors', async () => {
799
+ const TOP_LEVEL_ERRORS = [{
800
+ id: 'testText',
801
+ entryId: '123',
802
+ error: 'top-level error message'
803
+ }];
804
+ const {
805
+ container
806
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
807
+ entryId: CUSTOM_ENTRY.id,
808
+ topLevelErrors: TOP_LEVEL_ERRORS
809
+ }, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
810
+ id: ID,
811
+ entryData: CUSTOM_ENTRY,
812
+ config: CONFIG,
813
+ pages: PAGES,
814
+ parentCollectionName: "parent",
815
+ formData: {},
816
+ masterPage: {
817
+ childPages: []
818
+ },
819
+ onQuickEdit: () => {},
820
+ isDuplicated: true
821
+ })));
822
+ const {
823
+ headerActionDiv
824
+ } = checkSetup(container);
825
+ expect(headerActionDiv.children.length).toEqual(1);
789
826
 
790
- // Shows edit button but no quick edit
791
- editButton = headerActionDiv.children[0];
792
- expect(editButton.tagName).toEqual('BUTTON');
793
- expect(editButton.textContent).toEqual('Quick Edit');
794
- expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
827
+ // Shows edit button but no quick edit
828
+ const editButton = headerActionDiv.children[0];
829
+ expect(editButton.tagName).toEqual('BUTTON');
830
+ expect(editButton.textContent).toEqual('Quick Edit');
831
+ expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
795
832
 
796
- // shows quickedit once clicked
797
- _react.fireEvent.click(editButton, {});
798
- expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
799
- quickEdit = container.childNodes[0].childNodes[1];
800
- expect(quickEdit.textContent).toContain('Test text');
833
+ // shows quickedit once clicked
834
+ _react.fireEvent.click(editButton, {});
835
+ expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
836
+ const quickEdit = container.childNodes[0].childNodes[1];
837
+ expect(quickEdit.textContent).toContain('Test text');
801
838
 
802
- // quick edit is initially showing top-level error
803
- errorSummary = quickEdit.childNodes[0];
804
- expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
839
+ // quick edit is initially showing top-level error
840
+ const errorSummary = quickEdit.childNodes[0];
841
+ expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
805
842
 
806
- // remove value from required text component
807
- component = quickEdit.childNodes[2];
808
- componentInput = component.childNodes[3];
809
- _context3.next = 18;
810
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
811
- return _regeneratorRuntime().wrap(function _callee$(_context) {
812
- while (1) switch (_context.prev = _context.next) {
813
- case 0:
814
- _react.fireEvent.change(componentInput, {
815
- target: {
816
- value: ''
817
- }
818
- });
819
- case 1:
820
- case "end":
821
- return _context.stop();
822
- }
823
- }, _callee);
824
- })));
825
- case 18:
826
- // click 'save' to trigger validation, which will fail as the component
827
- // cleared above is marked as 'required'.
828
- quickEditButtons = quickEdit.childNodes[3];
829
- saveButton = quickEditButtons.childNodes[0];
830
- expect(saveButton.textContent).toContain('Save');
831
- _context3.next = 23;
832
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
833
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
834
- while (1) switch (_context2.prev = _context2.next) {
835
- case 0:
836
- _react.fireEvent.click(saveButton, {});
837
- case 1:
838
- case "end":
839
- return _context2.stop();
840
- }
841
- }, _callee2);
842
- })));
843
- case 23:
844
- // quick edit should now be showing the errors from validation
845
- expect(errorSummary.textContent).toContain('Custom error message');
846
- case 24:
847
- case "end":
848
- return _context3.stop();
849
- }
850
- }, _callee3);
851
- })));
843
+ // remove value from required text component
844
+ const component = quickEdit.childNodes[2];
845
+ const componentInput = component.childNodes[3];
846
+ await (0, _testUtils.act)(async () => {
847
+ _react.fireEvent.change(componentInput, {
848
+ target: {
849
+ value: ''
850
+ }
851
+ });
852
+ });
853
+
854
+ // click 'save' to trigger validation, which will fail as the component
855
+ // cleared above is marked as 'required'.
856
+ const quickEditButtons = quickEdit.childNodes[3];
857
+ const saveButton = quickEditButtons.childNodes[0];
858
+ expect(saveButton.textContent).toContain('Save');
859
+ await (0, _testUtils.act)(async () => {
860
+ _react.fireEvent.click(saveButton, {});
861
+ });
862
+
863
+ // quick edit should now be showing the errors from validation
864
+ expect(errorSummary.textContent).toContain('Custom error message');
865
+ });
852
866
  });
853
- describe('Quick Edit save changes', function () {
854
- var CONFIG = {
867
+ describe('Quick Edit save changes', () => {
868
+ const CONFIG = {
855
869
  quickEdit: {
856
870
  components: [{
857
871
  use: 'testText'
858
872
  }]
859
873
  }
860
874
  };
861
- var PAGES = [{
875
+ const PAGES = [{
862
876
  id: 'parentPage',
863
877
  name: 'parentPage',
864
878
  components: [{
@@ -885,26 +899,28 @@ describe('components.CollectionSummary.SummaryCard', function () {
885
899
  }]
886
900
  }
887
901
  }];
888
- it('should render correctly', function () {
889
- var _renderWithValidation24 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
890
- id: ID,
891
- entryData: ENTRY,
892
- config: CONFIG,
893
- pages: PAGES,
894
- parentCollectionName: "parent",
895
- formData: {},
896
- masterPage: {
897
- childPages: []
898
- },
899
- isDuplicated: true
900
- })),
901
- container = _renderWithValidation24.container;
902
- var _checkSetup23 = checkSetup(container),
903
- headerActionDiv = _checkSetup23.headerActionDiv;
902
+ it('should render correctly', () => {
903
+ const {
904
+ container
905
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
906
+ id: ID,
907
+ entryData: ENTRY,
908
+ config: CONFIG,
909
+ pages: PAGES,
910
+ parentCollectionName: "parent",
911
+ formData: {},
912
+ masterPage: {
913
+ childPages: []
914
+ },
915
+ isDuplicated: true
916
+ }));
917
+ const {
918
+ headerActionDiv
919
+ } = checkSetup(container);
904
920
  expect(headerActionDiv.children.length).toEqual(1);
905
921
 
906
922
  // Shows edit button but no quick edit
907
- var editButton = headerActionDiv.children[0];
923
+ const editButton = headerActionDiv.children[0];
908
924
  expect(editButton.tagName).toEqual('BUTTON');
909
925
  expect(editButton.textContent).toEqual('Quick Edit');
910
926
  expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
@@ -912,13 +928,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
912
928
  // shows quickedit once clicked
913
929
  _react.fireEvent.click(editButton, {});
914
930
  expect(container.childNodes[0].childNodes.length).toEqual(3); // Quick edit shown
915
- var quickEdit = container.childNodes[0].childNodes[1];
931
+ const quickEdit = container.childNodes[0].childNodes[1];
916
932
  expect(quickEdit.textContent).toContain('Test text');
917
933
 
918
934
  // quick edit has proper buttons
919
- var quickEditButtons = quickEdit.childNodes[2];
920
- var saveButton = quickEditButtons.childNodes[0];
921
- var cancelButton = quickEditButtons.childNodes[1];
935
+ const quickEditButtons = quickEdit.childNodes[2];
936
+ const saveButton = quickEditButtons.childNodes[0];
937
+ const cancelButton = quickEditButtons.childNodes[1];
922
938
  expect(saveButton.textContent).toContain('Save');
923
939
  expect(cancelButton.textContent).toContain('Cancel');
924
940
 
@@ -927,405 +943,368 @@ describe('components.CollectionSummary.SummaryCard', function () {
927
943
  expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
928
944
  });
929
945
 
930
- it('should not validate or save if nothing has changed', function () {
931
- var ON_SUBMIT_CALLS = [];
932
- var hooks = {
933
- onSubmit: function onSubmit(type, patch) {
934
- return ON_SUBMIT_CALLS.push(patch);
935
- }
946
+ it('should not validate or save if nothing has changed', () => {
947
+ const ON_SUBMIT_CALLS = [];
948
+ const hooks = {
949
+ onSubmit: (type, patch) => ON_SUBMIT_CALLS.push(patch)
936
950
  };
937
- var _renderWithValidation25 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
938
- id: ID,
939
- entryData: ENTRY,
940
- config: CONFIG,
941
- pages: PAGES,
942
- parentCollectionName: "parents",
943
- formData: {},
944
- masterPage: {
945
- childPages: []
946
- },
947
- isDuplicated: true
948
- }), {
949
- hooks: hooks
950
- }),
951
- container = _renderWithValidation25.container;
952
- var _checkSetup24 = checkSetup(container),
953
- headerActionDiv = _checkSetup24.headerActionDiv;
951
+ const {
952
+ container
953
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
954
+ id: ID,
955
+ entryData: ENTRY,
956
+ config: CONFIG,
957
+ pages: PAGES,
958
+ parentCollectionName: "parents",
959
+ formData: {},
960
+ masterPage: {
961
+ childPages: []
962
+ },
963
+ isDuplicated: true
964
+ }), {
965
+ hooks
966
+ });
967
+ const {
968
+ headerActionDiv
969
+ } = checkSetup(container);
954
970
 
955
971
  // Shows edit button but no quick edit
956
- var editButton = headerActionDiv.children[0];
972
+ const editButton = headerActionDiv.children[0];
957
973
 
958
974
  // shows quickedit once clicked
959
975
  _react.fireEvent.click(editButton, {});
960
- var quickEdit = container.childNodes[0].childNodes[1];
961
- var quickEditButtons = quickEdit.childNodes[2];
962
- var saveButton = quickEditButtons.childNodes[0];
976
+ const quickEdit = container.childNodes[0].childNodes[1];
977
+ const quickEditButtons = quickEdit.childNodes[2];
978
+ const saveButton = quickEditButtons.childNodes[0];
963
979
  _react.fireEvent.click(saveButton, {});
964
980
  expect(ON_SUBMIT_CALLS.length).toEqual(0);
965
981
  });
966
- it('should return after local validation if errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
967
- var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation26, container, _checkSetup25, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
968
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
969
- while (1) switch (_context6.prev = _context6.next) {
970
- case 0:
971
- ON_SUBMIT_CALLS = [];
972
- hooks = {
973
- onSubmit: function onSubmit(type, patch) {
974
- return ON_SUBMIT_CALLS.push(patch);
975
- }
976
- };
977
- ON_QUICK_EDIT_CALLS = [];
978
- ON_QUICK_EDIT = function ON_QUICK_EDIT(_ref5) {
979
- var target = _ref5.target;
980
- ON_QUICK_EDIT_CALLS.push(target);
981
- };
982
- _renderWithValidation26 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
983
- id: ID,
984
- entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
985
- index: 0
986
- }),
987
- config: CONFIG,
988
- pages: PAGES,
989
- parentCollectionName: "parents",
990
- onQuickEdit: ON_QUICK_EDIT,
991
- formData: {
992
- parents: [{
993
- testText: 'hello'
994
- }]
995
- },
996
- masterPage: {
997
- childPages: []
998
- },
999
- isDuplicated: true
1000
- }), {
1001
- hooks: hooks
1002
- }), container = _renderWithValidation26.container;
1003
- _checkSetup25 = checkSetup(container), headerActionDiv = _checkSetup25.headerActionDiv;
1004
- editButton = headerActionDiv.children[0];
1005
- _react.fireEvent.click(editButton, {});
1006
- quickEdit = container.childNodes[0].childNodes[1];
1007
- component = quickEdit.childNodes[1];
1008
- componentInput = component.childNodes[2];
1009
- quickEditButtons = quickEdit.childNodes[2];
1010
- saveButton = quickEditButtons.childNodes[0]; // Field has validation to force the length of this field to be greater than 2 so this should fail
1011
- _context6.next = 15;
1012
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
1013
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1014
- while (1) switch (_context4.prev = _context4.next) {
1015
- case 0:
1016
- _react.fireEvent.change(componentInput, {
1017
- target: {
1018
- value: 'a'
1019
- }
1020
- });
1021
- case 1:
1022
- case "end":
1023
- return _context4.stop();
1024
- }
1025
- }, _callee4);
1026
- })));
1027
- case 15:
1028
- _context6.next = 17;
1029
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
1030
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1031
- while (1) switch (_context5.prev = _context5.next) {
1032
- case 0:
1033
- _react.fireEvent.click(saveButton, {});
1034
- case 1:
1035
- case "end":
1036
- return _context5.stop();
1037
- }
1038
- }, _callee5);
1039
- })));
1040
- case 17:
1041
- expect(ON_SUBMIT_CALLS.length).toEqual(0);
1042
- expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
1043
- case 19:
1044
- case "end":
1045
- return _context6.stop();
982
+ it('should return after local validation if errors are present', async () => {
983
+ const ON_SUBMIT_CALLS = [];
984
+ const hooks = {
985
+ onSubmit: (type, patch) => ON_SUBMIT_CALLS.push(patch)
986
+ };
987
+ const ON_QUICK_EDIT_CALLS = [];
988
+ const ON_QUICK_EDIT = _ref => {
989
+ let {
990
+ target
991
+ } = _ref;
992
+ ON_QUICK_EDIT_CALLS.push(target);
993
+ };
994
+ const {
995
+ container
996
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
997
+ id: ID,
998
+ entryData: {
999
+ ...ENTRY,
1000
+ index: 0
1001
+ },
1002
+ config: CONFIG,
1003
+ pages: PAGES,
1004
+ parentCollectionName: "parents",
1005
+ onQuickEdit: ON_QUICK_EDIT,
1006
+ formData: {
1007
+ parents: [{
1008
+ testText: 'hello'
1009
+ }]
1010
+ },
1011
+ masterPage: {
1012
+ childPages: []
1013
+ },
1014
+ isDuplicated: true
1015
+ }), {
1016
+ hooks
1017
+ });
1018
+ const {
1019
+ headerActionDiv
1020
+ } = checkSetup(container);
1021
+ const editButton = headerActionDiv.children[0];
1022
+ _react.fireEvent.click(editButton, {});
1023
+ const quickEdit = container.childNodes[0].childNodes[1];
1024
+ const component = quickEdit.childNodes[1];
1025
+ const componentInput = component.childNodes[2];
1026
+ const quickEditButtons = quickEdit.childNodes[2];
1027
+ const saveButton = quickEditButtons.childNodes[0];
1028
+ // Field has validation to force the length of this field to be greater than 2 so this should fail
1029
+ await (0, _testUtils.act)(async () => {
1030
+ _react.fireEvent.change(componentInput, {
1031
+ target: {
1032
+ value: 'a'
1033
+ }
1034
+ });
1035
+ });
1036
+ await (0, _testUtils.act)(async () => {
1037
+ _react.fireEvent.click(saveButton, {});
1038
+ });
1039
+ expect(ON_SUBMIT_CALLS.length).toEqual(0);
1040
+ expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
1041
+ });
1042
+ it('should run hook validation when a value changes and local validation is passed', async () => {
1043
+ const ON_SUBMIT_CALLS = [];
1044
+ const hooks = {
1045
+ onSubmit: (type, patch, notRequired, onError) => {
1046
+ ON_SUBMIT_CALLS.push(patch);
1047
+ onError([{
1048
+ error: 'message',
1049
+ id: '0'
1050
+ }]);
1046
1051
  }
1047
- }, _callee6);
1048
- })));
1049
- it('should run hook validation when a value changes and local validation is passed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1050
- var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation27, container, _checkSetup26, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
1051
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1052
- while (1) switch (_context8.prev = _context8.next) {
1053
- case 0:
1054
- ON_SUBMIT_CALLS = [];
1055
- hooks = {
1056
- onSubmit: function onSubmit(type, patch, notRequired, onError) {
1057
- ON_SUBMIT_CALLS.push(patch);
1058
- onError([{
1059
- error: 'message',
1060
- id: '0'
1061
- }]);
1062
- }
1063
- };
1064
- ON_QUICK_EDIT_CALLS = [];
1065
- ON_QUICK_EDIT = function ON_QUICK_EDIT(_ref9) {
1066
- var target = _ref9.target;
1067
- ON_QUICK_EDIT_CALLS.push(target);
1068
- };
1069
- _renderWithValidation27 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1070
- id: ID,
1071
- entryData: ENTRY,
1072
- config: CONFIG,
1073
- pages: PAGES,
1074
- parentCollectionName: "parents",
1075
- onQuickEdit: ON_QUICK_EDIT,
1076
- formData: {
1077
- parents: [{
1078
- alreadyProvidedField: 'hello'
1079
- }]
1080
- },
1081
- masterPage: {
1082
- childPages: []
1083
- },
1084
- isDuplicated: true
1085
- }), {
1086
- hooks: hooks
1087
- }), container = _renderWithValidation27.container;
1088
- _checkSetup26 = checkSetup(container), headerActionDiv = _checkSetup26.headerActionDiv;
1089
- editButton = headerActionDiv.children[0];
1090
- _react.fireEvent.click(editButton, {});
1091
- quickEdit = container.childNodes[0].childNodes[1]; // Make a change
1092
- component = quickEdit.childNodes[1];
1093
- componentInput = component.childNodes[2];
1094
- _react.fireEvent.change(componentInput, {
1095
- target: {
1096
- value: 'new value'
1097
- }
1098
- });
1099
- quickEditButtons = quickEdit.childNodes[2];
1100
- saveButton = quickEditButtons.childNodes[0];
1101
- _context8.next = 16;
1102
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1103
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1104
- while (1) switch (_context7.prev = _context7.next) {
1105
- case 0:
1106
- _react.fireEvent.click(saveButton, {});
1107
- case 1:
1108
- case "end":
1109
- return _context7.stop();
1110
- }
1111
- }, _callee7);
1112
- })));
1113
- case 16:
1114
- expect(ON_SUBMIT_CALLS[0]).toEqual({
1115
- testText: 'new value'
1116
- });
1117
- expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
1118
- case 18:
1119
- case "end":
1120
- return _context8.stop();
1052
+ };
1053
+ const ON_QUICK_EDIT_CALLS = [];
1054
+ const ON_QUICK_EDIT = _ref2 => {
1055
+ let {
1056
+ target
1057
+ } = _ref2;
1058
+ ON_QUICK_EDIT_CALLS.push(target);
1059
+ };
1060
+ const {
1061
+ container
1062
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1063
+ id: ID,
1064
+ entryData: ENTRY,
1065
+ config: CONFIG,
1066
+ pages: PAGES,
1067
+ parentCollectionName: "parents",
1068
+ onQuickEdit: ON_QUICK_EDIT,
1069
+ formData: {
1070
+ parents: [{
1071
+ alreadyProvidedField: 'hello'
1072
+ }]
1073
+ },
1074
+ masterPage: {
1075
+ childPages: []
1076
+ },
1077
+ isDuplicated: true
1078
+ }), {
1079
+ hooks
1080
+ });
1081
+ const {
1082
+ headerActionDiv
1083
+ } = checkSetup(container);
1084
+ const editButton = headerActionDiv.children[0];
1085
+ _react.fireEvent.click(editButton, {});
1086
+ const quickEdit = container.childNodes[0].childNodes[1];
1087
+
1088
+ // Make a change
1089
+ const component = quickEdit.childNodes[1];
1090
+ const componentInput = component.childNodes[2];
1091
+ _react.fireEvent.change(componentInput, {
1092
+ target: {
1093
+ value: 'new value'
1121
1094
  }
1122
- }, _callee8);
1123
- })));
1124
- it('should apply changes if no errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1125
- var isDuplicatedValue, ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation28, container, _checkSetup27, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
1126
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1127
- while (1) switch (_context10.prev = _context10.next) {
1128
- case 0:
1129
- isDuplicatedValue = true;
1130
- ON_SUBMIT_CALLS = [];
1131
- hooks = {
1132
- onSubmit: function onSubmit(type, patch) {
1133
- return ON_SUBMIT_CALLS.push(patch);
1134
- }
1135
- };
1136
- ON_QUICK_EDIT_CALLS = [];
1137
- ON_QUICK_EDIT = function ON_QUICK_EDIT(_ref12) {
1138
- var target = _ref12.target;
1139
- ON_QUICK_EDIT_CALLS.push(target);
1140
- isDuplicatedValue = false;
1141
- };
1142
- _renderWithValidation28 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1143
- id: ID,
1144
- entryData: {
1145
- index: 0,
1146
- id: '0'
1147
- },
1148
- config: CONFIG,
1149
- pages: PAGES,
1150
- parentCollectionName: "parents",
1151
- onQuickEdit: ON_QUICK_EDIT,
1152
- formData: {
1153
- parents: [{
1154
- alreadyProvidedField: 'hello'
1155
- }]
1156
- },
1157
- masterPage: {
1158
- childPages: []
1159
- },
1160
- isDuplicated: isDuplicatedValue
1161
- }), {
1162
- hooks: hooks
1163
- }), container = _renderWithValidation28.container;
1164
- _checkSetup27 = checkSetup(container), headerActionDiv = _checkSetup27.headerActionDiv;
1165
- editButton = headerActionDiv.children[0];
1166
- _react.fireEvent.click(editButton, {});
1167
- quickEdit = container.childNodes[0].childNodes[1]; // Make a change that will be accepted
1168
- component = quickEdit.childNodes[1];
1169
- componentInput = component.childNodes[2];
1170
- _react.fireEvent.change(componentInput, {
1171
- target: {
1172
- value: 'new value'
1173
- }
1174
- });
1175
- quickEditButtons = quickEdit.childNodes[2];
1176
- saveButton = quickEditButtons.childNodes[0];
1177
- _context10.next = 17;
1178
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1179
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1180
- while (1) switch (_context9.prev = _context9.next) {
1181
- case 0:
1182
- _react.fireEvent.click(saveButton, {});
1183
- case 1:
1184
- case "end":
1185
- return _context9.stop();
1186
- }
1187
- }, _callee9);
1188
- })));
1189
- case 17:
1190
- expect(ON_QUICK_EDIT_CALLS.length).toEqual(1);
1191
- expect(ON_QUICK_EDIT_CALLS[0].value[0]).toEqual({
1192
- alreadyProvidedField: 'hello',
1193
- testText: 'new value'
1194
- });
1095
+ });
1096
+ const quickEditButtons = quickEdit.childNodes[2];
1097
+ const saveButton = quickEditButtons.childNodes[0];
1098
+ await (0, _testUtils.act)(async () => {
1099
+ _react.fireEvent.click(saveButton, {});
1100
+ });
1101
+ expect(ON_SUBMIT_CALLS[0]).toEqual({
1102
+ testText: 'new value'
1103
+ });
1104
+ expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
1105
+ });
1106
+ it('should apply changes if no errors are present', async () => {
1107
+ let isDuplicatedValue = true;
1108
+ const ON_SUBMIT_CALLS = [];
1109
+ const hooks = {
1110
+ onSubmit: (type, patch) => ON_SUBMIT_CALLS.push(patch)
1111
+ };
1112
+ const ON_QUICK_EDIT_CALLS = [];
1113
+ const ON_QUICK_EDIT = _ref3 => {
1114
+ let {
1115
+ target
1116
+ } = _ref3;
1117
+ ON_QUICK_EDIT_CALLS.push(target);
1118
+ isDuplicatedValue = false;
1119
+ };
1120
+ const {
1121
+ container
1122
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1123
+ id: ID,
1124
+ entryData: {
1125
+ index: 0,
1126
+ id: '0'
1127
+ },
1128
+ config: CONFIG,
1129
+ pages: PAGES,
1130
+ parentCollectionName: "parents",
1131
+ onQuickEdit: ON_QUICK_EDIT,
1132
+ formData: {
1133
+ parents: [{
1134
+ alreadyProvidedField: 'hello'
1135
+ }]
1136
+ },
1137
+ masterPage: {
1138
+ childPages: []
1139
+ },
1140
+ isDuplicated: isDuplicatedValue
1141
+ }), {
1142
+ hooks
1143
+ });
1144
+ const {
1145
+ headerActionDiv
1146
+ } = checkSetup(container);
1147
+ const editButton = headerActionDiv.children[0];
1148
+ _react.fireEvent.click(editButton, {});
1149
+ const quickEdit = container.childNodes[0].childNodes[1];
1195
1150
 
1196
- // Check that the isDuplicated prop is now false
1197
- expect(isDuplicatedValue).toBe(false);
1198
- case 20:
1199
- case "end":
1200
- return _context10.stop();
1151
+ // Make a change that will be accepted
1152
+ const component = quickEdit.childNodes[1];
1153
+ const componentInput = component.childNodes[2];
1154
+ _react.fireEvent.change(componentInput, {
1155
+ target: {
1156
+ value: 'new value'
1201
1157
  }
1202
- }, _callee10);
1203
- })));
1158
+ });
1159
+ const quickEditButtons = quickEdit.childNodes[2];
1160
+ const saveButton = quickEditButtons.childNodes[0];
1161
+ await (0, _testUtils.act)(async () => {
1162
+ _react.fireEvent.click(saveButton, {});
1163
+ });
1164
+ expect(ON_QUICK_EDIT_CALLS.length).toEqual(1);
1165
+ expect(ON_QUICK_EDIT_CALLS[0].value[0]).toEqual({
1166
+ alreadyProvidedField: 'hello',
1167
+ testText: 'new value'
1168
+ });
1169
+
1170
+ // Check that the isDuplicated prop is now false
1171
+ expect(isDuplicatedValue).toBe(false);
1172
+ });
1204
1173
  });
1205
- describe('Details prop behavior', function () {
1206
- it('should render the provided details', function () {
1207
- var DETAILS = 'Sample details';
1208
- var CONFIG = {
1174
+ describe('Details prop behavior', () => {
1175
+ it('should render the provided details', () => {
1176
+ const DETAILS = 'Sample details';
1177
+ const CONFIG = {
1209
1178
  title: 'Title',
1210
1179
  details: DETAILS
1211
1180
  };
1212
- var _renderWithValidation29 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1213
- id: ID,
1214
- entryData: ENTRY,
1215
- config: CONFIG,
1216
- parentCollectionName: "parent",
1217
- pages: [],
1218
- formData: {},
1219
- masterPage: {
1220
- childPages: []
1221
- }
1222
- })),
1223
- container = _renderWithValidation29.container;
1224
- var _checkSetup28 = checkSetup(container),
1225
- headerContentDiv = _checkSetup28.headerContentDiv;
1226
- var headerDetails = headerContentDiv.children[1];
1181
+ const {
1182
+ container
1183
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1184
+ id: ID,
1185
+ entryData: ENTRY,
1186
+ config: CONFIG,
1187
+ parentCollectionName: "parent",
1188
+ pages: [],
1189
+ formData: {},
1190
+ masterPage: {
1191
+ childPages: []
1192
+ }
1193
+ }));
1194
+ const {
1195
+ headerContentDiv
1196
+ } = checkSetup(container);
1197
+ const headerDetails = headerContentDiv.children[1];
1227
1198
  expect(headerDetails.tagName).toEqual('DIV');
1228
1199
  expect(headerDetails.classList).toContain(classes('header-content-detail'));
1229
1200
  expect(headerDetails.textContent).toEqual(DETAILS);
1230
1201
  });
1231
- it('should not render details when they are empty', function () {
1232
- var CONFIG = {
1202
+ it('should not render details when they are empty', () => {
1203
+ const CONFIG = {
1233
1204
  title: 'Title',
1234
1205
  details: ''
1235
1206
  };
1236
- var _renderWithValidation30 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1237
- id: ID,
1238
- entryData: ENTRY,
1239
- config: CONFIG,
1240
- parentCollectionName: "parent",
1241
- pages: [],
1242
- formData: {},
1243
- masterPage: {
1244
- childPages: []
1245
- }
1246
- })),
1247
- container = _renderWithValidation30.container;
1248
- var _checkSetup29 = checkSetup(container),
1249
- headerContentDiv = _checkSetup29.headerContentDiv;
1207
+ const {
1208
+ container
1209
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1210
+ id: ID,
1211
+ entryData: ENTRY,
1212
+ config: CONFIG,
1213
+ parentCollectionName: "parent",
1214
+ pages: [],
1215
+ formData: {},
1216
+ masterPage: {
1217
+ childPages: []
1218
+ }
1219
+ }));
1220
+ const {
1221
+ headerContentDiv
1222
+ } = checkSetup(container);
1250
1223
  // If no details are provided, we expect only the header title to be rendered.
1251
1224
  expect(headerContentDiv.children.length).toEqual(1);
1252
- var headerTitle = headerContentDiv.children[0];
1225
+ const headerTitle = headerContentDiv.children[0];
1253
1226
  expect(headerTitle.classList).toContain(classes('header-content-title'));
1254
1227
  });
1255
- it('should render the interpolated details', function () {
1256
- var DETAILS = 'Full {label}';
1257
- var INTERPOLATED_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
1228
+ it('should render the interpolated details', () => {
1229
+ const DETAILS = 'Full {label}';
1230
+ const INTERPOLATED_ENTRY = {
1231
+ ...ENTRY,
1258
1232
  label: 'Details'
1259
- });
1260
- var CONFIG = {
1233
+ };
1234
+ const CONFIG = {
1261
1235
  title: 'Title',
1262
1236
  details: DETAILS
1263
1237
  };
1264
- var _renderWithValidation31 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1265
- id: ID,
1266
- entryData: INTERPOLATED_ENTRY,
1267
- config: CONFIG,
1268
- parentCollectionName: "parent",
1269
- pages: [],
1270
- formData: {},
1271
- masterPage: {
1272
- childPages: []
1273
- }
1274
- })),
1275
- container = _renderWithValidation31.container;
1276
- var _checkSetup30 = checkSetup(container),
1277
- headerContentDiv = _checkSetup30.headerContentDiv;
1278
- var headerDetails = headerContentDiv.children[1];
1279
- var expectedInterpolatedString = _copReactComponents.Utils.interpolateString(DETAILS, INTERPOLATED_ENTRY);
1238
+ const {
1239
+ container
1240
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1241
+ id: ID,
1242
+ entryData: INTERPOLATED_ENTRY,
1243
+ config: CONFIG,
1244
+ parentCollectionName: "parent",
1245
+ pages: [],
1246
+ formData: {},
1247
+ masterPage: {
1248
+ childPages: []
1249
+ }
1250
+ }));
1251
+ const {
1252
+ headerContentDiv
1253
+ } = checkSetup(container);
1254
+ const headerDetails = headerContentDiv.children[1];
1255
+ const expectedInterpolatedString = _copReactComponents.Utils.interpolateString(DETAILS, INTERPOLATED_ENTRY);
1280
1256
  expect(headerDetails.textContent).toEqual(expectedInterpolatedString);
1281
1257
  });
1282
- it('should not render the details div if config.details is not provided', function () {
1283
- var CONFIG = {
1258
+ it('should not render the details div if config.details is not provided', () => {
1259
+ const CONFIG = {
1284
1260
  title: 'Title'
1285
1261
  };
1286
- var _renderWithValidation32 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1287
- id: ID,
1288
- entryData: ENTRY,
1289
- config: CONFIG,
1290
- parentCollectionName: "parent",
1291
- pages: [],
1292
- formData: {},
1293
- masterPage: {
1294
- childPages: []
1295
- }
1296
- })),
1297
- container = _renderWithValidation32.container;
1298
- var _checkSetup31 = checkSetup(container),
1299
- headerContentDiv = _checkSetup31.headerContentDiv;
1300
- var headerDetails = headerContentDiv.querySelector("#".concat(ID, ".titleDetail"));
1262
+ const {
1263
+ container
1264
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1265
+ id: ID,
1266
+ entryData: ENTRY,
1267
+ config: CONFIG,
1268
+ parentCollectionName: "parent",
1269
+ pages: [],
1270
+ formData: {},
1271
+ masterPage: {
1272
+ childPages: []
1273
+ }
1274
+ }));
1275
+ const {
1276
+ headerContentDiv
1277
+ } = checkSetup(container);
1278
+ const headerDetails = headerContentDiv.querySelector("#".concat(ID, ".titleDetail"));
1301
1279
  expect(headerDetails).toBeNull();
1302
1280
  });
1303
- it('should not render the entire details section when hideDetails prop is true', function () {
1304
- var DETAILS = 'Sample details that should not be displayed';
1305
- var CONFIG = {
1281
+ it('should not render the entire details section when hideDetails prop is true', () => {
1282
+ const DETAILS = 'Sample details that should not be displayed';
1283
+ const CONFIG = {
1306
1284
  title: 'Title',
1307
1285
  details: DETAILS
1308
1286
  };
1309
- var _renderWithValidation33 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1310
- id: ID,
1311
- entryData: ENTRY,
1312
- config: CONFIG,
1313
- parentCollectionName: "parent",
1314
- pages: [],
1315
- formData: {},
1316
- hideDetails: true,
1317
- masterPage: {
1318
- childPages: []
1319
- }
1320
- })),
1321
- container = _renderWithValidation33.container;
1322
- var detailsComponent = container.querySelector('.details');
1287
+ const {
1288
+ container
1289
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1290
+ id: ID,
1291
+ entryData: ENTRY,
1292
+ config: CONFIG,
1293
+ parentCollectionName: "parent",
1294
+ pages: [],
1295
+ formData: {},
1296
+ hideDetails: true,
1297
+ masterPage: {
1298
+ childPages: []
1299
+ }
1300
+ }));
1301
+ const detailsComponent = container.querySelector('.details');
1323
1302
  expect(detailsComponent).toBeNull();
1324
1303
  });
1325
1304
  });
1326
- describe('SummaryLayout config behavior', function () {
1327
- it('should render sections and fields based on summaryLayout config', function () {
1328
- var CHILD_PAGE_SAMPLE = [{
1305
+ describe('SummaryLayout config behavior', () => {
1306
+ it('should render sections and fields based on summaryLayout config', () => {
1307
+ const CHILD_PAGE_SAMPLE = [{
1329
1308
  summaryLayout: {
1330
1309
  sections: [{
1331
1310
  title: 'Section 1',
@@ -1345,40 +1324,39 @@ describe('components.CollectionSummary.SummaryCard', function () {
1345
1324
  fieldId: 'fieldC'
1346
1325
  }]
1347
1326
  }];
1348
- var CONFIG = {
1327
+ const CONFIG = {
1349
1328
  title: 'Title'
1350
1329
  };
1351
- var _renderWithValidation34 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1352
- id: ID,
1353
- entryData: ENTRY,
1354
- config: CONFIG,
1355
- parentCollectionName: "parent",
1356
- pages: CHILD_PAGE_SAMPLE,
1357
- formData: {},
1358
- masterPage: {
1359
- childPages: []
1360
- }
1361
- })),
1362
- container = _renderWithValidation34.container;
1330
+ const {
1331
+ container
1332
+ } = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1333
+ id: ID,
1334
+ entryData: ENTRY,
1335
+ config: CONFIG,
1336
+ parentCollectionName: "parent",
1337
+ pages: CHILD_PAGE_SAMPLE,
1338
+ formData: {},
1339
+ masterPage: {
1340
+ childPages: []
1341
+ }
1342
+ }));
1363
1343
 
1364
1344
  // Function to find an element by its text content
1365
1345
  function getByTextContent(parent, text) {
1366
- return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
1367
- return el.textContent === text;
1368
- });
1346
+ return Array.from(parent.getElementsByClassName(classes('section-title'))).find(el => el.textContent === text);
1369
1347
  }
1370
1348
 
1371
1349
  // Check for section titles
1372
- var section1Title = getByTextContent(container, 'Section 1');
1373
- var section2Title = getByTextContent(container, 'Section 2');
1350
+ const section1Title = getByTextContent(container, 'Section 1');
1351
+ const section2Title = getByTextContent(container, 'Section 2');
1374
1352
  expect(section1Title).not.toBeNull();
1375
1353
  expect(section2Title).not.toBeNull();
1376
1354
  if (section1Title) {
1377
- var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
1355
+ const section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
1378
1356
  expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
1379
1357
  }
1380
1358
  if (section2Title) {
1381
- var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
1359
+ const section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
1382
1360
  expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
1383
1361
  }
1384
1362
  });