@ukhomeoffice/cop-react-form-renderer 4.18.0 → 5.0.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +1 -14
  2. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +19 -57
  3. package/dist/components/CheckYourAnswers/index.js +0 -3
  4. package/dist/components/CollectionPage/CollectionPage.js +8 -38
  5. package/dist/components/CollectionPage/index.js +0 -3
  6. package/dist/components/FormComponent/Collection.js +13 -54
  7. package/dist/components/FormComponent/Container.js +6 -30
  8. package/dist/components/FormComponent/FormComponent.js +14 -57
  9. package/dist/components/FormComponent/helpers/addLabel.js +4 -7
  10. package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
  11. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
  12. package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
  13. package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
  14. package/dist/components/FormComponent/helpers/index.js +0 -4
  15. package/dist/components/FormComponent/index.js +0 -3
  16. package/dist/components/FormPage/FormPage.js +14 -45
  17. package/dist/components/FormPage/index.js +0 -3
  18. package/dist/components/FormRenderer/FormRenderer.js +106 -189
  19. package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
  20. package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
  21. package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
  22. package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
  23. package/dist/components/FormRenderer/handlers/index.js +0 -5
  24. package/dist/components/FormRenderer/handlers/navigate.js +0 -5
  25. package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
  26. package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
  27. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
  28. package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
  29. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
  30. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +0 -5
  31. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
  32. package/dist/components/FormRenderer/helpers/getCYA.js +0 -6
  33. package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
  34. package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
  35. package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
  36. package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
  37. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
  38. package/dist/components/FormRenderer/helpers/getPage.js +0 -5
  39. package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
  40. package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
  41. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
  42. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
  43. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +0 -6
  44. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +6 -20
  45. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +3 -8
  46. package/dist/components/FormRenderer/helpers/index.js +1 -11
  47. package/dist/components/FormRenderer/index.js +0 -3
  48. package/dist/components/PageActions/ActionButton.js +2 -17
  49. package/dist/components/PageActions/PageActions.js +3 -10
  50. package/dist/components/PageActions/index.js +0 -3
  51. package/dist/components/SummaryList/GroupAction.js +3 -24
  52. package/dist/components/SummaryList/RowAction.js +3 -23
  53. package/dist/components/SummaryList/SummaryList.js +6 -28
  54. package/dist/components/SummaryList/SummaryListRow.js +4 -8
  55. package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
  56. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
  57. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
  58. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
  59. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
  60. package/dist/components/SummaryList/helpers/index.js +0 -2
  61. package/dist/components/SummaryList/index.js +0 -3
  62. package/dist/components/TaskList/Task.js +7 -29
  63. package/dist/components/TaskList/TaskList.js +12 -33
  64. package/dist/components/TaskList/TaskState.js +2 -10
  65. package/dist/components/TaskList/index.js +0 -3
  66. package/dist/components/index.js +0 -6
  67. package/dist/context/HooksContext/HooksContext.js +14 -34
  68. package/dist/context/HooksContext/index.js +0 -5
  69. package/dist/context/ValidationContext/ValidationContext.js +8 -34
  70. package/dist/context/ValidationContext/index.js +0 -5
  71. package/dist/context/index.js +0 -3
  72. package/dist/hooks/index.js +0 -9
  73. package/dist/hooks/useAxios.js +8 -25
  74. package/dist/hooks/useGetRequest.js +13 -47
  75. package/dist/hooks/useHooks.js +2 -4
  76. package/dist/hooks/useRefData.js +8 -37
  77. package/dist/hooks/useValidation.js +2 -4
  78. package/dist/index.js +0 -6
  79. package/dist/models/PageAction.js +0 -3
  80. package/dist/models/TaskStates.js +0 -3
  81. package/dist/models/index.js +0 -9
  82. package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
  83. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +0 -10
  84. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +0 -8
  85. package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
  86. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +2 -20
  87. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +0 -18
  88. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +0 -20
  89. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +0 -13
  90. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
  91. package/dist/utils/CheckYourAnswers/index.js +1 -3
  92. package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -11
  93. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +0 -11
  94. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
  95. package/dist/utils/CollectionPage/index.js +1 -5
  96. package/dist/utils/CollectionPage/mergeCollectionPages.js +1 -12
  97. package/dist/utils/Component/cleanAttributes.js +1 -8
  98. package/dist/utils/Component/elevateNestedComponents.js +0 -3
  99. package/dist/utils/Component/getComponent.js +4 -68
  100. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
  101. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +10 -28
  102. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +6 -33
  103. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +10 -27
  104. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
  105. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +4 -21
  106. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +4 -22
  107. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
  108. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
  109. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
  110. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +6 -15
  111. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +4 -21
  112. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +6 -33
  113. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +4 -21
  114. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +4 -21
  115. package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +4 -21
  116. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +10 -29
  117. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
  118. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
  119. package/dist/utils/Component/getDefaultValue.js +0 -7
  120. package/dist/utils/Component/index.js +0 -9
  121. package/dist/utils/Component/isEditable.js +1 -4
  122. package/dist/utils/Component/showComponent.js +1 -8
  123. package/dist/utils/Component/wrapInFormGroup.js +0 -7
  124. package/dist/utils/Condition/index.js +0 -5
  125. package/dist/utils/Condition/meetsAllConditions.js +0 -9
  126. package/dist/utils/Condition/meetsCondition.js +7 -19
  127. package/dist/utils/Condition/meetsOneCondition.js +1 -9
  128. package/dist/utils/Condition/setupConditions.js +0 -12
  129. package/dist/utils/Container/getEditableComponents.js +0 -7
  130. package/dist/utils/Container/index.js +0 -5
  131. package/dist/utils/Container/setupNesting.js +0 -11
  132. package/dist/utils/Container/showContainer.js +9 -18
  133. package/dist/utils/Data/applyFormula.js +2 -28
  134. package/dist/utils/Data/getAutocompleteSource.js +1 -4
  135. package/dist/utils/Data/getDataPath.js +3 -17
  136. package/dist/utils/Data/getOptions.js +0 -9
  137. package/dist/utils/Data/getSourceData.js +4 -19
  138. package/dist/utils/Data/index.js +1 -11
  139. package/dist/utils/Data/refDataToOptions.js +1 -12
  140. package/dist/utils/Data/setDataItem.js +0 -5
  141. package/dist/utils/Data/setupFormData.js +2 -20
  142. package/dist/utils/Data/setupRefDataUrlForComponent.js +0 -14
  143. package/dist/utils/FormPage/getFormPage.js +0 -15
  144. package/dist/utils/FormPage/getFormPages.js +0 -8
  145. package/dist/utils/FormPage/getPageActions.js +3 -18
  146. package/dist/utils/FormPage/getParagraphFromText.js +0 -3
  147. package/dist/utils/FormPage/index.js +0 -6
  148. package/dist/utils/FormPage/showFormPage.js +9 -18
  149. package/dist/utils/FormPage/showFormPageCYA.js +0 -5
  150. package/dist/utils/FormPage/useComponent.js +3 -18
  151. package/dist/utils/Format/formatData.js +0 -5
  152. package/dist/utils/Format/formatDataForComponent.js +1 -6
  153. package/dist/utils/Format/formatDataForForm.js +0 -8
  154. package/dist/utils/Format/formatDataForPage.js +1 -5
  155. package/dist/utils/Format/index.js +1 -6
  156. package/dist/utils/Hub/getFormHub.js +0 -8
  157. package/dist/utils/Hub/index.js +1 -3
  158. package/dist/utils/Meta/documents/getDocuments.js +1 -4
  159. package/dist/utils/Meta/documents/getDocuments.test.js +0 -9
  160. package/dist/utils/Meta/documents/index.js +1 -5
  161. package/dist/utils/Meta/documents/setDocumentForField.js +0 -11
  162. package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -11
  163. package/dist/utils/Meta/index.js +2 -6
  164. package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
  165. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
  166. package/dist/utils/Operate/index.js +0 -3
  167. package/dist/utils/Operate/persistValueInFormData.js +1 -8
  168. package/dist/utils/Operate/runPageOperations.js +3 -18
  169. package/dist/utils/Operate/setValueInFormData.js +2 -7
  170. package/dist/utils/Operate/shouldRun.js +1 -14
  171. package/dist/utils/Validate/additional/index.js +1 -18
  172. package/dist/utils/Validate/additional/index.test.js +0 -6
  173. package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
  174. package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
  175. package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
  176. package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
  177. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
  178. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +0 -7
  179. package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
  180. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
  181. package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
  182. package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
  183. package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
  184. package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
  185. package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
  186. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
  187. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -4
  188. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
  189. package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
  190. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
  191. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
  192. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +0 -4
  193. package/dist/utils/Validate/additional/utils.js +8 -24
  194. package/dist/utils/Validate/index.js +1 -9
  195. package/dist/utils/Validate/validateCollection.js +0 -9
  196. package/dist/utils/Validate/validateComponent.js +2 -35
  197. package/dist/utils/Validate/validateContainer.js +0 -13
  198. package/dist/utils/Validate/validateDate.js +4 -36
  199. package/dist/utils/Validate/validateEmail.js +1 -7
  200. package/dist/utils/Validate/validatePage.js +0 -15
  201. package/dist/utils/Validate/validateRegex.js +0 -10
  202. package/dist/utils/Validate/validateRequired.js +0 -8
  203. package/dist/utils/Validate/validateTime.js +3 -20
  204. package/dist/utils/index.js +0 -19
  205. package/package.json +50 -34
  206. package/dist/components/CheckYourAnswers/Answer.test.js +0 -95
  207. package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +0 -410
  208. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +0 -680
  209. package/dist/components/CollectionPage/CollectionPage.test.js +0 -428
  210. package/dist/components/FormComponent/Collection.test.js +0 -381
  211. package/dist/components/FormComponent/Container.test.js +0 -423
  212. package/dist/components/FormComponent/FormComponent.stories.mdx +0 -184
  213. package/dist/components/FormComponent/FormComponent.test.js +0 -264
  214. package/dist/components/FormPage/FormPage.stories.mdx +0 -131
  215. package/dist/components/FormPage/FormPage.test.js +0 -368
  216. package/dist/components/FormRenderer/FormRenderer.stories.mdx +0 -183
  217. package/dist/components/FormRenderer/FormRenderer.test.js +0 -1006
  218. package/dist/components/PageActions/ActionButton.test.js +0 -116
  219. package/dist/components/PageActions/PageActions.stories.mdx +0 -74
  220. package/dist/components/PageActions/PageActions.test.js +0 -157
  221. package/dist/components/SummaryList/GroupAction.test.js +0 -94
  222. package/dist/components/SummaryList/RowAction.test.js +0 -94
  223. package/dist/components/SummaryList/SummaryList.stories.mdx +0 -90
  224. package/dist/components/SummaryList/SummaryList.test.js +0 -361
  225. package/dist/components/TaskList/Task.test.js +0 -194
  226. package/dist/components/TaskList/TaskList.stories.mdx +0 -164
  227. package/dist/components/TaskList/TaskList.test.js +0 -334
  228. package/dist/components/TaskList/TaskState.test.js +0 -104
  229. package/dist/context/HooksContext/HooksContext.test.js +0 -60
  230. package/dist/context/ValidationContext/ValidationContext.test.js +0 -98
  231. package/dist/json/areYouACivilServant.json +0 -7
  232. package/dist/json/firstForm.json +0 -94
  233. package/dist/json/grade.json +0 -108
  234. package/dist/json/group.data.json +0 -21
  235. package/dist/json/group.json +0 -402
  236. package/dist/json/groupOfRow.json +0 -137
  237. package/dist/json/groupOfRowData.json +0 -15
  238. package/dist/json/port.json +0 -346
  239. package/dist/json/saveAndContinue.json +0 -98
  240. package/dist/json/sublocation.json +0 -859
  241. package/dist/json/taskList.json +0 -265
  242. package/dist/json/team.json +0 -17351
  243. package/dist/json/terminal.json +0 -81
  244. package/dist/json/userProfile.data.json +0 -21
  245. package/dist/json/userProfile.json +0 -276
  246. package/dist/setupTests.js +0 -59
  247. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +0 -139
  248. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +0 -76
  249. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +0 -59
  250. package/dist/utils/CheckYourAnswers/getCYARow.test.js +0 -256
  251. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +0 -77
  252. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +0 -199
  253. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +0 -170
  254. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +0 -323
  255. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +0 -281
  256. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +0 -64
  257. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +0 -41
  258. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +0 -54
  259. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +0 -131
  260. package/dist/utils/Component/cleanAttributes.test.js +0 -69
  261. package/dist/utils/Component/elevateNestedComponents.test.js +0 -92
  262. package/dist/utils/Component/getDefaultValue.test.js +0 -53
  263. package/dist/utils/Component/isEditable.test.js +0 -42
  264. package/dist/utils/Component/showComponent.test.js +0 -157
  265. package/dist/utils/Condition/meetsAllConditions.test.js +0 -62
  266. package/dist/utils/Condition/meetsCondition.test.js +0 -391
  267. package/dist/utils/Condition/meetsOneCondition.test.js +0 -101
  268. package/dist/utils/Condition/setupConditions.test.js +0 -35
  269. package/dist/utils/Container/getEditableComponents.test.js +0 -146
  270. package/dist/utils/Container/setupNesting.test.js +0 -92
  271. package/dist/utils/Container/showContainer.test.js +0 -179
  272. package/dist/utils/Data/applyFormula.test.js +0 -264
  273. package/dist/utils/Data/getAutocompleteSource.test.js +0 -146
  274. package/dist/utils/Data/getDataPath.test.js +0 -52
  275. package/dist/utils/Data/getOptions.test.js +0 -71
  276. package/dist/utils/Data/getSourceData.test.js +0 -141
  277. package/dist/utils/Data/refDataToOptions.test.js +0 -197
  278. package/dist/utils/Data/setDataItem.test.js +0 -112
  279. package/dist/utils/Data/setupFormData.test.js +0 -276
  280. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +0 -133
  281. package/dist/utils/FormPage/getFormPage.test.js +0 -205
  282. package/dist/utils/FormPage/getFormPages.test.js +0 -98
  283. package/dist/utils/FormPage/getPageActions.test.js +0 -89
  284. package/dist/utils/FormPage/getParagraphFromText.test.js +0 -29
  285. package/dist/utils/FormPage/showFormPage.test.js +0 -182
  286. package/dist/utils/FormPage/showFormPageCYA.test.js +0 -30
  287. package/dist/utils/FormPage/useComponent.test.js +0 -169
  288. package/dist/utils/Format/formatData.test.js +0 -46
  289. package/dist/utils/Format/formatDataForComponent.test.js +0 -161
  290. package/dist/utils/Format/formatDataForForm.test.js +0 -78
  291. package/dist/utils/Format/formatDataForPage.test.js +0 -96
  292. package/dist/utils/Hub/getFormHub.test.js +0 -107
  293. package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -44
  294. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +0 -159
  295. package/dist/utils/Operate/persistValueInFormData.test.js +0 -106
  296. package/dist/utils/Operate/runPageOperations.test.js +0 -107
  297. package/dist/utils/Operate/setValueInFormData.test.js +0 -46
  298. package/dist/utils/Operate/shouldRun.test.js +0 -69
  299. package/dist/utils/Validate/validateCollection.test.js +0 -74
  300. package/dist/utils/Validate/validateComponent.test.js +0 -267
  301. package/dist/utils/Validate/validateContainer.test.js +0 -81
  302. package/dist/utils/Validate/validateDate.test.js +0 -118
  303. package/dist/utils/Validate/validateEmail.test.js +0 -57
  304. package/dist/utils/Validate/validatePage.test.js +0 -383
  305. package/dist/utils/Validate/validateRegex.test.js +0 -41
  306. package/dist/utils/Validate/validateRequired.test.js +0 -62
  307. package/dist/utils/Validate/validateTime.test.js +0 -61
@@ -1,59 +0,0 @@
1
- "use strict";
2
-
3
- var _getCYACollectionDeleteAction = _interopRequireDefault(require("./getCYACollectionDeleteAction"));
4
-
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
-
7
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
-
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
-
11
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
-
13
- describe('utils', function () {
14
- describe('CheckYourAnswers', function () {
15
- describe('getCYACollectionDeleteAction', function () {
16
- var PAGE = {
17
- id: 'pageid',
18
- collection: {
19
- name: 'collectionName',
20
- labels: {
21
- remove: 'customName'
22
- }
23
- }
24
- };
25
- var ITEM = {
26
- id: 2
27
- };
28
- var TEST_DATA = {
29
- page: _objectSpread({}, PAGE),
30
- collectionName: [{
31
- id: 1
32
- }, {
33
- id: 2
34
- }, {
35
- id: 3
36
- }]
37
- };
38
- it('should remove selected item from the form data', function () {
39
- var data = null;
40
-
41
- var ON_ACTION = function ON_ACTION(_, call_back) {
42
- data = call_back(TEST_DATA);
43
- };
44
-
45
- var action = (0, _getCYACollectionDeleteAction.default)(PAGE, ITEM, ON_ACTION, 0, {});
46
- action.action.onAction();
47
- expect(data.collectionName.length).toEqual(2);
48
- expect(data.collectionName[0].id).toEqual(1);
49
- expect(data.collectionName[1].id).toEqual(3);
50
- });
51
- it('should get label to custom value', function () {
52
- var action = (0, _getCYACollectionDeleteAction.default)(PAGE, ITEM, function () {}, 0, {
53
- label: "customName"
54
- });
55
- expect(action.action.label).toEqual('customName');
56
- });
57
- });
58
- });
59
- });
@@ -1,256 +0,0 @@
1
- "use strict";
2
-
3
- var _setupTests = require("../../setupTests");
4
-
5
- var _getCYARow = _interopRequireDefault(require("./getCYARow"));
6
-
7
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
-
9
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
-
11
- describe('utils', function () {
12
- describe('CheckYourAnswers', function () {
13
- describe('getCYARow', function () {
14
- it('should get an appropriate row for a readonly text component', function () {
15
- var PAGE = {
16
- id: 'page',
17
- formData: {
18
- a: 'Bravo'
19
- }
20
- };
21
- var COMPONENT = {
22
- type: 'text',
23
- readonly: true,
24
- id: 'a',
25
- fieldId: 'a',
26
- label: 'Alpha'
27
- };
28
-
29
- var ON_ACTION = function ON_ACTION() {};
30
-
31
- var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
32
- (0, _setupTests.expectObjectLike)(ROW, {
33
- pageId: PAGE.id,
34
- fieldId: COMPONENT.fieldId,
35
- key: COMPONENT.label,
36
- value: 'Bravo',
37
- component: COMPONENT,
38
- action: null
39
- });
40
- });
41
- it('should get an appropriate row for a readonly text component with no value', function () {
42
- var PAGE = {
43
- id: 'page',
44
- formData: {}
45
- };
46
- var COMPONENT = {
47
- type: 'text',
48
- readonly: true,
49
- id: 'a',
50
- fieldId: 'a',
51
- label: 'Alpha'
52
- };
53
-
54
- var ON_ACTION = function ON_ACTION() {};
55
-
56
- expect((0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION)).toEqual({
57
- pageId: PAGE.id,
58
- id: COMPONENT.id,
59
- fieldId: COMPONENT.fieldId,
60
- key: COMPONENT.label,
61
- value: '',
62
- component: COMPONENT,
63
- action: null
64
- });
65
- });
66
- it('should get an appropriate row for a readonly non-editable component', function () {
67
- var PAGE = {
68
- id: 'page',
69
- formData: {
70
- a: 'BLAH'
71
- }
72
- };
73
- var COMPONENT = {
74
- type: 'blah',
75
- readonly: true,
76
- id: 'a',
77
- fieldId: 'a',
78
- label: 'Alpha'
79
- };
80
-
81
- var ON_ACTION = function ON_ACTION() {};
82
-
83
- expect((0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION)).toEqual({
84
- pageId: PAGE.id,
85
- id: COMPONENT.id,
86
- fieldId: COMPONENT.fieldId,
87
- key: COMPONENT.label,
88
- value: 'BLAH',
89
- action: null
90
- });
91
- });
92
- it('should use the cya_label where there is no label', function () {
93
- var PAGE = {
94
- id: 'page',
95
- formData: {
96
- a: 'Bravo'
97
- }
98
- };
99
- var COMPONENT = {
100
- type: 'text',
101
- readonly: true,
102
- id: 'a',
103
- fieldId: 'a',
104
- cya_label: 'CYA Alpha'
105
- };
106
-
107
- var ON_ACTION = function ON_ACTION() {};
108
-
109
- var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
110
- (0, _setupTests.expectObjectLike)(ROW, {
111
- pageId: PAGE.id,
112
- fieldId: COMPONENT.fieldId,
113
- key: COMPONENT.cya_label,
114
- action: null,
115
- component: COMPONENT,
116
- value: 'Bravo'
117
- });
118
- });
119
- it('should get an appropriate row for an editable text component', function () {
120
- var PAGE = {
121
- id: 'page',
122
- formData: {
123
- a: 'Bravo'
124
- },
125
- cya_link: {}
126
- };
127
- var COMPONENT = {
128
- type: 'text',
129
- id: 'a',
130
- fieldId: 'a',
131
- label: 'Alpha'
132
- };
133
-
134
- var ON_ACTION = function ON_ACTION() {};
135
-
136
- var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
137
- (0, _setupTests.expectObjectLike)(ROW, {
138
- pageId: PAGE.id,
139
- fieldId: COMPONENT.fieldId,
140
- key: COMPONENT.label,
141
- component: COMPONENT,
142
- value: 'Bravo'
143
- });
144
- (0, _setupTests.expectObjectLike)(ROW.action, {
145
- onAction: ON_ACTION
146
- });
147
- });
148
- it('should update any nested components with corresponding values from the stored formdata', function () {
149
- var SELECTED_VALUE = 'selectedValue';
150
- var NESTED_ID = 'nestedId';
151
- var NESTED_VALUE = 'nestedValue';
152
- var PAGE = {
153
- id: 'page',
154
- formData: _defineProperty({
155
- a: SELECTED_VALUE
156
- }, NESTED_ID, NESTED_VALUE),
157
- cya_link: {}
158
- };
159
- var COMPONENT = {
160
- type: 'radios',
161
- id: 'a',
162
- fieldId: 'a',
163
- data: {
164
- options: [{
165
- value: SELECTED_VALUE,
166
- nested: [{
167
- id: NESTED_ID
168
- }]
169
- }]
170
- }
171
- };
172
- var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
173
- expect(ROW.component.data.options[0].nested[0].value).toEqual(NESTED_VALUE);
174
- });
175
- it('should handle an undefined formData when attempting to set nested values', function () {
176
- var SELECTED_VALUE = 'selectedValue';
177
- var NESTED_ID = 'nestedId';
178
- var PAGE = {
179
- id: 'page',
180
- cya_link: {}
181
- };
182
- var COMPONENT = {
183
- type: 'radios',
184
- id: 'a',
185
- fieldId: 'a',
186
- data: {
187
- options: [{
188
- value: SELECTED_VALUE,
189
- nested: [{
190
- id: NESTED_ID
191
- }]
192
- }]
193
- }
194
- };
195
- var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
196
- expect(ROW.component.data.options[0].nested[0].value).toBeUndefined();
197
- });
198
- it('should get an appropriate row for a readonly text component with no value and interpolated label', function () {
199
- var PAGE = {
200
- id: 'page',
201
- formData: {
202
- text: 'Smith'
203
- }
204
- }; // eslint-disable-next-line no-template-curly-in-string
205
-
206
- var COMPONENT = {
207
- type: 'text',
208
- readonly: true,
209
- id: 'a',
210
- fieldId: 'a',
211
- label: 'Alpha ${text}'
212
- };
213
-
214
- var ON_ACTION = function ON_ACTION() {};
215
-
216
- expect((0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION)).toEqual({
217
- pageId: PAGE.id,
218
- id: COMPONENT.id,
219
- fieldId: COMPONENT.fieldId,
220
- key: 'Alpha Smith',
221
- value: '',
222
- component: COMPONENT,
223
- action: null
224
- });
225
- });
226
- it('should use the interolated cya_label where there is no label', function () {
227
- var PAGE = {
228
- id: 'page',
229
- formData: {
230
- a: 'Bravo'
231
- }
232
- }; // eslint-disable-next-line no-template-curly-in-string
233
-
234
- var COMPONENT = {
235
- type: 'text',
236
- readonly: true,
237
- id: 'a',
238
- fieldId: 'a',
239
- cya_label: 'CYA Alpha ${a}'
240
- };
241
-
242
- var ON_ACTION = function ON_ACTION() {};
243
-
244
- var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
245
- (0, _setupTests.expectObjectLike)(ROW, {
246
- pageId: PAGE.id,
247
- fieldId: COMPONENT.fieldId,
248
- key: 'CYA Alpha Bravo',
249
- action: null,
250
- component: COMPONENT,
251
- value: 'Bravo'
252
- });
253
- });
254
- });
255
- });
256
- });
@@ -1,77 +0,0 @@
1
- "use strict";
2
-
3
- var _setupTests = require("../../setupTests");
4
-
5
- var _getCYARowForGroup = _interopRequireDefault(require("./getCYARowForGroup"));
6
-
7
- var _getCYARow = _interopRequireDefault(require("./getCYARow"));
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- // Local imports
12
- describe('utils', function () {
13
- describe('CheckYourAnswers', function () {
14
- describe('getCYARowsForGroup', function () {
15
- it('should check address values block', function () {
16
- var COMPONENT_ADDRESS = {
17
- id: 'firstLineOfTheAddress',
18
- fieldId: 'firstLineOfTheAddress',
19
- label: 'address',
20
- type: 'text'
21
- };
22
- var COMPONENT_TOWN = {
23
- id: 'town',
24
- fieldId: 'town',
25
- label: 'Town',
26
- type: 'text'
27
- };
28
- var COMPONENT_CITY = {
29
- id: 'city',
30
- fieldId: 'city',
31
- label: 'City',
32
- type: 'text'
33
- };
34
- var COMPONENT_POSTCODE = {
35
- id: 'postCode',
36
- fieldId: 'postCode',
37
- label: 'postCode',
38
- type: 'text'
39
- };
40
- var PAGE = {
41
- components: [COMPONENT_ADDRESS, COMPONENT_TOWN, COMPONENT_CITY, COMPONENT_POSTCODE],
42
- id: 'addressDetails',
43
- fieldId: 'UK address',
44
- groups: [{
45
- id: 'address',
46
- label: 'Address details',
47
- components: ['firstLineOfTheAddress', 'town', 'city', 'postCode']
48
- }],
49
- name: 'address-details',
50
- title: 'Address details',
51
- formData: {
52
- firstLineOfTheAddress: '10 Downing Street',
53
- town: 'City of Westminster',
54
- city: 'London',
55
- postCode: 'SW1A 2AA'
56
- }
57
- };
58
-
59
- var ON_ACTION = function ON_ACTION() {};
60
-
61
- var rows = PAGE.components.map(function (component) {
62
- return (0, _getCYARow.default)(PAGE, component, ON_ACTION);
63
- });
64
-
65
- var _renderWithValidation = (0, _setupTests.renderWithValidation)((0, _getCYARowForGroup.default)(PAGE, PAGE.groups[0], rows, ON_ACTION).row.value),
66
- container = _renderWithValidation.container;
67
-
68
- expect(container.childNodes.length).toEqual(4);
69
- var addressValues = container.childNodes;
70
- expect(addressValues[0].childNodes[0].textContent).toEqual('10 Downing Street');
71
- expect(addressValues[1].childNodes[0].textContent).toEqual('City of Westminster');
72
- expect(addressValues[2].childNodes[0].textContent).toEqual('London');
73
- expect(addressValues[3].childNodes[0].textContent).toEqual('SW1A 2AA');
74
- });
75
- });
76
- });
77
- });
@@ -1,199 +0,0 @@
1
- "use strict";
2
-
3
- var _models = require("../../models");
4
-
5
- var _setupTests = require("../../setupTests");
6
-
7
- var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
-
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
-
15
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
-
17
- describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
18
- it('should get a single entry point row when there are no items', function () {
19
- var FORM_DATA = undefined;
20
- var PAGE = {
21
- id: 'page',
22
- components: [{
23
- labels: {
24
- add: 'Add'
25
- }
26
- }],
27
- formData: FORM_DATA,
28
- cya_link: {}
29
- };
30
- var COMPONENT = {
31
- type: 'text',
32
- readonly: true,
33
- id: 'a',
34
- fieldId: 'a',
35
- label: 'Alpha'
36
- };
37
- var COLLECTION = {
38
- id: 'collection',
39
- fieldId: 'collection',
40
- type: _models.ComponentTypes.COLLECTION,
41
- item: [COMPONENT]
42
- };
43
-
44
- var ON_ACTION = function ON_ACTION() {};
45
-
46
- var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, undefined, ON_ACTION);
47
- expect(ROWS.length).toEqual(1);
48
- });
49
- it('should get an appropriate row for a collection with a single readonly text component', function () {
50
- var FORM_DATA = {
51
- collection: [{
52
- a: 'Bravo'
53
- }]
54
- };
55
- var PAGE = {
56
- id: 'page',
57
- formData: FORM_DATA,
58
- cya_link: {}
59
- };
60
- var COMPONENT = {
61
- type: 'text',
62
- readonly: true,
63
- id: 'a',
64
- fieldId: 'a',
65
- label: 'Alpha'
66
- };
67
- var COLLECTION = {
68
- id: 'collection',
69
- fieldId: 'collection',
70
- type: _models.ComponentTypes.COLLECTION,
71
- countOffset: 22,
72
- item: [COMPONENT],
73
- value: FORM_DATA.collection,
74
- formData: FORM_DATA
75
- };
76
-
77
- var ON_ACTION = function ON_ACTION() {};
78
-
79
- var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
80
- expect(ROWS.length).toEqual(2); // Item title row + component row
81
-
82
- (0, _setupTests.expectObjectLike)(ROWS[0], {
83
- pageId: PAGE.id,
84
- fieldId: COLLECTION.fieldId,
85
- full_path: "".concat(COLLECTION.fieldId, "[0]"),
86
- key: 'Item 23',
87
- // includes countOffset
88
- type: 'title',
89
- action: null
90
- });
91
- (0, _setupTests.expectObjectLike)(ROWS[1], {
92
- pageId: PAGE.id,
93
- fieldId: COMPONENT.fieldId,
94
- full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
95
- key: COMPONENT.label,
96
- action: null,
97
- component: _objectSpread(_objectSpread({}, COMPONENT), {}, {
98
- full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId)
99
- }),
100
- value: 'Bravo'
101
- });
102
- });
103
- it('should get an appropriate row for a collection with a single readonly text component where the item label is an empty string', function () {
104
- var FORM_DATA = {
105
- collection: [{
106
- a: 'Bravo'
107
- }]
108
- };
109
- var PAGE = {
110
- id: 'page',
111
- formData: FORM_DATA,
112
- cya_link: {}
113
- };
114
- var COMPONENT = {
115
- type: 'text',
116
- readonly: true,
117
- id: 'a',
118
- fieldId: 'a',
119
- label: 'Alpha'
120
- };
121
- var COLLECTION = {
122
- id: 'collection',
123
- fieldId: 'collection',
124
- type: _models.ComponentTypes.COLLECTION,
125
- labels: {
126
- item: ''
127
- },
128
- countOffset: 22,
129
- item: [COMPONENT],
130
- value: FORM_DATA.collection,
131
- formData: FORM_DATA
132
- };
133
-
134
- var ON_ACTION = function ON_ACTION() {};
135
-
136
- var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
137
- expect(ROWS.length).toEqual(1); // Just the component row, no title row
138
-
139
- (0, _setupTests.expectObjectLike)(ROWS[0], {
140
- pageId: PAGE.id,
141
- fieldId: COMPONENT.fieldId,
142
- full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
143
- key: COMPONENT.label,
144
- action: null,
145
- component: _objectSpread(_objectSpread({}, COMPONENT), {}, {
146
- full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId)
147
- }),
148
- value: 'Bravo'
149
- });
150
- });
151
- it('should interpolate a field label appropriately', function () {
152
- var FORM_DATA = {
153
- collection: [{
154
- a: 'Bravo'
155
- }]
156
- };
157
- var PAGE = {
158
- id: 'page',
159
- formData: FORM_DATA,
160
- cya_link: {}
161
- }; // eslint-disable-next-line no-template-curly-in-string
162
-
163
- var COMPONENT = {
164
- type: 'text',
165
- readonly: true,
166
- id: 'a',
167
- fieldId: 'a',
168
- label: 'Alpha ${index}'
169
- };
170
- var COLLECTION = {
171
- id: 'collection',
172
- fieldId: 'collection',
173
- type: _models.ComponentTypes.COLLECTION,
174
- item: [COMPONENT],
175
- value: FORM_DATA.collection,
176
- formData: FORM_DATA
177
- };
178
-
179
- var ON_ACTION = function ON_ACTION() {};
180
-
181
- var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
182
- expect(ROWS.length).toEqual(2); // Title and item row.
183
-
184
- (0, _setupTests.expectObjectLike)(ROWS[1], {
185
- pageId: PAGE.id,
186
- fieldId: COMPONENT.fieldId,
187
- full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
188
- key: 'Alpha 1',
189
- // no countOffset
190
- action: null,
191
- component: _objectSpread(_objectSpread({}, COMPONENT), {}, {
192
- full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
193
- label: 'Alpha 1' // no countOffset
194
-
195
- }),
196
- value: 'Bravo'
197
- });
198
- });
199
- });