@ukhomeoffice/cop-react-form-renderer 4.67.0 → 4.69.0
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 +6 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +104 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +26 -64
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +428 -555
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +13 -42
- package/dist/components/CollectionPage/CollectionPage.test.js +160 -206
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +35 -79
- package/dist/components/FormComponent/Collection.test.js +340 -391
- package/dist/components/FormComponent/Container.js +10 -31
- package/dist/components/FormComponent/Container.test.js +304 -357
- package/dist/components/FormComponent/FormComponent.js +17 -60
- package/dist/components/FormComponent/FormComponent.test.js +190 -228
- 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 +21 -53
- package/dist/components/FormPage/FormPage.test.js +122 -160
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -296
- package/dist/components/FormRenderer/FormRenderer.test.js +820 -1058
- 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 +12 -16
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +48 -11
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -9
- 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 +4 -7
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +32 -41
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +122 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/FormRenderer/onCYAAction.js +8 -30
- package/dist/components/FormRenderer/onCYAAction.test.js +54 -79
- package/dist/components/FormRenderer/onPageAction.js +123 -0
- package/dist/components/FormRenderer/onPageAction.test.js +632 -0
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/ActionButton.test.js +58 -81
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/PageActions.test.js +95 -120
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +5 -26
- package/dist/components/SummaryList/GroupAction.test.js +14 -28
- package/dist/components/SummaryList/RowAction.js +5 -25
- package/dist/components/SummaryList/RowAction.test.js +14 -28
- package/dist/components/SummaryList/SummaryList.js +7 -31
- package/dist/components/SummaryList/SummaryList.test.js +69 -126
- package/dist/components/SummaryList/SummaryListHeadingRow.js +3 -8
- 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 +9 -31
- package/dist/components/TaskList/Task.test.js +32 -59
- package/dist/components/TaskList/TaskList.js +32 -59
- package/dist/components/TaskList/TaskList.test.js +52 -90
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/TaskState.test.js +23 -41
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -7
- package/dist/context/HooksContext/HooksContext.js +21 -39
- package/dist/context/HooksContext/HooksContext.test.js +18 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +26 -56
- package/dist/context/ValidationContext/ValidationContext.test.js +43 -64
- 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 +17 -36
- package/dist/hooks/useGetRequest.js +57 -93
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +14 -41
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -9
- package/dist/models/PageAction.js +4 -4
- package/dist/models/TaskStates.js +4 -4
- package/dist/models/index.js +1 -10
- package/dist/setupTests.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +1 -19
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +4 -11
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +4 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +3 -11
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +60 -25
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +6 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +2 -9
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +4 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +7 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +4 -32
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +4 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +4 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +4 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +7 -25
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -15
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +1 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +4 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +5 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +1 -2
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +5 -11
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +1 -2
- package/dist/utils/Component/addShowWhen.js +4 -10
- package/dist/utils/Component/addShowWhen.test.js +1 -2
- package/dist/utils/Component/applyToComponentTree.js +4 -18
- package/dist/utils/Component/applyToComponentTree.test.js +4 -8
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/cleanAttributes.test.js +15 -16
- package/dist/utils/Component/elevateNestedComponents.js +0 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -2
- package/dist/utils/Component/getComponent.js +13 -86
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +33 -51
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +12 -29
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +6 -24
- 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.list.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +5 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +10 -34
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +12 -31
- 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 +4 -8
- package/dist/utils/Component/getDefaultValue.test.js +0 -3
- package/dist/utils/Component/index.js +0 -10
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/isEditable.test.js +1 -5
- package/dist/utils/Component/optionIsSelected.js +22 -0
- package/dist/utils/Component/optionIsSelected.test.js +42 -0
- package/dist/utils/Component/setupContainerComponentsPath.js +4 -9
- package/dist/utils/Component/setupContainerComponentsPath.test.js +0 -3
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/showComponent.test.js +1 -2
- 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/meetsAllConditions.test.js +1 -2
- package/dist/utils/Condition/meetsCondition.js +9 -34
- package/dist/utils/Condition/meetsCondition.test.js +21 -14
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/meetsOneCondition.test.js +1 -2
- package/dist/utils/Condition/setupConditions.js +4 -13
- package/dist/utils/Condition/setupConditions.test.js +0 -2
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/getEditableComponents.test.js +1 -12
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +4 -12
- package/dist/utils/Container/setupNesting.test.js +4 -10
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Container/showContainer.test.js +1 -2
- package/dist/utils/Data/applyFormula.js +6 -29
- package/dist/utils/Data/applyFormula.test.js +1 -2
- package/dist/utils/Data/getAutocompleteSource.js +1 -5
- package/dist/utils/Data/getAutocompleteSource.test.js +1 -2
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getDataPath.test.js +0 -4
- package/dist/utils/Data/getOptions.js +4 -14
- package/dist/utils/Data/getOptions.test.js +1 -2
- package/dist/utils/Data/getSourceData.js +6 -21
- package/dist/utils/Data/getSourceData.test.js +4 -6
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +5 -13
- package/dist/utils/Data/refDataToOptions.test.js +1 -2
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setDataItem.test.js +0 -2
- package/dist/utils/Data/setupFormData.js +6 -25
- package/dist/utils/Data/setupFormData.test.js +8 -11
- package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -15
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +1 -3
- package/dist/utils/FormPage/applyConditionalProperties.js +4 -11
- package/dist/utils/FormPage/applyConditionalProperties.test.js +4 -6
- package/dist/utils/FormPage/getFormPage.js +4 -16
- package/dist/utils/FormPage/getFormPage.test.js +10 -9
- package/dist/utils/FormPage/getFormPages.js +4 -9
- package/dist/utils/FormPage/getFormPages.test.js +6 -7
- package/dist/utils/FormPage/getPageActions.js +6 -19
- package/dist/utils/FormPage/getPageActions.test.js +1 -3
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/getParagraphFromText.test.js +1 -3
- package/dist/utils/FormPage/index.js +0 -7
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPage.test.js +0 -2
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -2
- package/dist/utils/FormPage/useComponent.js +7 -19
- package/dist/utils/FormPage/useComponent.test.js +4 -7
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatData.test.js +1 -2
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForComponent.test.js +28 -47
- package/dist/utils/Format/formatDataForForm.js +4 -9
- package/dist/utils/Format/formatDataForForm.test.js +14 -11
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/formatDataForPage.test.js +15 -12
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/getFormHub.test.js +6 -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 +4 -10
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentsForField.js +4 -11
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +4 -16
- package/dist/utils/Meta/index.js +1 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -2
- package/dist/utils/Operate/getFirstOf.js +2 -9
- package/dist/utils/Operate/getFirstOf.test.js +0 -2
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +6 -2
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -4
- package/dist/utils/Operate/runPageOperations.js +3 -19
- package/dist/utils/Operate/runPageOperations.test.js +4 -6
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/setValueInFormData.test.js +0 -2
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Operate/shouldRun.test.js +5 -8
- package/dist/utils/Validate/additional/conditionallyRequired.js +0 -3
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +0 -2
- package/dist/utils/Validate/additional/index.js +1 -22
- 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 +4 -8
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +0 -2
- 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 -3
- 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 +4 -5
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +0 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +0 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +0 -6
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +4 -7
- package/dist/utils/Validate/additional/utils.js +10 -26
- package/dist/utils/Validate/index.js +1 -11
- package/dist/utils/Validate/validateCollection.js +4 -10
- package/dist/utils/Validate/validateCollection.test.js +4 -6
- package/dist/utils/Validate/validateComponent.js +5 -40
- package/dist/utils/Validate/validateComponent.test.js +120 -22
- package/dist/utils/Validate/validateContainer.js +4 -14
- package/dist/utils/Validate/validateContainer.test.js +4 -10
- package/dist/utils/Validate/validateDate.js +6 -38
- package/dist/utils/Validate/validateDate.test.js +0 -4
- package/dist/utils/Validate/validateEmail.js +1 -8
- package/dist/utils/Validate/validateEmail.test.js +5 -4
- package/dist/utils/Validate/validateMultifile.js +0 -7
- package/dist/utils/Validate/validateMultifile.test.js +5 -6
- package/dist/utils/Validate/validatePage.js +4 -16
- package/dist/utils/Validate/validatePage.test.js +30 -25
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRegex.test.js +5 -4
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateRequired.test.js +5 -4
- package/dist/utils/Validate/validateTextArea.js +0 -8
- package/dist/utils/Validate/validateTextArea.test.js +0 -2
- package/dist/utils/Validate/validateTime.js +5 -22
- package/dist/utils/Validate/validateTime.test.js +0 -2
- package/dist/utils/index.js +4 -20
- package/package.json +2 -2
package/dist/setupTests.js
CHANGED
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderWithValidation = exports.renderHookWithProvider = exports.renderDomWithValidation = exports.expectObjectLike = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("@testing-library/react");
|
|
9
|
-
|
|
10
8
|
var _reactHooks = require("@testing-library/react-hooks");
|
|
11
|
-
|
|
12
9
|
var _reactDom = require("react-dom");
|
|
13
|
-
|
|
14
10
|
var _context = require("./context");
|
|
15
|
-
|
|
16
11
|
var renderWithValidation = function renderWithValidation(ui, options) {
|
|
17
12
|
return (0, _react.render)( /*#__PURE__*/React.createElement(_context.HooksContextProvider, {
|
|
18
13
|
overrides: options === null || options === void 0 ? void 0 : options.hooks
|
|
@@ -20,9 +15,7 @@ var renderWithValidation = function renderWithValidation(ui, options) {
|
|
|
20
15
|
key: "vcp"
|
|
21
16
|
}, ui)), options);
|
|
22
17
|
};
|
|
23
|
-
|
|
24
18
|
exports.renderWithValidation = renderWithValidation;
|
|
25
|
-
|
|
26
19
|
var renderDomWithValidation = function renderDomWithValidation(ui, container, options) {
|
|
27
20
|
return (0, _reactDom.render)( /*#__PURE__*/React.createElement(_context.HooksContextProvider, {
|
|
28
21
|
overrides: options === null || options === void 0 ? void 0 : options.hooks
|
|
@@ -30,9 +23,7 @@ var renderDomWithValidation = function renderDomWithValidation(ui, container, op
|
|
|
30
23
|
key: "vcp"
|
|
31
24
|
}, ui)), container);
|
|
32
25
|
};
|
|
33
|
-
|
|
34
26
|
exports.renderDomWithValidation = renderDomWithValidation;
|
|
35
|
-
|
|
36
27
|
var renderHookWithProvider = function renderHookWithProvider(hook, options) {
|
|
37
28
|
var wrapper = function wrapper(_ref) {
|
|
38
29
|
var children = _ref.children;
|
|
@@ -40,20 +31,16 @@ var renderHookWithProvider = function renderHookWithProvider(hook, options) {
|
|
|
40
31
|
overrides: options === null || options === void 0 ? void 0 : options.hooks
|
|
41
32
|
}, children);
|
|
42
33
|
};
|
|
43
|
-
|
|
44
34
|
return (0, _reactHooks.renderHook)(function () {
|
|
45
35
|
return hook();
|
|
46
36
|
}, {
|
|
47
37
|
wrapper: wrapper
|
|
48
38
|
});
|
|
49
39
|
};
|
|
50
|
-
|
|
51
40
|
exports.renderHookWithProvider = renderHookWithProvider;
|
|
52
|
-
|
|
53
41
|
var expectObjectLike = function expectObjectLike(received, expected) {
|
|
54
42
|
Object.keys(expected).forEach(function (key) {
|
|
55
43
|
expect(received[key]).toEqual(expected[key]);
|
|
56
44
|
});
|
|
57
45
|
};
|
|
58
|
-
|
|
59
46
|
exports.expectObjectLike = expectObjectLike;
|
|
@@ -4,20 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var getPageFromCYALink = function getPageFromCYALink(link) {
|
|
9
8
|
if (link.page) {
|
|
10
9
|
return link.page;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
var url = link.href || link.url;
|
|
14
|
-
|
|
15
12
|
if (url) {
|
|
16
13
|
return url.split('/').pop();
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
return undefined;
|
|
20
16
|
};
|
|
17
|
+
|
|
21
18
|
/**
|
|
22
19
|
* Gets an action object, configured appropriately for a Check your answers component.
|
|
23
20
|
*
|
|
@@ -31,11 +28,8 @@ var getPageFromCYALink = function getPageFromCYALink(link) {
|
|
|
31
28
|
* method will convert both by taking the final part of the relative path:
|
|
32
29
|
* - `href: '/bravo'` => `page: 'bravo'`
|
|
33
30
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
31
|
var getCYAAction = function getCYAAction(readonly, page, onAction) {
|
|
37
32
|
var cya_link = page === null || page === void 0 ? void 0 : page.cya_link;
|
|
38
|
-
|
|
39
33
|
if (readonly !== true && cya_link) {
|
|
40
34
|
return {
|
|
41
35
|
page: getPageFromCYALink(cya_link) || page.id || '#',
|
|
@@ -44,9 +38,7 @@ var getCYAAction = function getCYAAction(readonly, page, onAction) {
|
|
|
44
38
|
onAction: onAction
|
|
45
39
|
};
|
|
46
40
|
}
|
|
47
|
-
|
|
48
41
|
return null;
|
|
49
42
|
};
|
|
50
|
-
|
|
51
43
|
var _default = getCYAAction;
|
|
52
44
|
exports.default = _default;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getCYAAction = _interopRequireDefault(require("./getCYAAction"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
// Local imports
|
|
6
|
+
|
|
8
7
|
describe('utils', function () {
|
|
9
8
|
describe('CheckYourAnswers', function () {
|
|
10
9
|
describe('getCYAAction', function () {
|
|
@@ -14,7 +13,6 @@ describe('utils', function () {
|
|
|
14
13
|
id: id
|
|
15
14
|
};
|
|
16
15
|
};
|
|
17
|
-
|
|
18
16
|
it('should return null if readonly', function () {
|
|
19
17
|
expect((0, _getCYAAction.default)(true, {}, function () {})).toBeNull();
|
|
20
18
|
});
|
|
@@ -23,9 +21,7 @@ describe('utils', function () {
|
|
|
23
21
|
});
|
|
24
22
|
it('should return a default action if the cya_link is empty and the page has no id', function () {
|
|
25
23
|
var CYA_LINK = {};
|
|
26
|
-
|
|
27
24
|
var ON_ACTION = function ON_ACTION() {};
|
|
28
|
-
|
|
29
25
|
expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
|
|
30
26
|
page: '#',
|
|
31
27
|
label: 'Change',
|
|
@@ -35,9 +31,7 @@ describe('utils', function () {
|
|
|
35
31
|
it('should return a default action if the cya_link is empty but the page has an id', function () {
|
|
36
32
|
var PAGE_ID = 'page-id';
|
|
37
33
|
var CYA_LINK = {};
|
|
38
|
-
|
|
39
34
|
var ON_ACTION = function ON_ACTION() {};
|
|
40
|
-
|
|
41
35
|
expect((0, _getCYAAction.default)(false, getPage(CYA_LINK, PAGE_ID), ON_ACTION)).toEqual({
|
|
42
36
|
page: PAGE_ID,
|
|
43
37
|
label: 'Change',
|
|
@@ -49,9 +43,7 @@ describe('utils', function () {
|
|
|
49
43
|
var CYA_LINK = {
|
|
50
44
|
page: PAGE
|
|
51
45
|
};
|
|
52
|
-
|
|
53
46
|
var ON_ACTION = function ON_ACTION() {};
|
|
54
|
-
|
|
55
47
|
expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
|
|
56
48
|
page: PAGE,
|
|
57
49
|
label: 'Change',
|
|
@@ -63,9 +55,7 @@ describe('utils', function () {
|
|
|
63
55
|
var CYA_LINK = {
|
|
64
56
|
href: HREF
|
|
65
57
|
};
|
|
66
|
-
|
|
67
58
|
var ON_ACTION = function ON_ACTION() {};
|
|
68
|
-
|
|
69
59
|
expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
|
|
70
60
|
page: 'bravo',
|
|
71
61
|
label: 'Change',
|
|
@@ -77,9 +67,7 @@ describe('utils', function () {
|
|
|
77
67
|
var CYA_LINK = {
|
|
78
68
|
url: URL
|
|
79
69
|
};
|
|
80
|
-
|
|
81
70
|
var ON_ACTION = function ON_ACTION() {};
|
|
82
|
-
|
|
83
71
|
expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
|
|
84
72
|
page: 'bravo',
|
|
85
73
|
label: 'Change',
|
|
@@ -91,9 +79,7 @@ describe('utils', function () {
|
|
|
91
79
|
var CYA_LINK = {
|
|
92
80
|
label: LABEL
|
|
93
81
|
};
|
|
94
|
-
|
|
95
82
|
var ON_ACTION = function ON_ACTION() {};
|
|
96
|
-
|
|
97
83
|
expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
|
|
98
84
|
page: '#',
|
|
99
85
|
label: LABEL,
|
|
@@ -105,9 +91,7 @@ describe('utils', function () {
|
|
|
105
91
|
var CYA_LINK = {
|
|
106
92
|
aria_suffix: ARIA_SUFFIX
|
|
107
93
|
};
|
|
108
|
-
|
|
109
94
|
var ON_ACTION = function ON_ACTION() {};
|
|
110
|
-
|
|
111
95
|
expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
|
|
112
96
|
page: '#',
|
|
113
97
|
label: 'Change',
|
|
@@ -124,9 +108,7 @@ describe('utils', function () {
|
|
|
124
108
|
page: PAGE,
|
|
125
109
|
aria_suffix: ARIA_SUFFIX
|
|
126
110
|
};
|
|
127
|
-
|
|
128
111
|
var ON_ACTION = function ON_ACTION() {};
|
|
129
|
-
|
|
130
112
|
expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
|
|
131
113
|
page: PAGE,
|
|
132
114
|
label: LABEL,
|
|
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _models = require("../../models");
|
|
11
|
-
|
|
9
|
+
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); }
|
|
12
10
|
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; }
|
|
13
|
-
|
|
14
11
|
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; }
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
15
|
var getCYACollectionChangeAction = function getCYACollectionChangeAction(page, item, _onAction, labelCount, action) {
|
|
19
16
|
var label = (action === null || action === void 0 ? void 0 : action.label) || _models.CollectionLabels.change;
|
|
20
17
|
return {
|
|
@@ -28,15 +25,12 @@ var getCYACollectionChangeAction = function getCYACollectionChangeAction(page, i
|
|
|
28
25
|
data["".concat(page.collection.name, "ActiveId")] = item.id;
|
|
29
26
|
return data;
|
|
30
27
|
};
|
|
31
|
-
|
|
32
28
|
var nextPage = row;
|
|
33
|
-
|
|
34
29
|
if (action.page) {
|
|
35
30
|
nextPage = {
|
|
36
31
|
pageId: action.page
|
|
37
32
|
};
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
_onAction(nextPage, changeCallback);
|
|
41
35
|
},
|
|
42
36
|
label: _copReactComponents.Utils.interpolateString(label, _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -45,6 +39,5 @@ var getCYACollectionChangeAction = function getCYACollectionChangeAction(page, i
|
|
|
45
39
|
}
|
|
46
40
|
};
|
|
47
41
|
};
|
|
48
|
-
|
|
49
42
|
var _default = getCYACollectionChangeAction;
|
|
50
43
|
exports.default = _default;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getCYACollectionChangeAction = _interopRequireDefault(require("./getCYACollectionChangeAction"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
5
|
+
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); }
|
|
7
6
|
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
7
|
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
|
|
12
|
-
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
11
|
describe('utils', function () {
|
|
14
12
|
describe('CheckYourAnswers', function () {
|
|
15
13
|
describe('getCYACollectionChangeAction', function () {
|
|
@@ -38,7 +36,6 @@ describe('utils', function () {
|
|
|
38
36
|
expect(row.id).toEqual(2);
|
|
39
37
|
TEST_DATA = call_back(TEST_DATA);
|
|
40
38
|
};
|
|
41
|
-
|
|
42
39
|
var action = (0, _getCYACollectionChangeAction.default)(PAGE, ITEM, ON_ACTION, 0, {});
|
|
43
40
|
action.action.onAction(PAGE);
|
|
44
41
|
expect(TEST_DATA.collectionNameActiveId).toEqual(2);
|
|
@@ -61,12 +58,10 @@ describe('utils', function () {
|
|
|
61
58
|
}]
|
|
62
59
|
}
|
|
63
60
|
};
|
|
64
|
-
|
|
65
61
|
var ON_ACTION = function ON_ACTION(page, call_back) {
|
|
66
62
|
expect(page.pageId).toEqual('confirmDelete');
|
|
67
63
|
TEST_DATA = call_back(TEST_DATA);
|
|
68
64
|
};
|
|
69
|
-
|
|
70
65
|
var action = (0, _getCYACollectionChangeAction.default)(PAGE_WITH_CUSTOM_DESTINATION, ITEM, ON_ACTION, 0, PAGE_WITH_CUSTOM_DESTINATION.collection.actions[0]);
|
|
71
66
|
action.action.onAction({});
|
|
72
67
|
expect(TEST_DATA.collectionNameActiveId).toEqual(2);
|
|
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _models = require("../../models");
|
|
11
|
-
|
|
9
|
+
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); }
|
|
12
10
|
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; }
|
|
13
|
-
|
|
14
11
|
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; }
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
15
|
var getCYACollectionDeleteAction = function getCYACollectionDeleteAction(page, item, _onAction, labelCount, action) {
|
|
19
16
|
var label = (action === null || action === void 0 ? void 0 : action.label) || _models.CollectionLabels.remove;
|
|
20
17
|
return {
|
|
@@ -30,7 +27,6 @@ var getCYACollectionDeleteAction = function getCYACollectionDeleteAction(page, i
|
|
|
30
27
|
});
|
|
31
28
|
return data;
|
|
32
29
|
};
|
|
33
|
-
|
|
34
30
|
_onAction(null, deleteCallback);
|
|
35
31
|
},
|
|
36
32
|
label: _copReactComponents.Utils.interpolateString(label, _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -39,6 +35,5 @@ var getCYACollectionDeleteAction = function getCYACollectionDeleteAction(page, i
|
|
|
39
35
|
}
|
|
40
36
|
};
|
|
41
37
|
};
|
|
42
|
-
|
|
43
38
|
var _default = getCYACollectionDeleteAction;
|
|
44
39
|
exports.default = _default;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getCYACollectionDeleteAction = _interopRequireDefault(require("./getCYACollectionDeleteAction"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
5
|
+
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); }
|
|
7
6
|
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
7
|
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
|
|
12
|
-
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
11
|
describe('utils', function () {
|
|
14
12
|
describe('CheckYourAnswers', function () {
|
|
15
13
|
describe('getCYACollectionDeleteAction', function () {
|
|
@@ -37,11 +35,9 @@ describe('utils', function () {
|
|
|
37
35
|
};
|
|
38
36
|
it('should remove selected item from the form data', function () {
|
|
39
37
|
var data = null;
|
|
40
|
-
|
|
41
38
|
var ON_ACTION = function ON_ACTION(_, call_back) {
|
|
42
39
|
data = call_back(TEST_DATA);
|
|
43
40
|
};
|
|
44
|
-
|
|
45
41
|
var action = (0, _getCYACollectionDeleteAction.default)(PAGE, ITEM, ON_ACTION, 0, {});
|
|
46
42
|
action.action.onAction();
|
|
47
43
|
expect(data.collectionName.length).toEqual(2);
|
|
@@ -4,16 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _Component = _interopRequireDefault(require("../Component"));
|
|
11
|
-
|
|
9
|
+
var _optionIsSelected = _interopRequireDefault(require("../Component/optionIsSelected"));
|
|
12
10
|
var _getCYAAction = _interopRequireDefault(require("./getCYAAction"));
|
|
13
|
-
|
|
14
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
12
|
// Global imports
|
|
13
|
+
|
|
17
14
|
// Local imports
|
|
18
15
|
|
|
19
16
|
/**
|
|
@@ -27,12 +24,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
24
|
*/
|
|
28
25
|
var getCYARow = function getCYARow(page, component, onAction) {
|
|
29
26
|
var value = '';
|
|
30
|
-
|
|
31
27
|
if (page.formData && component.fieldId) {
|
|
32
28
|
value = page.formData[component.fieldId];
|
|
33
29
|
setNestedValue(component, page);
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
return {
|
|
37
32
|
pageId: page.id,
|
|
38
33
|
id: component.id,
|
|
@@ -45,19 +40,16 @@ var getCYARow = function getCYARow(page, component, onAction) {
|
|
|
45
40
|
action: (0, _getCYAAction.default)(component.readonly, page, onAction)
|
|
46
41
|
};
|
|
47
42
|
};
|
|
48
|
-
|
|
49
43
|
var setNestedValue = function setNestedValue(component, page) {
|
|
50
44
|
var _component$data, _component$data$optio;
|
|
51
|
-
|
|
52
45
|
(_component$data = component.data) === null || _component$data === void 0 ? void 0 : (_component$data$optio = _component$data.options) === null || _component$data$optio === void 0 ? void 0 : _component$data$optio.forEach(function (option) {
|
|
53
46
|
//check if option is selected and has nested component
|
|
54
|
-
if (Array.isArray(option.nested) && page.formData[component.id]
|
|
47
|
+
if (Array.isArray(option.nested) && (0, _optionIsSelected.default)(page.formData[component.id], option)) {
|
|
55
48
|
option.nested.forEach(function (child) {
|
|
56
49
|
child.value = page.formData[child.id];
|
|
57
50
|
});
|
|
58
51
|
}
|
|
59
52
|
});
|
|
60
53
|
};
|
|
61
|
-
|
|
62
54
|
var _default = getCYARow;
|
|
63
55
|
exports.default = _default;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _setupTests = require("../../setupTests");
|
|
4
|
-
|
|
5
4
|
var _getCYARow = _interopRequireDefault(require("./getCYARow"));
|
|
6
|
-
|
|
7
5
|
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
|
-
|
|
6
|
+
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); }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
9
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
10
|
describe('utils', function () {
|
|
12
11
|
describe('CheckYourAnswers', function () {
|
|
13
12
|
describe('getCYARow', function () {
|
|
@@ -25,9 +24,7 @@ describe('utils', function () {
|
|
|
25
24
|
fieldId: 'a',
|
|
26
25
|
label: 'Alpha'
|
|
27
26
|
};
|
|
28
|
-
|
|
29
27
|
var ON_ACTION = function ON_ACTION() {};
|
|
30
|
-
|
|
31
28
|
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
32
29
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
33
30
|
pageId: PAGE.id,
|
|
@@ -50,9 +47,7 @@ describe('utils', function () {
|
|
|
50
47
|
fieldId: 'a',
|
|
51
48
|
label: 'Alpha'
|
|
52
49
|
};
|
|
53
|
-
|
|
54
50
|
var ON_ACTION = function ON_ACTION() {};
|
|
55
|
-
|
|
56
51
|
expect((0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION)).toEqual({
|
|
57
52
|
pageId: PAGE.id,
|
|
58
53
|
id: COMPONENT.id,
|
|
@@ -77,9 +72,7 @@ describe('utils', function () {
|
|
|
77
72
|
fieldId: 'a',
|
|
78
73
|
label: 'Alpha'
|
|
79
74
|
};
|
|
80
|
-
|
|
81
75
|
var ON_ACTION = function ON_ACTION() {};
|
|
82
|
-
|
|
83
76
|
expect((0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION)).toEqual({
|
|
84
77
|
pageId: PAGE.id,
|
|
85
78
|
id: COMPONENT.id,
|
|
@@ -103,9 +96,7 @@ describe('utils', function () {
|
|
|
103
96
|
fieldId: 'a',
|
|
104
97
|
cya_label: 'CYA Alpha'
|
|
105
98
|
};
|
|
106
|
-
|
|
107
99
|
var ON_ACTION = function ON_ACTION() {};
|
|
108
|
-
|
|
109
100
|
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
110
101
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
111
102
|
pageId: PAGE.id,
|
|
@@ -130,9 +121,7 @@ describe('utils', function () {
|
|
|
130
121
|
fieldId: 'a',
|
|
131
122
|
label: 'Alpha'
|
|
132
123
|
};
|
|
133
|
-
|
|
134
124
|
var ON_ACTION = function ON_ACTION() {};
|
|
135
|
-
|
|
136
125
|
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
137
126
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
138
127
|
pageId: PAGE.id,
|
|
@@ -145,7 +134,7 @@ describe('utils', function () {
|
|
|
145
134
|
onAction: ON_ACTION
|
|
146
135
|
});
|
|
147
136
|
});
|
|
148
|
-
it('should update any nested components with corresponding values from the stored formdata', function () {
|
|
137
|
+
it('should update any nested components in radios with corresponding values from the stored formdata', function () {
|
|
149
138
|
var SELECTED_VALUE = 'selectedValue';
|
|
150
139
|
var NESTED_ID = 'nestedId';
|
|
151
140
|
var NESTED_VALUE = 'nestedValue';
|
|
@@ -172,7 +161,7 @@ describe('utils', function () {
|
|
|
172
161
|
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
|
|
173
162
|
expect(ROW.component.data.options[0].nested[0].value).toEqual(NESTED_VALUE);
|
|
174
163
|
});
|
|
175
|
-
it('should handle an undefined formData when attempting to set nested values', function () {
|
|
164
|
+
it('should handle an undefined formData when attempting to set nested values in radios', function () {
|
|
176
165
|
var SELECTED_VALUE = 'selectedValue';
|
|
177
166
|
var NESTED_ID = 'nestedId';
|
|
178
167
|
var PAGE = {
|
|
@@ -195,14 +184,64 @@ describe('utils', function () {
|
|
|
195
184
|
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
|
|
196
185
|
expect(ROW.component.data.options[0].nested[0].value).toBeUndefined();
|
|
197
186
|
});
|
|
187
|
+
it('should update any nested components in checkboxes with corresponding values from the stored formdata', function () {
|
|
188
|
+
var SELECTED_VALUE = 'selectedValue';
|
|
189
|
+
var NESTED_ID = 'nestedId';
|
|
190
|
+
var NESTED_VALUE = 'nestedValue';
|
|
191
|
+
var PAGE = {
|
|
192
|
+
id: 'page',
|
|
193
|
+
formData: _defineProperty({
|
|
194
|
+
a: [SELECTED_VALUE]
|
|
195
|
+
}, NESTED_ID, NESTED_VALUE),
|
|
196
|
+
cya_link: {}
|
|
197
|
+
};
|
|
198
|
+
var COMPONENT = {
|
|
199
|
+
type: 'checkboxes',
|
|
200
|
+
id: 'a',
|
|
201
|
+
fieldId: 'a',
|
|
202
|
+
data: {
|
|
203
|
+
options: [{
|
|
204
|
+
value: SELECTED_VALUE,
|
|
205
|
+
nested: [{
|
|
206
|
+
id: NESTED_ID
|
|
207
|
+
}]
|
|
208
|
+
}]
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
|
|
212
|
+
expect(ROW.component.data.options[0].nested[0].value).toEqual(NESTED_VALUE);
|
|
213
|
+
});
|
|
214
|
+
it('should handle an undefined formData when attempting to set nested values in checkboxes', function () {
|
|
215
|
+
var SELECTED_VALUE = 'selectedValue';
|
|
216
|
+
var NESTED_ID = 'nestedId';
|
|
217
|
+
var PAGE = {
|
|
218
|
+
id: 'page',
|
|
219
|
+
cya_link: {}
|
|
220
|
+
};
|
|
221
|
+
var COMPONENT = {
|
|
222
|
+
type: 'checkboxes',
|
|
223
|
+
id: 'a',
|
|
224
|
+
fieldId: 'a',
|
|
225
|
+
data: {
|
|
226
|
+
options: [{
|
|
227
|
+
value: SELECTED_VALUE,
|
|
228
|
+
nested: [{
|
|
229
|
+
id: NESTED_ID
|
|
230
|
+
}]
|
|
231
|
+
}]
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
|
|
235
|
+
expect(ROW.component.data.options[0].nested[0].value).toBeUndefined();
|
|
236
|
+
});
|
|
198
237
|
it('should get an appropriate row for a readonly text component with no value and interpolated label', function () {
|
|
199
238
|
var PAGE = {
|
|
200
239
|
id: 'page',
|
|
201
240
|
formData: {
|
|
202
241
|
text: 'Smith'
|
|
203
242
|
}
|
|
204
|
-
};
|
|
205
|
-
|
|
243
|
+
};
|
|
244
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
206
245
|
var COMPONENT = {
|
|
207
246
|
type: 'text',
|
|
208
247
|
readonly: true,
|
|
@@ -210,9 +249,7 @@ describe('utils', function () {
|
|
|
210
249
|
fieldId: 'a',
|
|
211
250
|
label: 'Alpha ${text}'
|
|
212
251
|
};
|
|
213
|
-
|
|
214
252
|
var ON_ACTION = function ON_ACTION() {};
|
|
215
|
-
|
|
216
253
|
expect((0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION)).toEqual({
|
|
217
254
|
pageId: PAGE.id,
|
|
218
255
|
id: COMPONENT.id,
|
|
@@ -229,8 +266,8 @@ describe('utils', function () {
|
|
|
229
266
|
formData: {
|
|
230
267
|
a: 'Bravo'
|
|
231
268
|
}
|
|
232
|
-
};
|
|
233
|
-
|
|
269
|
+
};
|
|
270
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
234
271
|
var COMPONENT = {
|
|
235
272
|
type: 'text',
|
|
236
273
|
readonly: true,
|
|
@@ -238,9 +275,7 @@ describe('utils', function () {
|
|
|
238
275
|
fieldId: 'a',
|
|
239
276
|
cya_label: 'CYA Alpha ${a}'
|
|
240
277
|
};
|
|
241
|
-
|
|
242
278
|
var ON_ACTION = function ON_ACTION() {};
|
|
243
|
-
|
|
244
279
|
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
245
280
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
246
281
|
pageId: PAGE.id,
|