@ukhomeoffice/cop-react-form-renderer 5.14.0 → 5.14.4
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 +15 -15
- package/dist/components/CheckYourAnswers/Answer.test.js +94 -128
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +99 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +291 -501
- package/dist/components/CheckYourAnswers/index.js +2 -3
- package/dist/components/CollectionPage/CollectionPage.js +64 -58
- package/dist/components/CollectionPage/CollectionPage.test.js +212 -238
- package/dist/components/CollectionPage/index.js +2 -3
- package/dist/components/FormComponent/Collection.js +77 -113
- package/dist/components/FormComponent/Collection.test.js +688 -787
- package/dist/components/FormComponent/Container.js +44 -43
- package/dist/components/FormComponent/Container.test.js +316 -346
- package/dist/components/FormComponent/FormComponent.js +58 -64
- package/dist/components/FormComponent/FormComponent.test.js +180 -219
- package/dist/components/FormComponent/helpers/addLabel.js +5 -9
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +2 -3
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +2 -2
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
- package/dist/components/FormComponent/helpers/index.js +5 -5
- package/dist/components/FormComponent/index.js +2 -3
- package/dist/components/FormPage/FormPage.js +65 -79
- package/dist/components/FormPage/FormPage.test.js +134 -170
- package/dist/components/FormPage/index.js +2 -3
- package/dist/components/FormRenderer/FormRenderer.js +151 -193
- package/dist/components/FormRenderer/FormRenderer.test.js +598 -920
- package/dist/components/FormRenderer/handlers/cyaAction.js +4 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +2 -5
- package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
- package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
- package/dist/components/FormRenderer/handlers/index.js +3 -4
- package/dist/components/FormRenderer/handlers/navigate.js +5 -6
- package/dist/components/FormRenderer/handlers/submissionError.js +2 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.js +2 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +10 -10
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +2 -5
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +19 -27
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +17 -17
- package/dist/components/FormRenderer/helpers/getCYA.js +6 -9
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -10
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +19 -34
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +3 -6
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -13
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +12 -13
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +98 -92
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +66 -66
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +72 -79
- package/dist/components/FormRenderer/helpers/index.js +3 -4
- package/dist/components/FormRenderer/index.js +2 -3
- package/dist/components/FormRenderer/onCYAAction.js +52 -62
- package/dist/components/FormRenderer/onCYAAction.test.js +146 -138
- package/dist/components/FormRenderer/onPageAction.js +48 -47
- package/dist/components/FormRenderer/onPageAction.test.js +219 -205
- package/dist/components/FormRenderer/onTaskAction.js +12 -17
- package/dist/components/FormRenderer/onTaskAction.test.js +94 -89
- package/dist/components/PageActions/ActionButton.js +15 -19
- package/dist/components/PageActions/ActionButton.test.js +58 -79
- package/dist/components/PageActions/PageActions.js +12 -13
- package/dist/components/PageActions/PageActions.test.js +88 -116
- package/dist/components/PageActions/index.js +2 -3
- package/dist/components/SummaryList/GroupAction.js +15 -23
- package/dist/components/SummaryList/GroupAction.test.js +41 -37
- package/dist/components/SummaryList/RowAction.js +14 -19
- package/dist/components/SummaryList/RowAction.test.js +41 -37
- package/dist/components/SummaryList/SummaryList.js +25 -30
- package/dist/components/SummaryList/SummaryList.test.js +160 -182
- package/dist/components/SummaryList/SummaryListHeadingRow.js +9 -8
- package/dist/components/SummaryList/SummaryListRow.js +9 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +8 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -8
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -8
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/index.js +2 -2
- package/dist/components/SummaryList/index.js +2 -3
- package/dist/components/TaskList/Task.js +22 -33
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +46 -75
- package/dist/components/TaskList/TaskList.test.js +118 -113
- package/dist/components/TaskList/TaskState.js +9 -9
- package/dist/components/TaskList/TaskState.test.js +56 -49
- package/dist/components/TaskList/index.js +2 -3
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +59 -85
- package/dist/context/HooksContext/HooksContext.test.js +28 -36
- package/dist/context/HooksContext/index.js +4 -6
- package/dist/context/ValidationContext/ValidationContext.js +35 -76
- package/dist/context/ValidationContext/ValidationContext.test.js +50 -61
- package/dist/context/ValidationContext/index.js +4 -6
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +17 -43
- package/dist/hooks/useGetRequest.js +65 -106
- package/dist/hooks/useHooks.js +2 -5
- package/dist/hooks/useRefData.js +30 -45
- package/dist/hooks/useValidation.js +2 -5
- package/dist/index.js +15 -17
- package/dist/models/CollectionLabels.js +2 -3
- package/dist/models/ComponentTypes.js +25 -26
- package/dist/models/EventTypes.js +5 -6
- package/dist/models/FormPages.js +5 -6
- package/dist/models/FormTypes.js +9 -10
- package/dist/models/HubFormats.js +4 -5
- package/dist/models/PageAction.js +45 -42
- package/dist/models/TaskStates.js +30 -31
- package/dist/models/index.js +11 -12
- package/dist/setupTests.js +20 -24
- package/dist/utils/CheckYourAnswers/getCYAAction.js +6 -7
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +18 -20
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +21 -23
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +18 -20
- package/dist/utils/CheckYourAnswers/getCYARow.js +8 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +72 -72
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +20 -27
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +41 -47
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +72 -75
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +71 -78
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +133 -114
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +27 -23
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +16 -23
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +77 -83
- package/dist/utils/CheckYourAnswers/index.js +3 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +7 -9
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +9 -16
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +19 -20
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +4 -8
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +15 -15
- package/dist/utils/CollectionPage/index.js +3 -4
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -29
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +15 -15
- package/dist/utils/Component/addShowWhen.js +5 -10
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +20 -22
- package/dist/utils/Component/applyToComponentTree.test.js +28 -33
- package/dist/utils/Component/cleanAttributes.js +11 -16
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +7 -9
- package/dist/utils/Component/elevateNestedComponents.test.js +19 -19
- package/dist/utils/Component/getComponent.js +91 -99
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +51 -63
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +41 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -37
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +12 -11
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +24 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +59 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +35 -41
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +24 -32
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
- package/dist/utils/Component/getDefaultValue.js +7 -9
- package/dist/utils/Component/getDefaultValue.test.js +14 -14
- package/dist/utils/Component/index.js +3 -4
- package/dist/utils/Component/isEditable.js +3 -7
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -3
- package/dist/utils/Component/optionIsSelected.test.js +10 -10
- package/dist/utils/Component/setupContainerComponentsPath.js +30 -33
- package/dist/utils/Component/setupContainerComponentsPath.test.js +16 -16
- package/dist/utils/Component/showComponent.js +4 -6
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +6 -6
- package/dist/utils/Condition/index.js +3 -4
- package/dist/utils/Condition/meetsAllConditions.js +9 -10
- package/dist/utils/Condition/meetsAllConditions.test.js +18 -18
- package/dist/utils/Condition/meetsCondition.js +19 -27
- package/dist/utils/Condition/meetsCondition.test.js +377 -377
- package/dist/utils/Condition/meetsOneCondition.js +7 -8
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +15 -21
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +5 -8
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +3 -4
- package/dist/utils/Container/setupNesting.js +17 -24
- package/dist/utils/Container/setupNesting.test.js +28 -31
- package/dist/utils/Container/showContainer.js +5 -10
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +41 -52
- package/dist/utils/Data/applyFormula.test.js +26 -26
- package/dist/utils/Data/getAutocompleteSource.js +11 -14
- package/dist/utils/Data/getAutocompleteSource.test.js +59 -59
- package/dist/utils/Data/getDataPath.js +21 -32
- package/dist/utils/Data/getDataPath.test.js +20 -20
- package/dist/utils/Data/getOptions.js +22 -28
- package/dist/utils/Data/getOptions.test.js +21 -21
- package/dist/utils/Data/getSourceData.js +7 -21
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +3 -4
- package/dist/utils/Data/refDataToOptions.js +12 -17
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +8 -10
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +32 -48
- package/dist/utils/Data/setupFormData.test.js +99 -98
- package/dist/utils/Data/setupRefDataUrlForComponent.js +22 -30
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +28 -28
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -12
- package/dist/utils/FormPage/applyConditionalProperties.test.js +16 -19
- package/dist/utils/FormPage/getFormPage.js +17 -19
- package/dist/utils/FormPage/getFormPage.test.js +49 -48
- package/dist/utils/FormPage/getFormPages.js +9 -15
- package/dist/utils/FormPage/getFormPages.test.js +22 -25
- package/dist/utils/FormPage/getPageActions.js +11 -19
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +6 -9
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -4
- package/dist/utils/FormPage/showFormPage.js +5 -10
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +4 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +21 -29
- package/dist/utils/FormPage/useComponent.test.js +71 -73
- package/dist/utils/Format/formatData.js +2 -3
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -9
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +7 -10
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -7
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +3 -4
- package/dist/utils/Hub/getFormHub.js +3 -4
- package/dist/utils/Hub/getFormHub.test.js +29 -32
- package/dist/utils/Hub/index.js +3 -4
- package/dist/utils/Meta/constants.js +2 -4
- package/dist/utils/Meta/documents/getDocuments.js +2 -6
- package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
- package/dist/utils/Meta/documents/index.js +3 -4
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -19
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +69 -35
- package/dist/utils/Meta/index.js +3 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +5 -6
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/getFirstOf.js +9 -10
- package/dist/utils/Operate/getFirstOf.test.js +33 -33
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +13 -14
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/index.js +3 -4
- package/dist/utils/Operate/persistValueInFormData.js +7 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +10 -11
- package/dist/utils/Operate/runPageOperations.test.js +36 -37
- package/dist/utils/Operate/setValueInFormData.js +6 -7
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +9 -10
- package/dist/utils/Operate/shouldRun.test.js +22 -28
- package/dist/utils/Validate/additional/conditionallyRequired.js +5 -7
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -9
- package/dist/utils/Validate/additional/index.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeAfter.js +4 -5
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +4 -5
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -14
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +34 -38
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +3 -4
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +5 -6
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +6 -7
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +3 -4
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +2 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +3 -4
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeShorterThan.js +2 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +4 -7
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +2 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +4 -7
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -25
- package/dist/utils/Validate/index.js +3 -4
- package/dist/utils/Validate/validateCollection.js +22 -29
- package/dist/utils/Validate/validateCollection.test.js +85 -77
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +169 -147
- package/dist/utils/Validate/validateContainer.js +16 -22
- package/dist/utils/Validate/validateContainer.test.js +52 -48
- package/dist/utils/Validate/validateDate.js +14 -21
- package/dist/utils/Validate/validateDate.test.js +28 -29
- package/dist/utils/Validate/validateEmail.js +8 -11
- package/dist/utils/Validate/validateEmail.test.js +26 -26
- package/dist/utils/Validate/validateMultifile.js +6 -10
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +20 -22
- package/dist/utils/Validate/validatePage.test.js +146 -143
- package/dist/utils/Validate/validateRegex.js +6 -10
- package/dist/utils/Validate/validateRegex.test.js +17 -17
- package/dist/utils/Validate/validateRequired.js +6 -9
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +6 -9
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +8 -16
- package/dist/utils/Validate/validateTime.test.js +15 -15
- package/dist/utils/index.js +10 -12
- package/package.json +9 -6
|
@@ -8,105 +8,95 @@ var _models = require("../../models");
|
|
|
8
8
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
9
9
|
var _handlers = _interopRequireDefault(require("./handlers"));
|
|
10
10
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
11
|
-
function _interopRequireDefault(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
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
|
-
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; }
|
|
16
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
|
-
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
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
// Local imports.
|
|
13
|
+
|
|
18
14
|
/**
|
|
19
15
|
*
|
|
20
16
|
* @param {*} action
|
|
21
17
|
*/
|
|
22
|
-
|
|
18
|
+
const onCYAAction = (setPagePoint, action, pages, validate, components, data, setData, type, pageId, currentTask, hooks, addErrors, hub, onPageChange, formState) => {
|
|
23
19
|
// Check to see whether the action is able to proceed, which in
|
|
24
20
|
// in the case of a submission will validate the fields in the page.
|
|
25
21
|
if (action.type === _models.PageAction.TYPES.SUBMIT && hub !== _models.HubFormats.TASK) {
|
|
26
22
|
setPagePoint('submit');
|
|
27
23
|
if (_helpers.default.canCYASubmit(pages, validate.pages)) {
|
|
28
24
|
// Submit.
|
|
29
|
-
|
|
30
|
-
pages
|
|
31
|
-
components
|
|
32
|
-
},
|
|
25
|
+
const submissionData = _utils.default.Format.form({
|
|
26
|
+
pages,
|
|
27
|
+
components
|
|
28
|
+
}, {
|
|
29
|
+
...data
|
|
30
|
+
}, _models.EventTypes.SUBMIT);
|
|
33
31
|
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
34
32
|
setData(submissionData);
|
|
35
33
|
// Now submit the data to the backend...
|
|
36
|
-
hooks.onSubmit(action.type, submissionData,
|
|
37
|
-
return hooks.onFormComplete();
|
|
38
|
-
}, function (errors) {
|
|
39
|
-
return _handlers.default.submissionError(errors, addErrors);
|
|
40
|
-
});
|
|
34
|
+
hooks.onSubmit(action.type, submissionData, () => hooks.onFormComplete(), errors => _handlers.default.submissionError(errors, addErrors));
|
|
41
35
|
}
|
|
42
36
|
}
|
|
43
37
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_CONTINUE && hub === _models.HubFormats.TASK) {
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
const shouldValidate = !(Object.prototype.hasOwnProperty.call(action, 'validate') && !action.validate);
|
|
39
|
+
const canSubmit = shouldValidate ? _helpers.default.canCYASubmit(currentTask.fullPages, validate.pages) : true;
|
|
46
40
|
if (canSubmit) {
|
|
47
|
-
|
|
48
|
-
pages
|
|
49
|
-
components
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return _handlers.default.submissionError(errors, addErrors);
|
|
57
|
-
});
|
|
41
|
+
const submissionData = _utils.default.Format.form({
|
|
42
|
+
pages,
|
|
43
|
+
components
|
|
44
|
+
}, {
|
|
45
|
+
...data
|
|
46
|
+
}, _models.EventTypes.SUBMIT);
|
|
47
|
+
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
48
|
+
setData(submissionData);
|
|
49
|
+
hooks.onSubmit(action.type, submissionData, () => onPageChange(_models.FormPages.HUB), errors => _handlers.default.submissionError(errors, addErrors));
|
|
58
50
|
}
|
|
59
51
|
}
|
|
60
52
|
if (action.type === _models.PageAction.TYPES.SUBMIT && hub === _models.HubFormats.TASK) {
|
|
61
53
|
setPagePoint('submit');
|
|
62
54
|
if (_helpers.default.canCYASubmit(currentTask.fullPages, validate.pages)) {
|
|
63
55
|
// Submit.
|
|
64
|
-
|
|
65
|
-
pages
|
|
66
|
-
components
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
const submissionData = _utils.default.Format.form({
|
|
57
|
+
pages,
|
|
58
|
+
components
|
|
59
|
+
}, {
|
|
60
|
+
...data
|
|
61
|
+
}, _models.EventTypes.SUBMIT);
|
|
62
|
+
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
63
|
+
setData(submissionData);
|
|
70
64
|
// Now submit the data to the backend...
|
|
71
|
-
hooks.onSubmit(action.type,
|
|
72
|
-
return hooks.onFormComplete();
|
|
73
|
-
}, function (errors) {
|
|
74
|
-
return _handlers.default.submissionError(errors, addErrors);
|
|
75
|
-
});
|
|
65
|
+
hooks.onSubmit(action.type, submissionData, () => hooks.onFormComplete(), errors => _handlers.default.submissionError(errors, addErrors));
|
|
76
66
|
}
|
|
77
67
|
}
|
|
78
68
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_RETURN) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
pages
|
|
84
|
-
components
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
const shouldValidate = !(Object.prototype.hasOwnProperty.call(action, 'validate') && !action.validate);
|
|
70
|
+
const canSubmit = shouldValidate ? _helpers.default.canCYASubmit(currentTask.fullPages, validate.pages) : true;
|
|
71
|
+
if (canSubmit) {
|
|
72
|
+
const submissionData = _utils.default.Format.form({
|
|
73
|
+
pages,
|
|
74
|
+
components
|
|
75
|
+
}, {
|
|
76
|
+
...data
|
|
77
|
+
}, _models.EventTypes.SUBMIT);
|
|
78
|
+
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, false);
|
|
79
|
+
setData(submissionData);
|
|
80
|
+
hooks.onSubmit(action.type, submissionData, () => {
|
|
89
81
|
if (type === _models.FormTypes.TASK) {
|
|
90
82
|
onPageChange(undefined);
|
|
91
83
|
} else {
|
|
92
84
|
onPageChange(_models.FormPages.HUB);
|
|
93
85
|
}
|
|
94
|
-
},
|
|
95
|
-
return _handlers.default.submissionError(errors, addErrors);
|
|
96
|
-
});
|
|
86
|
+
}, errors => _handlers.default.submissionError(errors, addErrors));
|
|
97
87
|
}
|
|
98
88
|
}
|
|
99
89
|
if (action.type === _models.PageAction.TYPES.NAVIGATE) {
|
|
100
|
-
|
|
101
|
-
onPageChange(_helpers.default.getNextPageId(type, pages, pageId, action, (_formState$page = formState.page) === null || _formState$page === void 0 ? void 0 : _formState$page.formData));
|
|
90
|
+
onPageChange(_helpers.default.getNextPageId(type, pages, pageId, action, formState.page?.formData));
|
|
102
91
|
}
|
|
103
92
|
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
104
|
-
|
|
105
|
-
pages
|
|
106
|
-
components
|
|
107
|
-
},
|
|
93
|
+
const formData = _utils.default.Format.form({
|
|
94
|
+
pages,
|
|
95
|
+
components
|
|
96
|
+
}, {
|
|
97
|
+
...data
|
|
98
|
+
}, _models.EventTypes.CANCEL);
|
|
108
99
|
hooks.onCancel(formData);
|
|
109
100
|
}
|
|
110
101
|
};
|
|
111
|
-
var _default = onCYAAction;
|
|
112
|
-
exports.default = _default;
|
|
102
|
+
var _default = exports.default = onCYAAction;
|
|
@@ -5,88 +5,76 @@ var _utils = _interopRequireDefault(require("../../utils"));
|
|
|
5
5
|
var _handlers = _interopRequireDefault(require("./handlers"));
|
|
6
6
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
7
7
|
var _onCYAAction = _interopRequireDefault(require("./onCYAAction"));
|
|
8
|
-
function _interopRequireDefault(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
submissionErrorCalls: 0,
|
|
18
|
-
submissionErrorArgs: [],
|
|
19
|
-
submissionError: function submissionError(errors, addErrors) {
|
|
20
|
-
this.submissionErrorCalls += 1;
|
|
21
|
-
this.submissionErrorArgs.push(errors);
|
|
22
|
-
if (typeof addErrors === 'function') {
|
|
23
|
-
addErrors(errors);
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
reset: function reset() {
|
|
27
|
-
this.submissionErrorCalls = 0;
|
|
28
|
-
this.submissionErrorArgs = [];
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
jest.mock('./helpers', function () {
|
|
33
|
-
return {
|
|
34
|
-
canCYASubmitResult: true,
|
|
35
|
-
canCYASubmitCalls: 0,
|
|
36
|
-
canCYASubmit: function canCYASubmit() {
|
|
37
|
-
this.canCYASubmitCalls += 1;
|
|
38
|
-
return this.canCYASubmitResult;
|
|
39
|
-
},
|
|
40
|
-
getNextPageIdCalls: 0,
|
|
41
|
-
getNextPageId: function getNextPageId() {
|
|
42
|
-
this.getNextPageIdCalls += 1;
|
|
43
|
-
return 'page2';
|
|
44
|
-
},
|
|
45
|
-
getFormStateCalls: 0,
|
|
46
|
-
getFormState: function getFormState() {
|
|
47
|
-
this.getFormStateCalls += 1;
|
|
48
|
-
return {};
|
|
49
|
-
},
|
|
50
|
-
getSubmissionStatusCalls: 0,
|
|
51
|
-
getSubmissionStatus: function getSubmissionStatus() {
|
|
52
|
-
this.getSubmissionStatusCalls += 1;
|
|
53
|
-
return 'Good to go!';
|
|
54
|
-
},
|
|
55
|
-
reset: function reset() {
|
|
56
|
-
this.canCYASubmitCalls = 0;
|
|
57
|
-
this.canCYASubmitResult = true;
|
|
58
|
-
this.getFormStateCalls = 0;
|
|
59
|
-
this.getNextPageIdCalls = 0;
|
|
60
|
-
this.getFormStateCalls = 0;
|
|
61
|
-
this.getSubmissionStatusCalls = 0;
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
jest.mock('./handlers', () => ({
|
|
10
|
+
submissionErrorCalls: 0,
|
|
11
|
+
submissionErrorArgs: [],
|
|
12
|
+
submissionError(errors, addErrors) {
|
|
13
|
+
this.submissionErrorCalls += 1;
|
|
14
|
+
this.submissionErrorArgs.push(errors);
|
|
15
|
+
if (typeof addErrors === 'function') {
|
|
16
|
+
addErrors(errors);
|
|
62
17
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
18
|
+
},
|
|
19
|
+
reset() {
|
|
20
|
+
this.submissionErrorCalls = 0;
|
|
21
|
+
this.submissionErrorArgs = [];
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
jest.mock('./helpers', () => ({
|
|
25
|
+
canCYASubmitResult: true,
|
|
26
|
+
canCYASubmitCalls: 0,
|
|
27
|
+
canCYASubmit() {
|
|
28
|
+
this.canCYASubmitCalls += 1;
|
|
29
|
+
return this.canCYASubmitResult;
|
|
30
|
+
},
|
|
31
|
+
getNextPageIdCalls: 0,
|
|
32
|
+
getNextPageId() {
|
|
33
|
+
this.getNextPageIdCalls += 1;
|
|
34
|
+
return 'page2';
|
|
35
|
+
},
|
|
36
|
+
getFormStateCalls: 0,
|
|
37
|
+
getFormState() {
|
|
38
|
+
this.getFormStateCalls += 1;
|
|
39
|
+
return {};
|
|
40
|
+
},
|
|
41
|
+
getSubmissionStatusCalls: 0,
|
|
42
|
+
getSubmissionStatus() {
|
|
43
|
+
this.getSubmissionStatusCalls += 1;
|
|
44
|
+
return 'Good to go!';
|
|
45
|
+
},
|
|
46
|
+
reset() {
|
|
47
|
+
this.canCYASubmitCalls = 0;
|
|
48
|
+
this.canCYASubmitResult = true;
|
|
49
|
+
this.getFormStateCalls = 0;
|
|
50
|
+
this.getNextPageIdCalls = 0;
|
|
51
|
+
this.getFormStateCalls = 0;
|
|
52
|
+
this.getSubmissionStatusCalls = 0;
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
jest.mock('../../utils', () => ({
|
|
56
|
+
Format: {
|
|
57
|
+
formCalls: 0,
|
|
58
|
+
form() {
|
|
59
|
+
this.formCalls += 1;
|
|
60
|
+
return {
|
|
61
|
+
id: 'formId'
|
|
62
|
+
};
|
|
78
63
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
},
|
|
65
|
+
reset() {
|
|
66
|
+
this.Format.formCalls = 0;
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
describe('components.FormRenderer.onCYAAction', () => {
|
|
70
|
+
const MOCK_HOOKS = {
|
|
83
71
|
onSubmitCalls: 0,
|
|
84
72
|
onSubmitArgs: [],
|
|
85
|
-
onSubmit
|
|
73
|
+
onSubmit(type, payload, onSuccess, onError) {
|
|
86
74
|
this.onSubmitCalls += 1;
|
|
87
75
|
this.onSubmitArgs.push({
|
|
88
|
-
type
|
|
89
|
-
payload
|
|
76
|
+
type,
|
|
77
|
+
payload
|
|
90
78
|
});
|
|
91
79
|
if (typeof onSuccess === 'function') {
|
|
92
80
|
onSuccess();
|
|
@@ -99,45 +87,45 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
99
87
|
}
|
|
100
88
|
},
|
|
101
89
|
onFormCompleteCalls: 0,
|
|
102
|
-
onFormComplete
|
|
90
|
+
onFormComplete() {
|
|
103
91
|
this.onFormCompleteCalls += 1;
|
|
104
92
|
},
|
|
105
93
|
onCancelArgs: [],
|
|
106
|
-
onCancel
|
|
94
|
+
onCancel(data) {
|
|
107
95
|
this.onCancelArgs.push(data);
|
|
108
96
|
},
|
|
109
|
-
reset
|
|
97
|
+
reset() {
|
|
110
98
|
this.onSubmitCalls = 0;
|
|
111
99
|
this.onSubmitArgs = [];
|
|
112
100
|
this.onFormCompleteCalls = 0;
|
|
113
101
|
this.onCancelArgs = [];
|
|
114
102
|
}
|
|
115
103
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
104
|
+
let setPagePointCalls = 0;
|
|
105
|
+
let setPagePointArgs = [];
|
|
106
|
+
const mockSetPagePoint = point => {
|
|
119
107
|
setPagePointCalls += 1;
|
|
120
108
|
setPagePointArgs.push(point);
|
|
121
109
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
110
|
+
let setDataCalls = 0;
|
|
111
|
+
let setDataArgs = [];
|
|
112
|
+
const mockSetData = data => {
|
|
125
113
|
setDataCalls += 1;
|
|
126
114
|
setDataArgs.push(data);
|
|
127
115
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
116
|
+
let onPageChangeCalls = 0;
|
|
117
|
+
let onPageChangeArgs = [];
|
|
118
|
+
const mockOnPageChange = pageId => {
|
|
131
119
|
onPageChangeCalls += 1;
|
|
132
120
|
onPageChangeArgs.push(pageId);
|
|
133
121
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
122
|
+
let addErrorsCalls = 0;
|
|
123
|
+
let addErrorsArgs = [];
|
|
124
|
+
const mockAddErrors = errors => {
|
|
137
125
|
addErrorsCalls += 1;
|
|
138
126
|
addErrorsArgs.push(errors);
|
|
139
127
|
};
|
|
140
|
-
|
|
128
|
+
const COMPONENTS = [{
|
|
141
129
|
id: 'alpha',
|
|
142
130
|
fieldId: 'alpha'
|
|
143
131
|
}, {
|
|
@@ -150,24 +138,32 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
150
138
|
id: 'delta',
|
|
151
139
|
fieldId: 'delta'
|
|
152
140
|
}];
|
|
153
|
-
|
|
141
|
+
const PAGES = [{
|
|
154
142
|
id: 'page1',
|
|
155
|
-
components: [
|
|
143
|
+
components: [{
|
|
144
|
+
...COMPONENTS[0]
|
|
145
|
+
}, {
|
|
146
|
+
...COMPONENTS[1]
|
|
147
|
+
}]
|
|
156
148
|
}, {
|
|
157
149
|
id: 'page2',
|
|
158
|
-
components: [
|
|
150
|
+
components: [{
|
|
151
|
+
...COMPONENTS[2]
|
|
152
|
+
}, {
|
|
153
|
+
...COMPONENTS[3]
|
|
154
|
+
}]
|
|
159
155
|
}];
|
|
160
|
-
|
|
156
|
+
const CURRENT_TASK = {
|
|
161
157
|
name: 'testTask',
|
|
162
158
|
fullPages: PAGES
|
|
163
159
|
};
|
|
164
|
-
|
|
160
|
+
const ARGS = {
|
|
165
161
|
setPagePoint: mockSetPagePoint,
|
|
166
162
|
action: {
|
|
167
163
|
type: _models.PageAction.TYPES.SUBMIT
|
|
168
164
|
},
|
|
169
165
|
pages: PAGES,
|
|
170
|
-
validate:
|
|
166
|
+
validate: () => {},
|
|
171
167
|
components: COMPONENTS,
|
|
172
168
|
data: {},
|
|
173
169
|
setData: mockSetData,
|
|
@@ -180,7 +176,7 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
180
176
|
onPageChange: mockOnPageChange,
|
|
181
177
|
formState: _helpers.default.getFormState('alpha', PAGES, null)
|
|
182
178
|
};
|
|
183
|
-
beforeEach(
|
|
179
|
+
beforeEach(() => {
|
|
184
180
|
_handlers.default.reset();
|
|
185
181
|
_helpers.default.reset();
|
|
186
182
|
_utils.default.reset();
|
|
@@ -194,11 +190,12 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
194
190
|
addErrorsCalls = 0;
|
|
195
191
|
addErrorsArgs = [];
|
|
196
192
|
});
|
|
197
|
-
describe('with a page action of PageAction.TYPES.SUBMIT',
|
|
198
|
-
it('should handle a hub format of HubFormats.CYA',
|
|
199
|
-
|
|
193
|
+
describe('with a page action of PageAction.TYPES.SUBMIT', () => {
|
|
194
|
+
it('should handle a hub format of HubFormats.CYA', () => {
|
|
195
|
+
const CUSTOM_ARGS = {
|
|
196
|
+
...ARGS,
|
|
200
197
|
hub: _models.HubFormats.CYA
|
|
201
|
-
}
|
|
198
|
+
};
|
|
202
199
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
203
200
|
expect(setPagePointCalls).toEqual(1);
|
|
204
201
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
@@ -228,10 +225,11 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
228
225
|
expect(addErrorsCalls).toEqual(1);
|
|
229
226
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
230
227
|
});
|
|
231
|
-
it('should handle a hub format of HubFormats.TASK',
|
|
232
|
-
|
|
228
|
+
it('should handle a hub format of HubFormats.TASK', () => {
|
|
229
|
+
const CUSTOM_ARGS = {
|
|
230
|
+
...ARGS,
|
|
233
231
|
hub: _models.HubFormats.TASK
|
|
234
|
-
}
|
|
232
|
+
};
|
|
235
233
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
236
234
|
expect(setPagePointCalls).toEqual(1);
|
|
237
235
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
@@ -261,10 +259,11 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
261
259
|
expect(addErrorsCalls).toEqual(1);
|
|
262
260
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
263
261
|
});
|
|
264
|
-
it('should handle no hub',
|
|
265
|
-
|
|
262
|
+
it('should handle no hub', () => {
|
|
263
|
+
const CUSTOM_ARGS = {
|
|
264
|
+
...ARGS,
|
|
266
265
|
hub: null
|
|
267
|
-
}
|
|
266
|
+
};
|
|
268
267
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
269
268
|
expect(setPagePointCalls).toEqual(1);
|
|
270
269
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
@@ -295,14 +294,15 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
295
294
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
296
295
|
});
|
|
297
296
|
});
|
|
298
|
-
describe('with a page action of PageAction.TYPES.SAVE_AND_CONTINUE',
|
|
299
|
-
it('should validate if action.validate is not defined',
|
|
300
|
-
|
|
297
|
+
describe('with a page action of PageAction.TYPES.SAVE_AND_CONTINUE', () => {
|
|
298
|
+
it('should validate if action.validate is not defined', () => {
|
|
299
|
+
const CUSTOM_ARGS = {
|
|
300
|
+
...ARGS,
|
|
301
301
|
action: {
|
|
302
302
|
type: _models.PageAction.TYPES.SAVE_AND_CONTINUE
|
|
303
303
|
},
|
|
304
304
|
hub: _models.HubFormats.TASK
|
|
305
|
-
}
|
|
305
|
+
};
|
|
306
306
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
307
307
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1); // Validating.
|
|
308
308
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
@@ -331,14 +331,15 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
331
331
|
expect(addErrorsCalls).toEqual(1);
|
|
332
332
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
333
333
|
});
|
|
334
|
-
it('should validate if action.validate is true',
|
|
335
|
-
|
|
334
|
+
it('should validate if action.validate is true', () => {
|
|
335
|
+
const CUSTOM_ARGS = {
|
|
336
|
+
...ARGS,
|
|
336
337
|
action: {
|
|
337
338
|
type: _models.PageAction.TYPES.SAVE_AND_CONTINUE,
|
|
338
339
|
validate: true
|
|
339
340
|
},
|
|
340
341
|
hub: _models.HubFormats.TASK
|
|
341
|
-
}
|
|
342
|
+
};
|
|
342
343
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
343
344
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1); // Validating.
|
|
344
345
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
@@ -367,14 +368,15 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
367
368
|
expect(addErrorsCalls).toEqual(1);
|
|
368
369
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
369
370
|
});
|
|
370
|
-
it('should not validate if action.validate is false',
|
|
371
|
-
|
|
371
|
+
it('should not validate if action.validate is false', () => {
|
|
372
|
+
const CUSTOM_ARGS = {
|
|
373
|
+
...ARGS,
|
|
372
374
|
action: {
|
|
373
375
|
type: _models.PageAction.TYPES.SAVE_AND_CONTINUE,
|
|
374
376
|
validate: false
|
|
375
377
|
},
|
|
376
378
|
hub: _models.HubFormats.TASK
|
|
377
|
-
}
|
|
379
|
+
};
|
|
378
380
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
379
381
|
|
|
380
382
|
// Validation.
|
|
@@ -409,14 +411,15 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
409
411
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
410
412
|
});
|
|
411
413
|
});
|
|
412
|
-
describe('with an action type of PageAction.TYPES.SAVE_AND_RETURN',
|
|
413
|
-
it('should validate if action.validate is not defined',
|
|
414
|
-
|
|
414
|
+
describe('with an action type of PageAction.TYPES.SAVE_AND_RETURN', () => {
|
|
415
|
+
it('should validate if action.validate is not defined', () => {
|
|
416
|
+
const CUSTOM_ARGS = {
|
|
417
|
+
...ARGS,
|
|
415
418
|
action: {
|
|
416
419
|
type: _models.PageAction.TYPES.SAVE_AND_RETURN
|
|
417
420
|
},
|
|
418
421
|
hub: _models.HubFormats.TASK
|
|
419
|
-
}
|
|
422
|
+
};
|
|
420
423
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
421
424
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1); // Validating.
|
|
422
425
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
@@ -445,14 +448,15 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
445
448
|
expect(addErrorsCalls).toEqual(1);
|
|
446
449
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
447
450
|
});
|
|
448
|
-
it('should validate if action.validate is true',
|
|
449
|
-
|
|
451
|
+
it('should validate if action.validate is true', () => {
|
|
452
|
+
const CUSTOM_ARGS = {
|
|
453
|
+
...ARGS,
|
|
450
454
|
action: {
|
|
451
455
|
type: _models.PageAction.TYPES.SAVE_AND_RETURN,
|
|
452
456
|
validate: true
|
|
453
457
|
},
|
|
454
458
|
hub: _models.HubFormats.TASK
|
|
455
|
-
}
|
|
459
|
+
};
|
|
456
460
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
457
461
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1); // Validating.
|
|
458
462
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
@@ -481,14 +485,15 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
481
485
|
expect(addErrorsCalls).toEqual(1);
|
|
482
486
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
483
487
|
});
|
|
484
|
-
it('should not validate if action.validate is false',
|
|
485
|
-
|
|
488
|
+
it('should not validate if action.validate is false', () => {
|
|
489
|
+
const CUSTOM_ARGS = {
|
|
490
|
+
...ARGS,
|
|
486
491
|
action: {
|
|
487
492
|
type: _models.PageAction.TYPES.SAVE_AND_RETURN,
|
|
488
493
|
validate: false
|
|
489
494
|
},
|
|
490
495
|
hub: _models.HubFormats.TASK
|
|
491
|
-
}
|
|
496
|
+
};
|
|
492
497
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
493
498
|
|
|
494
499
|
// Validation.
|
|
@@ -522,15 +527,16 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
522
527
|
expect(addErrorsCalls).toEqual(1);
|
|
523
528
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
524
529
|
});
|
|
525
|
-
it('should call onPageChange with undefined if type is FormTypes.TASK',
|
|
526
|
-
|
|
530
|
+
it('should call onPageChange with undefined if type is FormTypes.TASK', () => {
|
|
531
|
+
const CUSTOM_ARGS = {
|
|
532
|
+
...ARGS,
|
|
527
533
|
action: {
|
|
528
534
|
type: _models.PageAction.TYPES.SAVE_AND_RETURN,
|
|
529
535
|
validate: true
|
|
530
536
|
},
|
|
531
537
|
hub: _models.HubFormats.TASK,
|
|
532
538
|
type: _models.FormTypes.TASK
|
|
533
|
-
}
|
|
539
|
+
};
|
|
534
540
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
535
541
|
expect(_helpers.default.canCYASubmitCalls).toEqual(1); // Validating.
|
|
536
542
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
@@ -560,23 +566,25 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
560
566
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
561
567
|
});
|
|
562
568
|
});
|
|
563
|
-
it('should handle a page action type of PageAction.TYPES.NAVIGATE',
|
|
564
|
-
|
|
569
|
+
it('should handle a page action type of PageAction.TYPES.NAVIGATE', () => {
|
|
570
|
+
const CUSTOM_ARGS = {
|
|
571
|
+
...ARGS,
|
|
565
572
|
action: {
|
|
566
573
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
567
574
|
page: 'page2'
|
|
568
575
|
}
|
|
569
|
-
}
|
|
576
|
+
};
|
|
570
577
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
571
578
|
expect(onPageChangeCalls).toEqual(1);
|
|
572
579
|
expect(onPageChangeArgs[0]).toEqual('page2');
|
|
573
580
|
});
|
|
574
|
-
it('should handle a page action type of PageAction.TYPES.CANCEL',
|
|
575
|
-
|
|
581
|
+
it('should handle a page action type of PageAction.TYPES.CANCEL', () => {
|
|
582
|
+
const CUSTOM_ARGS = {
|
|
583
|
+
...ARGS,
|
|
576
584
|
action: {
|
|
577
585
|
type: _models.PageAction.TYPES.CANCEL
|
|
578
586
|
}
|
|
579
|
-
}
|
|
587
|
+
};
|
|
580
588
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
581
589
|
expect(MOCK_HOOKS.onCancelArgs.length).toEqual(1);
|
|
582
590
|
expect(MOCK_HOOKS.onCancelArgs[0]).toMatchObject({
|