@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.
- package/dist/components/CheckYourAnswers/Answer.js +1 -14
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +19 -57
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +8 -38
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +13 -54
- package/dist/components/FormComponent/Container.js +6 -30
- package/dist/components/FormComponent/FormComponent.js +14 -57
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
- package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
- package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
- package/dist/components/FormComponent/helpers/index.js +0 -4
- package/dist/components/FormComponent/index.js +0 -3
- package/dist/components/FormPage/FormPage.js +14 -45
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -189
- package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
- package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
- package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
- package/dist/components/FormRenderer/handlers/index.js +0 -5
- package/dist/components/FormRenderer/handlers/navigate.js +0 -5
- package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
- package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +0 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -6
- package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
- package/dist/components/FormRenderer/helpers/getPage.js +0 -5
- package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +0 -6
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +6 -20
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +3 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +3 -24
- package/dist/components/SummaryList/RowAction.js +3 -23
- package/dist/components/SummaryList/SummaryList.js +6 -28
- package/dist/components/SummaryList/SummaryListRow.js +4 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/index.js +0 -2
- package/dist/components/SummaryList/index.js +0 -3
- package/dist/components/TaskList/Task.js +7 -29
- package/dist/components/TaskList/TaskList.js +12 -33
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -6
- package/dist/context/HooksContext/HooksContext.js +14 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +8 -34
- package/dist/context/ValidationContext/index.js +0 -5
- package/dist/context/index.js +0 -3
- package/dist/hooks/index.js +0 -9
- package/dist/hooks/useAxios.js +8 -25
- package/dist/hooks/useGetRequest.js +13 -47
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +8 -37
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -6
- package/dist/models/PageAction.js +0 -3
- package/dist/models/TaskStates.js +0 -3
- package/dist/models/index.js +0 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +0 -10
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +0 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +2 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +0 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +0 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -11
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +0 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +1 -12
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/elevateNestedComponents.js +0 -3
- package/dist/utils/Component/getComponent.js +4 -68
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +10 -28
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +10 -27
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +4 -22
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +6 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +10 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
- package/dist/utils/Component/getDefaultValue.js +0 -7
- package/dist/utils/Component/index.js +0 -9
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/wrapInFormGroup.js +0 -7
- package/dist/utils/Condition/index.js +0 -5
- package/dist/utils/Condition/meetsAllConditions.js +0 -9
- package/dist/utils/Condition/meetsCondition.js +7 -19
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/setupConditions.js +0 -12
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +0 -11
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Data/applyFormula.js +2 -28
- package/dist/utils/Data/getAutocompleteSource.js +1 -4
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getOptions.js +0 -9
- package/dist/utils/Data/getSourceData.js +4 -19
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +1 -12
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setupFormData.js +2 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.js +0 -14
- package/dist/utils/FormPage/getFormPage.js +0 -15
- package/dist/utils/FormPage/getFormPages.js +0 -8
- package/dist/utils/FormPage/getPageActions.js +3 -18
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/index.js +0 -6
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/useComponent.js +3 -18
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForForm.js +0 -8
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/index.js +1 -3
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +0 -9
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentForField.js +0 -11
- package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -11
- package/dist/utils/Meta/index.js +2 -6
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/runPageOperations.js +3 -18
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Validate/additional/index.js +1 -18
- package/dist/utils/Validate/additional/index.test.js +0 -6
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
- package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
- package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +0 -7
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -4
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +0 -4
- package/dist/utils/Validate/additional/utils.js +8 -24
- package/dist/utils/Validate/index.js +1 -9
- package/dist/utils/Validate/validateCollection.js +0 -9
- package/dist/utils/Validate/validateComponent.js +2 -35
- package/dist/utils/Validate/validateContainer.js +0 -13
- package/dist/utils/Validate/validateDate.js +4 -36
- package/dist/utils/Validate/validateEmail.js +1 -7
- package/dist/utils/Validate/validatePage.js +0 -15
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateTime.js +3 -20
- package/dist/utils/index.js +0 -19
- package/package.json +50 -34
- package/dist/components/CheckYourAnswers/Answer.test.js +0 -95
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +0 -410
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +0 -680
- package/dist/components/CollectionPage/CollectionPage.test.js +0 -428
- package/dist/components/FormComponent/Collection.test.js +0 -381
- package/dist/components/FormComponent/Container.test.js +0 -423
- package/dist/components/FormComponent/FormComponent.stories.mdx +0 -184
- package/dist/components/FormComponent/FormComponent.test.js +0 -264
- package/dist/components/FormPage/FormPage.stories.mdx +0 -131
- package/dist/components/FormPage/FormPage.test.js +0 -368
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +0 -183
- package/dist/components/FormRenderer/FormRenderer.test.js +0 -1006
- package/dist/components/PageActions/ActionButton.test.js +0 -116
- package/dist/components/PageActions/PageActions.stories.mdx +0 -74
- package/dist/components/PageActions/PageActions.test.js +0 -157
- package/dist/components/SummaryList/GroupAction.test.js +0 -94
- package/dist/components/SummaryList/RowAction.test.js +0 -94
- package/dist/components/SummaryList/SummaryList.stories.mdx +0 -90
- package/dist/components/SummaryList/SummaryList.test.js +0 -361
- package/dist/components/TaskList/Task.test.js +0 -194
- package/dist/components/TaskList/TaskList.stories.mdx +0 -164
- package/dist/components/TaskList/TaskList.test.js +0 -334
- package/dist/components/TaskList/TaskState.test.js +0 -104
- package/dist/context/HooksContext/HooksContext.test.js +0 -60
- package/dist/context/ValidationContext/ValidationContext.test.js +0 -98
- package/dist/json/areYouACivilServant.json +0 -7
- package/dist/json/firstForm.json +0 -94
- package/dist/json/grade.json +0 -108
- package/dist/json/group.data.json +0 -21
- package/dist/json/group.json +0 -402
- package/dist/json/groupOfRow.json +0 -137
- package/dist/json/groupOfRowData.json +0 -15
- package/dist/json/port.json +0 -346
- package/dist/json/saveAndContinue.json +0 -98
- package/dist/json/sublocation.json +0 -859
- package/dist/json/taskList.json +0 -265
- package/dist/json/team.json +0 -17351
- package/dist/json/terminal.json +0 -81
- package/dist/json/userProfile.data.json +0 -21
- package/dist/json/userProfile.json +0 -276
- package/dist/setupTests.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +0 -139
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +0 -76
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +0 -256
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +0 -77
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +0 -199
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +0 -170
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +0 -323
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +0 -281
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +0 -64
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +0 -41
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +0 -54
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +0 -131
- package/dist/utils/Component/cleanAttributes.test.js +0 -69
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -92
- package/dist/utils/Component/getDefaultValue.test.js +0 -53
- package/dist/utils/Component/isEditable.test.js +0 -42
- package/dist/utils/Component/showComponent.test.js +0 -157
- package/dist/utils/Condition/meetsAllConditions.test.js +0 -62
- package/dist/utils/Condition/meetsCondition.test.js +0 -391
- package/dist/utils/Condition/meetsOneCondition.test.js +0 -101
- package/dist/utils/Condition/setupConditions.test.js +0 -35
- package/dist/utils/Container/getEditableComponents.test.js +0 -146
- package/dist/utils/Container/setupNesting.test.js +0 -92
- package/dist/utils/Container/showContainer.test.js +0 -179
- package/dist/utils/Data/applyFormula.test.js +0 -264
- package/dist/utils/Data/getAutocompleteSource.test.js +0 -146
- package/dist/utils/Data/getDataPath.test.js +0 -52
- package/dist/utils/Data/getOptions.test.js +0 -71
- package/dist/utils/Data/getSourceData.test.js +0 -141
- package/dist/utils/Data/refDataToOptions.test.js +0 -197
- package/dist/utils/Data/setDataItem.test.js +0 -112
- package/dist/utils/Data/setupFormData.test.js +0 -276
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +0 -133
- package/dist/utils/FormPage/getFormPage.test.js +0 -205
- package/dist/utils/FormPage/getFormPages.test.js +0 -98
- package/dist/utils/FormPage/getPageActions.test.js +0 -89
- package/dist/utils/FormPage/getParagraphFromText.test.js +0 -29
- package/dist/utils/FormPage/showFormPage.test.js +0 -182
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -30
- package/dist/utils/FormPage/useComponent.test.js +0 -169
- package/dist/utils/Format/formatData.test.js +0 -46
- package/dist/utils/Format/formatDataForComponent.test.js +0 -161
- package/dist/utils/Format/formatDataForForm.test.js +0 -78
- package/dist/utils/Format/formatDataForPage.test.js +0 -96
- package/dist/utils/Hub/getFormHub.test.js +0 -107
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -44
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +0 -159
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -106
- package/dist/utils/Operate/runPageOperations.test.js +0 -107
- package/dist/utils/Operate/setValueInFormData.test.js +0 -46
- package/dist/utils/Operate/shouldRun.test.js +0 -69
- package/dist/utils/Validate/validateCollection.test.js +0 -74
- package/dist/utils/Validate/validateComponent.test.js +0 -267
- package/dist/utils/Validate/validateContainer.test.js +0 -81
- package/dist/utils/Validate/validateDate.test.js +0 -118
- package/dist/utils/Validate/validateEmail.test.js +0 -57
- package/dist/utils/Validate/validatePage.test.js +0 -383
- package/dist/utils/Validate/validateRegex.test.js +0 -41
- package/dist/utils/Validate/validateRequired.test.js +0 -62
- package/dist/utils/Validate/validateTime.test.js +0 -61
|
@@ -1,680 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
6
|
-
|
|
7
|
-
var _axiosMockAdapter = _interopRequireDefault(require("axios-mock-adapter"));
|
|
8
|
-
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
|
-
var _reactDom = require("react-dom");
|
|
12
|
-
|
|
13
|
-
var _testUtils = require("react-dom/test-utils");
|
|
14
|
-
|
|
15
|
-
var _areYouACivilServant = _interopRequireDefault(require("../../json/areYouACivilServant.json"));
|
|
16
|
-
|
|
17
|
-
var _grade = _interopRequireDefault(require("../../json/grade.json"));
|
|
18
|
-
|
|
19
|
-
var _team = _interopRequireDefault(require("../../json/team.json"));
|
|
20
|
-
|
|
21
|
-
var _userProfileData = _interopRequireDefault(require("../../json/userProfile.data.json"));
|
|
22
|
-
|
|
23
|
-
var _userProfile = _interopRequireDefault(require("../../json/userProfile.json"));
|
|
24
|
-
|
|
25
|
-
var _groupData = _interopRequireDefault(require("../../json/group.data.json"));
|
|
26
|
-
|
|
27
|
-
var _group = _interopRequireDefault(require("../../json/group.json"));
|
|
28
|
-
|
|
29
|
-
var _groupOfRow = _interopRequireDefault(require("../../json/groupOfRow.json"));
|
|
30
|
-
|
|
31
|
-
var _setupTests = require("../../setupTests");
|
|
32
|
-
|
|
33
|
-
var _utils = _interopRequireDefault(require("../../utils"));
|
|
34
|
-
|
|
35
|
-
var _CheckYourAnswers = _interopRequireWildcard(require("./CheckYourAnswers"));
|
|
36
|
-
|
|
37
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
38
|
-
|
|
39
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
40
|
-
|
|
41
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
42
|
-
|
|
43
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
44
|
-
|
|
45
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
46
|
-
|
|
47
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
48
|
-
|
|
49
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
50
|
-
|
|
51
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
52
|
-
|
|
53
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
54
|
-
|
|
55
|
-
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); } }
|
|
56
|
-
|
|
57
|
-
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); }); }; }
|
|
58
|
-
|
|
59
|
-
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; }
|
|
60
|
-
|
|
61
|
-
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; }
|
|
62
|
-
|
|
63
|
-
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; }
|
|
64
|
-
|
|
65
|
-
describe('components', function () {
|
|
66
|
-
describe('CheckYourAnswers', function () {
|
|
67
|
-
var mockAxios = new _axiosMockAdapter.default(_axios.default);
|
|
68
|
-
|
|
69
|
-
var DATA = _utils.default.Data.setupForm(_userProfile.default.pages, _userProfile.default.components, _userProfileData.default);
|
|
70
|
-
|
|
71
|
-
var PAGES = _utils.default.FormPage.getAll(_userProfile.default.pages, _userProfile.default.components, _objectSpread({}, DATA));
|
|
72
|
-
|
|
73
|
-
var ON_ROW_ACTION_CALLS = [];
|
|
74
|
-
|
|
75
|
-
var ON_ROW_ACTION = function ON_ROW_ACTION(row) {
|
|
76
|
-
ON_ROW_ACTION_CALLS.push(row);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
var ON_ACTION_CALLS = [];
|
|
80
|
-
|
|
81
|
-
var ON_ACTION = function ON_ACTION(action, onError) {
|
|
82
|
-
ON_ACTION_CALLS.push({
|
|
83
|
-
action: action,
|
|
84
|
-
onError: onError
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
var container = null;
|
|
89
|
-
|
|
90
|
-
var refDataUrl = function refDataUrl(suffix) {
|
|
91
|
-
return "".concat(_userProfileData.default.urls.refData, "/").concat(suffix);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
beforeEach(function () {
|
|
95
|
-
ON_ROW_ACTION_CALLS.length = 0;
|
|
96
|
-
ON_ACTION_CALLS.length = 0;
|
|
97
|
-
container = document.createElement('div');
|
|
98
|
-
document.body.appendChild(container);
|
|
99
|
-
mockAxios.reset();
|
|
100
|
-
mockAxios.onGet(refDataUrl('areYouACivilServant')).reply(200, _areYouACivilServant.default);
|
|
101
|
-
mockAxios.onGet(refDataUrl('grade')).reply(200, _grade.default);
|
|
102
|
-
mockAxios.onGet(refDataUrl('team')).reply(200, _team.default);
|
|
103
|
-
});
|
|
104
|
-
afterEach(function () {
|
|
105
|
-
(0, _reactDom.unmountComponentAtNode)(container);
|
|
106
|
-
container.remove();
|
|
107
|
-
container = null;
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
var checkCYA = function checkCYA(container) {
|
|
111
|
-
var cya = container.childNodes[0];
|
|
112
|
-
expect(cya.tagName).toEqual('DIV');
|
|
113
|
-
expect(cya.classList).toContain(_CheckYourAnswers.DEFAULT_CLASS);
|
|
114
|
-
return cya;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
var checkRow = function checkRow(row, key, value, action) {
|
|
118
|
-
expect(row.textContent).toContain(key);
|
|
119
|
-
expect(row.textContent).toContain(value);
|
|
120
|
-
|
|
121
|
-
if (action) {
|
|
122
|
-
expect(row.textContent).toContain('Change');
|
|
123
|
-
} else {
|
|
124
|
-
expect(row.textContent).not.toContain('Change');
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
it('should show default title if none is provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
129
|
-
var cya, title;
|
|
130
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
131
|
-
while (1) {
|
|
132
|
-
switch (_context2.prev = _context2.next) {
|
|
133
|
-
case 0:
|
|
134
|
-
_context2.next = 2;
|
|
135
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
136
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
137
|
-
while (1) {
|
|
138
|
-
switch (_context.prev = _context.next) {
|
|
139
|
-
case 0:
|
|
140
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
141
|
-
pages: PAGES,
|
|
142
|
-
onRowAction: ON_ROW_ACTION,
|
|
143
|
-
onAction: ON_ACTION
|
|
144
|
-
}), container);
|
|
145
|
-
|
|
146
|
-
case 1:
|
|
147
|
-
case "end":
|
|
148
|
-
return _context.stop();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}, _callee);
|
|
152
|
-
})));
|
|
153
|
-
|
|
154
|
-
case 2:
|
|
155
|
-
cya = checkCYA(container);
|
|
156
|
-
title = cya.childNodes[0];
|
|
157
|
-
expect(title.classList).toContain('govuk-heading-l');
|
|
158
|
-
expect(title.textContent).toEqual(_CheckYourAnswers.DEFAULT_TITLE);
|
|
159
|
-
|
|
160
|
-
case 6:
|
|
161
|
-
case "end":
|
|
162
|
-
return _context2.stop();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}, _callee2);
|
|
166
|
-
})));
|
|
167
|
-
it('should allow title to be overridden', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
168
|
-
var TITLE, cya, title;
|
|
169
|
-
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
170
|
-
while (1) {
|
|
171
|
-
switch (_context4.prev = _context4.next) {
|
|
172
|
-
case 0:
|
|
173
|
-
TITLE = 'Alpha Bravo Charlie';
|
|
174
|
-
_context4.next = 3;
|
|
175
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
176
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
177
|
-
while (1) {
|
|
178
|
-
switch (_context3.prev = _context3.next) {
|
|
179
|
-
case 0:
|
|
180
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
181
|
-
title: TITLE,
|
|
182
|
-
pages: PAGES,
|
|
183
|
-
onRowAction: ON_ROW_ACTION,
|
|
184
|
-
onAction: ON_ACTION
|
|
185
|
-
}), container);
|
|
186
|
-
|
|
187
|
-
case 1:
|
|
188
|
-
case "end":
|
|
189
|
-
return _context3.stop();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}, _callee3);
|
|
193
|
-
})));
|
|
194
|
-
|
|
195
|
-
case 3:
|
|
196
|
-
cya = checkCYA(container);
|
|
197
|
-
title = cya.childNodes[0];
|
|
198
|
-
expect(title.classList).toContain('govuk-heading-l');
|
|
199
|
-
expect(title.textContent).toEqual(TITLE);
|
|
200
|
-
|
|
201
|
-
case 7:
|
|
202
|
-
case "end":
|
|
203
|
-
return _context4.stop();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}, _callee4);
|
|
207
|
-
})));
|
|
208
|
-
it('should show readonly page components correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
209
|
-
var cya, _cya$childNodes, cyaChildNode, names, _names$childNodes, firstName, surname;
|
|
210
|
-
|
|
211
|
-
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
212
|
-
while (1) {
|
|
213
|
-
switch (_context6.prev = _context6.next) {
|
|
214
|
-
case 0:
|
|
215
|
-
_context6.next = 2;
|
|
216
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
|
|
217
|
-
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
218
|
-
while (1) {
|
|
219
|
-
switch (_context5.prev = _context5.next) {
|
|
220
|
-
case 0:
|
|
221
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
222
|
-
pages: PAGES,
|
|
223
|
-
onRowAction: ON_ROW_ACTION,
|
|
224
|
-
onAction: ON_ACTION
|
|
225
|
-
}), container);
|
|
226
|
-
|
|
227
|
-
case 1:
|
|
228
|
-
case "end":
|
|
229
|
-
return _context5.stop();
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}, _callee5);
|
|
233
|
-
})));
|
|
234
|
-
|
|
235
|
-
case 2:
|
|
236
|
-
cya = checkCYA(container);
|
|
237
|
-
_cya$childNodes = _slicedToArray(cya.childNodes, 2), cyaChildNode = _cya$childNodes[1];
|
|
238
|
-
names = cyaChildNode.childNodes[0];
|
|
239
|
-
expect(names.tagName).toEqual('DL');
|
|
240
|
-
expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
|
|
241
|
-
_names$childNodes = _slicedToArray(names.childNodes, 2), firstName = _names$childNodes[0], surname = _names$childNodes[1];
|
|
242
|
-
checkRow(firstName, 'First name', 'John', false);
|
|
243
|
-
checkRow(surname, 'Last name', 'Smith', false);
|
|
244
|
-
|
|
245
|
-
case 10:
|
|
246
|
-
case "end":
|
|
247
|
-
return _context6.stop();
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}, _callee6);
|
|
251
|
-
})));
|
|
252
|
-
it('should show editable page components correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
|
|
253
|
-
var cya, _cya$childNodes2, title, cyaChildNode, civilServant, _civilServant$childNo, status;
|
|
254
|
-
|
|
255
|
-
return regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
256
|
-
while (1) {
|
|
257
|
-
switch (_context8.prev = _context8.next) {
|
|
258
|
-
case 0:
|
|
259
|
-
_context8.next = 2;
|
|
260
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
|
|
261
|
-
return regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
262
|
-
while (1) {
|
|
263
|
-
switch (_context7.prev = _context7.next) {
|
|
264
|
-
case 0:
|
|
265
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
266
|
-
pages: PAGES,
|
|
267
|
-
onRowAction: ON_ROW_ACTION,
|
|
268
|
-
onAction: ON_ACTION
|
|
269
|
-
}), container);
|
|
270
|
-
|
|
271
|
-
case 1:
|
|
272
|
-
case "end":
|
|
273
|
-
return _context7.stop();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}, _callee7);
|
|
277
|
-
})));
|
|
278
|
-
|
|
279
|
-
case 2:
|
|
280
|
-
cya = checkCYA(container);
|
|
281
|
-
_cya$childNodes2 = _slicedToArray(cya.childNodes, 4), title = _cya$childNodes2[2], cyaChildNode = _cya$childNodes2[3];
|
|
282
|
-
civilServant = cyaChildNode.childNodes[0];
|
|
283
|
-
expect(title.textContent).toEqual('Are you a civil servant?');
|
|
284
|
-
expect(civilServant.tagName).toEqual('DL');
|
|
285
|
-
expect(civilServant.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
|
|
286
|
-
_civilServant$childNo = _slicedToArray(civilServant.childNodes, 1), status = _civilServant$childNo[0];
|
|
287
|
-
checkRow(status, 'Are you a civil servant?', 'Yes', true);
|
|
288
|
-
|
|
289
|
-
case 10:
|
|
290
|
-
case "end":
|
|
291
|
-
return _context8.stop();
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}, _callee8);
|
|
295
|
-
})));
|
|
296
|
-
it('should show editable page components correctly with page titles hidden', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() {
|
|
297
|
-
var cya, _cya$childNodes3, cyaChildNode, civilServant, _civilServant$childNo2, status;
|
|
298
|
-
|
|
299
|
-
return regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
300
|
-
while (1) {
|
|
301
|
-
switch (_context10.prev = _context10.next) {
|
|
302
|
-
case 0:
|
|
303
|
-
_context10.next = 2;
|
|
304
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
|
|
305
|
-
return regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
306
|
-
while (1) {
|
|
307
|
-
switch (_context9.prev = _context9.next) {
|
|
308
|
-
case 0:
|
|
309
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
310
|
-
pages: PAGES,
|
|
311
|
-
onRowAction: ON_ROW_ACTION,
|
|
312
|
-
onAction: ON_ACTION,
|
|
313
|
-
hide_page_titles: true
|
|
314
|
-
}), container);
|
|
315
|
-
|
|
316
|
-
case 1:
|
|
317
|
-
case "end":
|
|
318
|
-
return _context9.stop();
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}, _callee9);
|
|
322
|
-
})));
|
|
323
|
-
|
|
324
|
-
case 2:
|
|
325
|
-
cya = checkCYA(container);
|
|
326
|
-
_cya$childNodes3 = _slicedToArray(cya.childNodes, 3), cyaChildNode = _cya$childNodes3[2]; // The title simply isn't returned
|
|
327
|
-
|
|
328
|
-
civilServant = cyaChildNode.childNodes[0];
|
|
329
|
-
expect(civilServant.tagName).toEqual('DL');
|
|
330
|
-
expect(civilServant.classList).toContain("govuk-!-margin-bottom-0"); // Changed margin if no titles
|
|
331
|
-
|
|
332
|
-
_civilServant$childNo2 = _slicedToArray(civilServant.childNodes, 1), status = _civilServant$childNo2[0];
|
|
333
|
-
checkRow(status, 'Are you a civil servant?', 'Yes', true);
|
|
334
|
-
|
|
335
|
-
case 9:
|
|
336
|
-
case "end":
|
|
337
|
-
return _context10.stop();
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}, _callee10);
|
|
341
|
-
})));
|
|
342
|
-
it('should show no title if is set to hidden', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
|
|
343
|
-
var cya, _cya$childNodes4, cyaChildNode, names, _names$childNodes2, firstName, surname;
|
|
344
|
-
|
|
345
|
-
return regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
346
|
-
while (1) {
|
|
347
|
-
switch (_context12.prev = _context12.next) {
|
|
348
|
-
case 0:
|
|
349
|
-
_context12.next = 2;
|
|
350
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
|
|
351
|
-
return regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
352
|
-
while (1) {
|
|
353
|
-
switch (_context11.prev = _context11.next) {
|
|
354
|
-
case 0:
|
|
355
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
356
|
-
pages: PAGES,
|
|
357
|
-
onRowAction: ON_ROW_ACTION,
|
|
358
|
-
onAction: ON_ACTION,
|
|
359
|
-
hide_title: true
|
|
360
|
-
}), container);
|
|
361
|
-
|
|
362
|
-
case 1:
|
|
363
|
-
case "end":
|
|
364
|
-
return _context11.stop();
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}, _callee11);
|
|
368
|
-
})));
|
|
369
|
-
|
|
370
|
-
case 2:
|
|
371
|
-
cya = checkCYA(container);
|
|
372
|
-
_cya$childNodes4 = _slicedToArray(cya.childNodes, 1), cyaChildNode = _cya$childNodes4[0];
|
|
373
|
-
names = cyaChildNode.childNodes[0];
|
|
374
|
-
expect(names.tagName).toEqual('DL');
|
|
375
|
-
expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
|
|
376
|
-
_names$childNodes2 = _slicedToArray(names.childNodes, 2), firstName = _names$childNodes2[0], surname = _names$childNodes2[1];
|
|
377
|
-
checkRow(firstName, 'First name', 'John', false);
|
|
378
|
-
checkRow(surname, 'Last name', 'Smith', false);
|
|
379
|
-
|
|
380
|
-
case 10:
|
|
381
|
-
case "end":
|
|
382
|
-
return _context12.stop();
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}, _callee12);
|
|
386
|
-
})));
|
|
387
|
-
it('should show task list in CYA style', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() {
|
|
388
|
-
var sections, taskHeading1, namesPageHeading, taskHeading2, gradePageHeading;
|
|
389
|
-
return regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
390
|
-
while (1) {
|
|
391
|
-
switch (_context14.prev = _context14.next) {
|
|
392
|
-
case 0:
|
|
393
|
-
sections = [{
|
|
394
|
-
name: 'These are your tasks',
|
|
395
|
-
tasks: [{
|
|
396
|
-
name: 'Task 1',
|
|
397
|
-
state: 'complete',
|
|
398
|
-
pages: ['names']
|
|
399
|
-
}, {
|
|
400
|
-
name: 'Task 2',
|
|
401
|
-
state: 'complete',
|
|
402
|
-
pages: ['grade']
|
|
403
|
-
}]
|
|
404
|
-
}];
|
|
405
|
-
_context14.next = 3;
|
|
406
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
|
|
407
|
-
return regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
408
|
-
while (1) {
|
|
409
|
-
switch (_context13.prev = _context13.next) {
|
|
410
|
-
case 0:
|
|
411
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
412
|
-
pages: PAGES,
|
|
413
|
-
onRowAction: ON_ROW_ACTION,
|
|
414
|
-
onAction: ON_ACTION,
|
|
415
|
-
hide_title: true,
|
|
416
|
-
sections: sections,
|
|
417
|
-
type: "task-list-cya"
|
|
418
|
-
}), container);
|
|
419
|
-
|
|
420
|
-
case 1:
|
|
421
|
-
case "end":
|
|
422
|
-
return _context13.stop();
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}, _callee13);
|
|
426
|
-
})));
|
|
427
|
-
|
|
428
|
-
case 3:
|
|
429
|
-
taskHeading1 = container.childNodes[0].childNodes[0];
|
|
430
|
-
expect(taskHeading1.tagName).toEqual('H3');
|
|
431
|
-
expect(taskHeading1.textContent).toEqual('Task 1');
|
|
432
|
-
expect(taskHeading1.classList).toContain("govuk-!-margin-top-8");
|
|
433
|
-
expect(taskHeading1.classList).toContain("govuk-!-margin-bottom-0");
|
|
434
|
-
namesPageHeading = container.childNodes[0].childNodes[1];
|
|
435
|
-
expect(namesPageHeading.tagName).toEqual('DIV');
|
|
436
|
-
expect(namesPageHeading.textContent).toContain('John');
|
|
437
|
-
expect(namesPageHeading.classList).toContain("group-of-rows");
|
|
438
|
-
taskHeading2 = container.childNodes[0].childNodes[2];
|
|
439
|
-
expect(taskHeading2.tagName).toEqual('H3');
|
|
440
|
-
expect(taskHeading2.textContent).toEqual('Task 2');
|
|
441
|
-
expect(taskHeading2.classList).toContain("govuk-!-margin-top-8");
|
|
442
|
-
expect(taskHeading2.classList).toContain("govuk-!-margin-bottom-0");
|
|
443
|
-
gradePageHeading = container.childNodes[0].childNodes[3];
|
|
444
|
-
expect(gradePageHeading.tagName).toEqual('H4');
|
|
445
|
-
expect(gradePageHeading.textContent).toEqual("What's your grade?");
|
|
446
|
-
expect(gradePageHeading.classList).toContain("govuk-!-margin-top-6");
|
|
447
|
-
expect(gradePageHeading.classList).toContain("govuk-!-margin-bottom-5");
|
|
448
|
-
|
|
449
|
-
case 22:
|
|
450
|
-
case "end":
|
|
451
|
-
return _context14.stop();
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}, _callee14);
|
|
455
|
-
})));
|
|
456
|
-
it('Show answers from multiple address fields into in one DL', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() {
|
|
457
|
-
var DATA, GROUP_PAGES, cya, groupedComponent, keyGroup, valueGroup, changeButtonDiv, changeButton;
|
|
458
|
-
return regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
459
|
-
while (1) {
|
|
460
|
-
switch (_context16.prev = _context16.next) {
|
|
461
|
-
case 0:
|
|
462
|
-
DATA = _utils.default.Data.setupForm(_group.default.pages, _group.default.components, _groupData.default);
|
|
463
|
-
GROUP_PAGES = _utils.default.FormPage.getAll(_group.default.pages, _group.default.components, _objectSpread({}, DATA));
|
|
464
|
-
_context16.next = 4;
|
|
465
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15() {
|
|
466
|
-
return regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
467
|
-
while (1) {
|
|
468
|
-
switch (_context15.prev = _context15.next) {
|
|
469
|
-
case 0:
|
|
470
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
471
|
-
pages: GROUP_PAGES,
|
|
472
|
-
onRowAction: ON_ROW_ACTION,
|
|
473
|
-
onAction: ON_ACTION,
|
|
474
|
-
hide_title: true
|
|
475
|
-
}), container);
|
|
476
|
-
|
|
477
|
-
case 1:
|
|
478
|
-
case "end":
|
|
479
|
-
return _context15.stop();
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}, _callee15);
|
|
483
|
-
})));
|
|
484
|
-
|
|
485
|
-
case 4:
|
|
486
|
-
cya = checkCYA(container);
|
|
487
|
-
groupedComponent = cya.childNodes[10];
|
|
488
|
-
keyGroup = groupedComponent.childNodes[0].childNodes[0].childNodes[0];
|
|
489
|
-
expect(keyGroup.tagName).toEqual('DT');
|
|
490
|
-
expect(keyGroup.textContent).toEqual('Address details');
|
|
491
|
-
valueGroup = groupedComponent.childNodes[0].childNodes[0].childNodes[1];
|
|
492
|
-
expect(valueGroup.childNodes.length).toEqual(4);
|
|
493
|
-
expect(valueGroup.tagName).toEqual('DD');
|
|
494
|
-
expect(valueGroup.childNodes[0].textContent).toContain('10 Downing Street');
|
|
495
|
-
expect(valueGroup.childNodes[1].textContent).toContain('City of Westminster');
|
|
496
|
-
expect(valueGroup.childNodes[2].textContent).toContain('London');
|
|
497
|
-
expect(valueGroup.childNodes[3].textContent).toContain('SW1A 2AA');
|
|
498
|
-
changeButtonDiv = groupedComponent.childNodes[0].childNodes[0].childNodes[2];
|
|
499
|
-
expect(changeButtonDiv.classList).toContain('govuk-summary-list__actions');
|
|
500
|
-
changeButton = changeButtonDiv.childNodes[0];
|
|
501
|
-
expect(changeButton.tagName).toEqual('A');
|
|
502
|
-
expect(changeButton.textContent).toEqual('Change address details');
|
|
503
|
-
|
|
504
|
-
case 21:
|
|
505
|
-
case "end":
|
|
506
|
-
return _context16.stop();
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}, _callee16);
|
|
510
|
-
})));
|
|
511
|
-
it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18() {
|
|
512
|
-
var GROUP_PAGES, cya, namesGroup, firstNameRow, surname, changeButtonDiv, changeButton;
|
|
513
|
-
return regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
514
|
-
while (1) {
|
|
515
|
-
switch (_context18.prev = _context18.next) {
|
|
516
|
-
case 0:
|
|
517
|
-
GROUP_PAGES = _utils.default.FormPage.getAll(_groupOfRow.default.pages, _groupOfRow.default.components, _objectSpread({}, DATA));
|
|
518
|
-
_context18.next = 3;
|
|
519
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() {
|
|
520
|
-
return regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
521
|
-
while (1) {
|
|
522
|
-
switch (_context17.prev = _context17.next) {
|
|
523
|
-
case 0:
|
|
524
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
525
|
-
pages: GROUP_PAGES,
|
|
526
|
-
onRowAction: ON_ROW_ACTION,
|
|
527
|
-
onAction: ON_ACTION,
|
|
528
|
-
groups: _groupOfRow.default.cya.groups
|
|
529
|
-
}), container);
|
|
530
|
-
|
|
531
|
-
case 1:
|
|
532
|
-
case "end":
|
|
533
|
-
return _context17.stop();
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
}, _callee17);
|
|
537
|
-
})));
|
|
538
|
-
|
|
539
|
-
case 3:
|
|
540
|
-
cya = checkCYA(container);
|
|
541
|
-
namesGroup = cya.childNodes[2];
|
|
542
|
-
firstNameRow = namesGroup.childNodes[0].childNodes[0];
|
|
543
|
-
expect(firstNameRow.childNodes.length).toEqual(2);
|
|
544
|
-
expect(firstNameRow.childNodes[0].textContent).toEqual('First name (optional)');
|
|
545
|
-
expect(firstNameRow.childNodes[0].tagName).toEqual('DT');
|
|
546
|
-
expect(firstNameRow.childNodes[1].textContent).toEqual('John');
|
|
547
|
-
expect(firstNameRow.childNodes[1].tagName).toEqual('DD');
|
|
548
|
-
surname = namesGroup.childNodes[0].childNodes[1];
|
|
549
|
-
expect(surname.childNodes.length).toEqual(2);
|
|
550
|
-
expect(surname.childNodes[0].textContent).toEqual('Last name (optional)');
|
|
551
|
-
expect(surname.childNodes[0].tagName).toEqual('DT');
|
|
552
|
-
expect(surname.childNodes[1].textContent).toEqual('Smith');
|
|
553
|
-
expect(surname.childNodes[1].tagName).toEqual('DD');
|
|
554
|
-
changeButtonDiv = namesGroup.childNodes[0].childNodes[2];
|
|
555
|
-
expect(changeButtonDiv.classList).toContain('change-group-button');
|
|
556
|
-
changeButton = changeButtonDiv.childNodes[0];
|
|
557
|
-
expect(changeButton.tagName).toEqual('A');
|
|
558
|
-
expect(changeButton.textContent).toEqual('Change names');
|
|
559
|
-
|
|
560
|
-
case 22:
|
|
561
|
-
case "end":
|
|
562
|
-
return _context18.stop();
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}, _callee18);
|
|
566
|
-
})));
|
|
567
|
-
it('should show page components corrently with interpolated title and cya_label, if label is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20() {
|
|
568
|
-
var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$childNodes5, cyaTitle, cyaChildNode, names, _names$childNodes3, firstName, surname, _firstName$childNodes, label;
|
|
569
|
-
|
|
570
|
-
return regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
571
|
-
while (1) {
|
|
572
|
-
switch (_context20.prev = _context20.next) {
|
|
573
|
-
case 0:
|
|
574
|
-
_PAGES = [].concat(_userProfile.default.pages); // eslint-disable-next-line no-template-curly-in-string
|
|
575
|
-
|
|
576
|
-
_PAGES[0] = _objectSpread(_objectSpread({}, _PAGES[0]), {}, {
|
|
577
|
-
title: 'Alpha ID: ${businessKey}'
|
|
578
|
-
});
|
|
579
|
-
_COMPONENTS = [].concat(_userProfile.default.components);
|
|
580
|
-
_COMPONENTS[0] = _objectSpread(_objectSpread({}, _COMPONENTS[0]), {}, {
|
|
581
|
-
label: undefined,
|
|
582
|
-
required: true,
|
|
583
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
584
|
-
cya_label: "Text ${currentUser.familyName}"
|
|
585
|
-
});
|
|
586
|
-
T_PAGES = _utils.default.FormPage.getAll(_PAGES, _COMPONENTS, DATA);
|
|
587
|
-
_context20.next = 7;
|
|
588
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() {
|
|
589
|
-
return regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
590
|
-
while (1) {
|
|
591
|
-
switch (_context19.prev = _context19.next) {
|
|
592
|
-
case 0:
|
|
593
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
594
|
-
pages: T_PAGES,
|
|
595
|
-
onRowAction: ON_ROW_ACTION,
|
|
596
|
-
onAction: ON_ACTION
|
|
597
|
-
}), container);
|
|
598
|
-
|
|
599
|
-
case 1:
|
|
600
|
-
case "end":
|
|
601
|
-
return _context19.stop();
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}, _callee19);
|
|
605
|
-
})));
|
|
606
|
-
|
|
607
|
-
case 7:
|
|
608
|
-
cya = checkCYA(container);
|
|
609
|
-
_cya$childNodes5 = _slicedToArray(cya.childNodes, 3), cyaTitle = _cya$childNodes5[1], cyaChildNode = _cya$childNodes5[2];
|
|
610
|
-
expect(cyaTitle.textContent).toEqual('Alpha ID: 123456789');
|
|
611
|
-
names = cyaChildNode.childNodes[0];
|
|
612
|
-
expect(names.tagName).toEqual('DL');
|
|
613
|
-
expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
|
|
614
|
-
_names$childNodes3 = _slicedToArray(names.childNodes, 2), firstName = _names$childNodes3[0], surname = _names$childNodes3[1];
|
|
615
|
-
_firstName$childNodes = _slicedToArray(firstName.childNodes, 1), label = _firstName$childNodes[0];
|
|
616
|
-
expect(label.textContent).toEqual('Text Smith');
|
|
617
|
-
checkRow(surname, 'Last name', 'Smith', false);
|
|
618
|
-
|
|
619
|
-
case 17:
|
|
620
|
-
case "end":
|
|
621
|
-
return _context20.stop();
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
}, _callee20);
|
|
625
|
-
})));
|
|
626
|
-
it('should show page components corrently with no label, if label and cya_label are missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22() {
|
|
627
|
-
var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$childNodes6, cyaChildNode, names, _names$childNodes4, firstName, surname, _firstName$childNodes2, label;
|
|
628
|
-
|
|
629
|
-
return regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
630
|
-
while (1) {
|
|
631
|
-
switch (_context22.prev = _context22.next) {
|
|
632
|
-
case 0:
|
|
633
|
-
_PAGES = [].concat(_userProfile.default.pages);
|
|
634
|
-
_COMPONENTS = [].concat(_userProfile.default.components);
|
|
635
|
-
_COMPONENTS[0] = _objectSpread(_objectSpread({}, _COMPONENTS[0]), {}, {
|
|
636
|
-
label: undefined,
|
|
637
|
-
required: true,
|
|
638
|
-
cya_label: undefined
|
|
639
|
-
});
|
|
640
|
-
T_PAGES = _utils.default.FormPage.getAll(_PAGES, _COMPONENTS, _objectSpread({}, DATA));
|
|
641
|
-
_context22.next = 6;
|
|
642
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21() {
|
|
643
|
-
return regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
644
|
-
while (1) {
|
|
645
|
-
switch (_context21.prev = _context21.next) {
|
|
646
|
-
case 0:
|
|
647
|
-
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
648
|
-
pages: T_PAGES,
|
|
649
|
-
onRowAction: ON_ROW_ACTION,
|
|
650
|
-
onAction: ON_ACTION
|
|
651
|
-
}), container);
|
|
652
|
-
|
|
653
|
-
case 1:
|
|
654
|
-
case "end":
|
|
655
|
-
return _context21.stop();
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
}, _callee21);
|
|
659
|
-
})));
|
|
660
|
-
|
|
661
|
-
case 6:
|
|
662
|
-
cya = checkCYA(container);
|
|
663
|
-
_cya$childNodes6 = _slicedToArray(cya.childNodes, 2), cyaChildNode = _cya$childNodes6[1];
|
|
664
|
-
names = cyaChildNode.childNodes[0];
|
|
665
|
-
expect(names.tagName).toEqual('DL');
|
|
666
|
-
expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
|
|
667
|
-
_names$childNodes4 = _slicedToArray(names.childNodes, 2), firstName = _names$childNodes4[0], surname = _names$childNodes4[1];
|
|
668
|
-
_firstName$childNodes2 = _slicedToArray(firstName.childNodes, 1), label = _firstName$childNodes2[0];
|
|
669
|
-
expect(label.textContent).toEqual("");
|
|
670
|
-
checkRow(surname, 'Last name', 'Smith', false);
|
|
671
|
-
|
|
672
|
-
case 15:
|
|
673
|
-
case "end":
|
|
674
|
-
return _context22.stop();
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
}, _callee22);
|
|
678
|
-
})));
|
|
679
|
-
});
|
|
680
|
-
});
|