@ukhomeoffice/cop-react-form-renderer 5.14.2 → 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 +61 -106
- package/dist/hooks/useHooks.js +2 -5
- package/dist/hooks/useRefData.js +29 -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
|
@@ -5,77 +5,68 @@ var _utils = _interopRequireDefault(require("../../utils"));
|
|
|
5
5
|
var _handlers = _interopRequireDefault(require("./handlers"));
|
|
6
6
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
7
7
|
var _onPageAction = _interopRequireDefault(require("./onPageAction"));
|
|
8
|
-
function _interopRequireDefault(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
submissionErrorCalls: 0,
|
|
22
|
-
submissionErrorArgs: [],
|
|
23
|
-
submissionError: function submissionError(errors, addErrors) {
|
|
24
|
-
this.submissionErrorCalls += 1;
|
|
25
|
-
this.submissionErrorArgs.push(errors);
|
|
26
|
-
if (typeof addErrors === 'function') {
|
|
27
|
-
addErrors(errors);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
reset: function reset() {
|
|
31
|
-
this.navigateCalls = 0;
|
|
32
|
-
this.submissionErrorCalls = 0;
|
|
33
|
-
this.submissionErrorArgs = [];
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
jest.mock('./handlers', () => ({
|
|
10
|
+
navigateCalls: 0,
|
|
11
|
+
navigate() {
|
|
12
|
+
this.navigateCalls += 1;
|
|
13
|
+
},
|
|
14
|
+
submissionErrorCalls: 0,
|
|
15
|
+
submissionErrorArgs: [],
|
|
16
|
+
submissionError(errors, addErrors) {
|
|
17
|
+
this.submissionErrorCalls += 1;
|
|
18
|
+
this.submissionErrorArgs.push(errors);
|
|
19
|
+
if (typeof addErrors === 'function') {
|
|
20
|
+
addErrors(errors);
|
|
34
21
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
cleanHiddenNestedData: function cleanHiddenNestedData(patch) {
|
|
50
|
-
this.cleanHiddenNestedDataCalls += 1;
|
|
51
|
-
return patch;
|
|
52
|
-
},
|
|
53
|
-
getNextPageIdCalls: 0,
|
|
54
|
-
getNextPageId: function getNextPageId() {
|
|
55
|
-
this.getNextPageIdCalls += 1;
|
|
56
|
-
return 'page2';
|
|
57
|
-
},
|
|
58
|
-
getSubmissionStatusCalls: 0,
|
|
59
|
-
getSubmissionStatus: function getSubmissionStatus() {
|
|
60
|
-
this.getSubmissionStatusCalls += 1;
|
|
61
|
-
return 'Good to go!';
|
|
62
|
-
},
|
|
63
|
-
reset: function reset() {
|
|
64
|
-
this.canActionProceedCalls = 0;
|
|
65
|
-
this.canActionProceedResult = true;
|
|
66
|
-
this.canCYASubmitResult = true;
|
|
67
|
-
this.cleanHiddenNestedDataCalls = 0;
|
|
68
|
-
this.getFormStateCalls = 0;
|
|
69
|
-
this.getSubmissionStatusCalls = 0;
|
|
22
|
+
},
|
|
23
|
+
reset() {
|
|
24
|
+
this.navigateCalls = 0;
|
|
25
|
+
this.submissionErrorCalls = 0;
|
|
26
|
+
this.submissionErrorArgs = [];
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
jest.mock('./helpers', () => ({
|
|
30
|
+
canActionProceedCalls: 0,
|
|
31
|
+
canActionProceedResult: true,
|
|
32
|
+
canActionProceed(action, page, validator) {
|
|
33
|
+
this.canActionProceedCalls += 1;
|
|
34
|
+
if (typeof validator === 'function') {
|
|
35
|
+
validator();
|
|
70
36
|
}
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
37
|
+
return this.canActionProceedResult;
|
|
38
|
+
},
|
|
39
|
+
cleanHiddenNestedDataCalls: 0,
|
|
40
|
+
cleanHiddenNestedData(patch) {
|
|
41
|
+
this.cleanHiddenNestedDataCalls += 1;
|
|
42
|
+
return patch;
|
|
43
|
+
},
|
|
44
|
+
getNextPageIdCalls: 0,
|
|
45
|
+
getNextPageId() {
|
|
46
|
+
this.getNextPageIdCalls += 1;
|
|
47
|
+
return 'page2';
|
|
48
|
+
},
|
|
49
|
+
getSubmissionStatusCalls: 0,
|
|
50
|
+
getSubmissionStatus() {
|
|
51
|
+
this.getSubmissionStatusCalls += 1;
|
|
52
|
+
return 'Good to go!';
|
|
53
|
+
},
|
|
54
|
+
reset() {
|
|
55
|
+
this.canActionProceedCalls = 0;
|
|
56
|
+
this.canActionProceedResult = true;
|
|
57
|
+
this.canCYASubmitResult = true;
|
|
58
|
+
this.cleanHiddenNestedDataCalls = 0;
|
|
59
|
+
this.getFormStateCalls = 0;
|
|
60
|
+
this.getSubmissionStatusCalls = 0;
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
jest.mock('../../utils', () => {
|
|
64
|
+
const originalModule = jest.requireActual('../../utils');
|
|
65
|
+
return {
|
|
66
|
+
...originalModule.default,
|
|
76
67
|
Format: {
|
|
77
68
|
formCalls: 0,
|
|
78
|
-
form
|
|
69
|
+
form(form, data) {
|
|
79
70
|
this.formCalls += 1;
|
|
80
71
|
return data;
|
|
81
72
|
}
|
|
@@ -83,29 +74,29 @@ jest.mock('../../utils', function () {
|
|
|
83
74
|
CollectionPage: {
|
|
84
75
|
duplicateActiveEntryCalls: 0,
|
|
85
76
|
duplicateActiveEntryResult: true,
|
|
86
|
-
duplicateActiveEntry
|
|
77
|
+
duplicateActiveEntry() {
|
|
87
78
|
this.duplicateActiveEntryCalls += 1;
|
|
88
79
|
return this.duplicateActiveEntryResult;
|
|
89
80
|
}
|
|
90
81
|
},
|
|
91
|
-
reset
|
|
82
|
+
reset() {
|
|
92
83
|
this.Format.formCalls = 0;
|
|
93
84
|
this.CollectionPage.duplicateActiveEntryCalls = 0;
|
|
94
85
|
this.duplicateActiveEntryResult = true;
|
|
95
86
|
}
|
|
96
|
-
}
|
|
87
|
+
};
|
|
97
88
|
});
|
|
98
|
-
describe('components.FormRenderer.onPageAction',
|
|
99
|
-
|
|
89
|
+
describe('components.FormRenderer.onPageAction', () => {
|
|
90
|
+
const MOCK_HOOKS = {
|
|
100
91
|
onSubmitCalls: 0,
|
|
101
92
|
onSubmitArgs: [],
|
|
102
|
-
onSubmit
|
|
93
|
+
onSubmit(type, payload, onSuccess, onError, changedFieldName, changedFieldValue) {
|
|
103
94
|
this.onSubmitCalls += 1;
|
|
104
95
|
this.onSubmitArgs.push({
|
|
105
|
-
type
|
|
106
|
-
payload
|
|
107
|
-
changedFieldName
|
|
108
|
-
changedFieldValue
|
|
96
|
+
type,
|
|
97
|
+
payload,
|
|
98
|
+
changedFieldName,
|
|
99
|
+
changedFieldValue
|
|
109
100
|
});
|
|
110
101
|
if (typeof onSuccess === 'function') {
|
|
111
102
|
onSuccess();
|
|
@@ -118,14 +109,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
118
109
|
}
|
|
119
110
|
},
|
|
120
111
|
onFormCompleteCalls: 0,
|
|
121
|
-
onFormComplete
|
|
112
|
+
onFormComplete() {
|
|
122
113
|
this.onFormCompleteCalls += 1;
|
|
123
114
|
},
|
|
124
115
|
onCancelArgs: [],
|
|
125
|
-
onCancel
|
|
116
|
+
onCancel(data) {
|
|
126
117
|
this.onCancelArgs.push(data);
|
|
127
118
|
},
|
|
128
|
-
reset
|
|
119
|
+
reset() {
|
|
129
120
|
this.onSubmitCalls = 0;
|
|
130
121
|
this.onSubmitArgs = [];
|
|
131
122
|
this.onFormCompleteCalls = 0;
|
|
@@ -133,50 +124,50 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
133
124
|
this.onActionCalls = 0;
|
|
134
125
|
},
|
|
135
126
|
onActionCalls: 0,
|
|
136
|
-
onAction
|
|
127
|
+
onAction(formData, patch) {
|
|
137
128
|
this.onActionCalls += 1;
|
|
138
129
|
return {
|
|
139
|
-
formData
|
|
140
|
-
patch
|
|
130
|
+
formData,
|
|
131
|
+
patch
|
|
141
132
|
};
|
|
142
133
|
}
|
|
143
134
|
};
|
|
144
|
-
|
|
135
|
+
const MOCK_VALIDATE = {
|
|
145
136
|
pageCalls: 0,
|
|
146
|
-
page
|
|
137
|
+
page() {
|
|
147
138
|
MOCK_VALIDATE.pageCalls += 1;
|
|
148
139
|
},
|
|
149
|
-
reset
|
|
140
|
+
reset() {
|
|
150
141
|
this.pageCalls = 0;
|
|
151
142
|
}
|
|
152
143
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
144
|
+
let setPagePointCalls = 0;
|
|
145
|
+
let setPagePointArgs = [];
|
|
146
|
+
const mockSetPagePoint = point => {
|
|
156
147
|
setPagePointCalls += 1;
|
|
157
148
|
setPagePointArgs.push(point);
|
|
158
149
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
150
|
+
let setDataCalls = 0;
|
|
151
|
+
let setDataArgs = [];
|
|
152
|
+
const mockSetData = data => {
|
|
162
153
|
setDataCalls += 1;
|
|
163
154
|
setDataArgs.push(data);
|
|
164
155
|
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
156
|
+
let onPageChangeCalls = 0;
|
|
157
|
+
let onPageChangeArgs = [];
|
|
158
|
+
const mockOnPageChange = pageId => {
|
|
168
159
|
onPageChangeCalls += 1;
|
|
169
160
|
onPageChangeArgs.push(pageId);
|
|
170
161
|
};
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
let addErrorsArgs = [];
|
|
163
|
+
const mockAddErrors = errors => {
|
|
173
164
|
addErrorsArgs.push(errors);
|
|
174
165
|
};
|
|
175
|
-
|
|
176
|
-
|
|
166
|
+
let setSubmittedArgs = [];
|
|
167
|
+
const mockSetSubmitted = newSubmitted => {
|
|
177
168
|
setSubmittedArgs.push(newSubmitted);
|
|
178
169
|
};
|
|
179
|
-
|
|
170
|
+
const COMPONENTS = [{
|
|
180
171
|
id: 'alpha',
|
|
181
172
|
fieldId: 'alpha'
|
|
182
173
|
}, {
|
|
@@ -189,18 +180,26 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
189
180
|
id: 'delta',
|
|
190
181
|
fieldId: 'delta'
|
|
191
182
|
}];
|
|
192
|
-
|
|
183
|
+
const PAGES = [{
|
|
193
184
|
id: 'page1',
|
|
194
|
-
components: [
|
|
185
|
+
components: [{
|
|
186
|
+
...COMPONENTS[0]
|
|
187
|
+
}, {
|
|
188
|
+
...COMPONENTS[1]
|
|
189
|
+
}]
|
|
195
190
|
}, {
|
|
196
191
|
id: 'page2',
|
|
197
|
-
components: [
|
|
192
|
+
components: [{
|
|
193
|
+
...COMPONENTS[2]
|
|
194
|
+
}, {
|
|
195
|
+
...COMPONENTS[3]
|
|
196
|
+
}]
|
|
198
197
|
}];
|
|
199
|
-
|
|
198
|
+
const CURRENT_TASK = {
|
|
200
199
|
name: 'testTask',
|
|
201
200
|
fullPages: PAGES
|
|
202
201
|
};
|
|
203
|
-
|
|
202
|
+
const ARGS = {
|
|
204
203
|
action: {
|
|
205
204
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
206
205
|
},
|
|
@@ -226,7 +225,7 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
226
225
|
setSubmitted: mockSetSubmitted,
|
|
227
226
|
addErrors: mockAddErrors
|
|
228
227
|
};
|
|
229
|
-
beforeEach(
|
|
228
|
+
beforeEach(() => {
|
|
230
229
|
_handlers.default.reset();
|
|
231
230
|
_helpers.default.reset();
|
|
232
231
|
_utils.default.reset();
|
|
@@ -241,12 +240,12 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
241
240
|
addErrorsArgs = [];
|
|
242
241
|
setSubmittedArgs = [];
|
|
243
242
|
});
|
|
244
|
-
|
|
243
|
+
const preActionChecks = () => {
|
|
245
244
|
expect(_helpers.default.canActionProceedCalls).toEqual(1);
|
|
246
245
|
expect(MOCK_VALIDATE.pageCalls).toEqual(1);
|
|
247
246
|
expect(_helpers.default.cleanHiddenNestedDataCalls).toEqual(1);
|
|
248
247
|
};
|
|
249
|
-
|
|
248
|
+
const postActionChecks = argsUsed => {
|
|
250
249
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
251
250
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
252
251
|
// setData is always called once in the error callback
|
|
@@ -254,8 +253,12 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
254
253
|
// to this if patch is valid.
|
|
255
254
|
if (argsUsed.patch) {
|
|
256
255
|
expect(setDataCalls).toEqual(2);
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
const dataUsed = {
|
|
257
|
+
...argsUsed.data,
|
|
258
|
+
...argsUsed.patch,
|
|
259
|
+
...argsUsed.formState.page.formData
|
|
260
|
+
};
|
|
261
|
+
const submissionData = _utils.default.Format.form(null, dataUsed, null);
|
|
259
262
|
submissionData.formStatus = _helpers.default.getSubmissionStatus();
|
|
260
263
|
expect(setDataArgs[0]).toEqual(submissionData);
|
|
261
264
|
} else {
|
|
@@ -263,7 +266,7 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
263
266
|
}
|
|
264
267
|
expect(MOCK_HOOKS.onSubmitCalls).toEqual(1);
|
|
265
268
|
if (argsUsed.type === _models.FormTypes.HUB && Object.keys(argsUsed.patchLabel).length > 0) {
|
|
266
|
-
|
|
269
|
+
const firstKey = Object.keys(argsUsed.patchLabel)[0];
|
|
267
270
|
expect(MOCK_HOOKS.onSubmitArgs[0]).toMatchObject({
|
|
268
271
|
changedFieldName: firstKey,
|
|
269
272
|
changedFieldValue: argsUsed.patchLabel[firstKey]
|
|
@@ -281,14 +284,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
281
284
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
282
285
|
expect(setDataArgs[setDataCalls - 1]).toEqual(argsUsed.data); // Data is reset in the case of an error.
|
|
283
286
|
};
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
var ACTION = {
|
|
287
|
+
it(`should handle the ${_models.PageAction.TYPES.CANCEL} Page Action type`, () => {
|
|
288
|
+
const ACTION = {
|
|
287
289
|
type: _models.PageAction.TYPES.CANCEL
|
|
288
290
|
};
|
|
289
|
-
|
|
291
|
+
const CUSTOM_ARGS = {
|
|
292
|
+
...ARGS,
|
|
290
293
|
action: ACTION
|
|
291
|
-
}
|
|
294
|
+
};
|
|
292
295
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
293
296
|
expect(MOCK_HOOKS.onCancelArgs.length).toEqual(1);
|
|
294
297
|
expect(MOCK_HOOKS.onCancelArgs[0]).toMatchObject({});
|
|
@@ -297,13 +300,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
297
300
|
expect(_helpers.default.canActionProceedCalls).toEqual(0);
|
|
298
301
|
expect(MOCK_VALIDATE.pageCalls).toEqual(0);
|
|
299
302
|
});
|
|
300
|
-
it(
|
|
301
|
-
|
|
303
|
+
it(`should handle the ${_models.PageAction.TYPES.NAVIGATE} Page Action type`, () => {
|
|
304
|
+
const ACTION = {
|
|
302
305
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
303
306
|
};
|
|
304
|
-
|
|
307
|
+
const CUSTOM_ARGS = {
|
|
308
|
+
...ARGS,
|
|
305
309
|
action: ACTION
|
|
306
|
-
}
|
|
310
|
+
};
|
|
307
311
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
308
312
|
preActionChecks();
|
|
309
313
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
@@ -312,27 +316,28 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
312
316
|
// as a navigate action should stop at calling
|
|
313
317
|
// hooks.navigate.
|
|
314
318
|
});
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
var ACTION = {
|
|
319
|
+
it(`should handle the ${_models.PageAction.TYPES.SUBMIT} Page Action type`, () => {
|
|
320
|
+
const ACTION = {
|
|
318
321
|
type: _models.PageAction.TYPES.SUBMIT
|
|
319
322
|
};
|
|
320
|
-
|
|
323
|
+
const CUSTOM_ARGS = {
|
|
324
|
+
...ARGS,
|
|
321
325
|
action: ACTION
|
|
322
|
-
}
|
|
326
|
+
};
|
|
323
327
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
324
328
|
preActionChecks();
|
|
325
329
|
expect(setPagePointCalls).toEqual(1);
|
|
326
330
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
327
331
|
postActionChecks(CUSTOM_ARGS);
|
|
328
332
|
});
|
|
329
|
-
it(
|
|
330
|
-
|
|
333
|
+
it(`should handle the ${_models.PageAction.TYPES.SAVE_AND_NAVIGATE} Page Action type`, () => {
|
|
334
|
+
const ACTION = {
|
|
331
335
|
type: _models.PageAction.TYPES.SAVE_AND_NAVIGATE
|
|
332
336
|
};
|
|
333
|
-
|
|
337
|
+
const CUSTOM_ARGS = {
|
|
338
|
+
...ARGS,
|
|
334
339
|
action: ACTION
|
|
335
|
-
}
|
|
340
|
+
};
|
|
336
341
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
337
342
|
preActionChecks();
|
|
338
343
|
// All the actions does in this case is set a function
|
|
@@ -340,48 +345,50 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
340
345
|
postActionChecks(CUSTOM_ARGS);
|
|
341
346
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
342
347
|
});
|
|
343
|
-
it(
|
|
344
|
-
|
|
348
|
+
it(`should handle the ${_models.PageAction.TYPES.COLLECTION_ADD} Page Action type`, () => {
|
|
349
|
+
const FORM_STATE = {
|
|
345
350
|
page: {
|
|
346
351
|
formData: {
|
|
347
352
|
'testCollection': []
|
|
348
353
|
}
|
|
349
354
|
}
|
|
350
355
|
};
|
|
351
|
-
|
|
356
|
+
const ACTION = {
|
|
352
357
|
type: _models.PageAction.TYPES.COLLECTION_ADD,
|
|
353
358
|
collection: 'testCollection'
|
|
354
359
|
};
|
|
355
|
-
|
|
360
|
+
const CUSTOM_ARGS = {
|
|
361
|
+
...ARGS,
|
|
356
362
|
action: ACTION,
|
|
357
363
|
formState: FORM_STATE
|
|
358
|
-
}
|
|
364
|
+
};
|
|
359
365
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
360
366
|
preActionChecks();
|
|
361
|
-
expect(FORM_STATE.page.formData[
|
|
367
|
+
expect(FORM_STATE.page.formData[`${ACTION.collection}ActiveId`]).toBeDefined();
|
|
362
368
|
postActionChecks(CUSTOM_ARGS);
|
|
363
369
|
|
|
364
370
|
// This action type also sets up a call to handlers.navigate
|
|
365
371
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
366
372
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
367
373
|
});
|
|
368
|
-
describe(
|
|
369
|
-
it(
|
|
370
|
-
|
|
374
|
+
describe(`should handle the ${_models.PageAction.TYPES.COLLECTION_DUPLICATE} Page Action type`, () => {
|
|
375
|
+
it(`calling handlers.navigate if the duplication was successful`, () => {
|
|
376
|
+
const FORM_STATE = {
|
|
371
377
|
page: {
|
|
372
378
|
formData: {
|
|
373
379
|
'testCollection': []
|
|
374
380
|
}
|
|
375
381
|
}
|
|
376
382
|
};
|
|
377
|
-
|
|
383
|
+
const ACTION = {
|
|
378
384
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
379
385
|
collection: 'testCollection'
|
|
380
386
|
};
|
|
381
|
-
|
|
387
|
+
const CUSTOM_ARGS = {
|
|
388
|
+
...ARGS,
|
|
382
389
|
action: ACTION,
|
|
383
390
|
formState: FORM_STATE
|
|
384
|
-
}
|
|
391
|
+
};
|
|
385
392
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
386
393
|
preActionChecks();
|
|
387
394
|
expect(_utils.default.CollectionPage.duplicateActiveEntryCalls).toEqual(1);
|
|
@@ -391,22 +398,23 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
391
398
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
392
399
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
393
400
|
});
|
|
394
|
-
it(
|
|
395
|
-
|
|
401
|
+
it(`calling onPageChange if the duplication was unsuccessful`, () => {
|
|
402
|
+
const FORM_STATE = {
|
|
396
403
|
page: {
|
|
397
404
|
formData: {
|
|
398
405
|
'testCollection': []
|
|
399
406
|
}
|
|
400
407
|
}
|
|
401
408
|
};
|
|
402
|
-
|
|
409
|
+
const ACTION = {
|
|
403
410
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
404
411
|
collection: 'testCollection'
|
|
405
412
|
};
|
|
406
|
-
|
|
413
|
+
const CUSTOM_ARGS = {
|
|
414
|
+
...ARGS,
|
|
407
415
|
action: ACTION,
|
|
408
416
|
formState: FORM_STATE
|
|
409
|
-
}
|
|
417
|
+
};
|
|
410
418
|
_utils.default.CollectionPage.duplicateActiveEntryResult = false;
|
|
411
419
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
412
420
|
preActionChecks();
|
|
@@ -420,9 +428,9 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
420
428
|
expect(onPageChangeCalls).toEqual(1);
|
|
421
429
|
});
|
|
422
430
|
});
|
|
423
|
-
describe(
|
|
424
|
-
it(
|
|
425
|
-
|
|
431
|
+
describe(`should handle the ${_models.PageAction.TYPES.COLLECTION_REMOVE} Page Action type`, () => {
|
|
432
|
+
it(`should store a reference to the removed item if action.recordRemoval is true`, () => {
|
|
433
|
+
const FORM_STATE = {
|
|
426
434
|
page: {
|
|
427
435
|
formData: {
|
|
428
436
|
testCollectionActiveId: 'removeMe',
|
|
@@ -434,15 +442,16 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
434
442
|
}
|
|
435
443
|
}
|
|
436
444
|
};
|
|
437
|
-
|
|
445
|
+
const ACTION = {
|
|
438
446
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
439
447
|
collection: 'testCollection',
|
|
440
448
|
recordRemoval: true
|
|
441
449
|
};
|
|
442
|
-
|
|
450
|
+
const CUSTOM_ARGS = {
|
|
451
|
+
...ARGS,
|
|
443
452
|
action: ACTION,
|
|
444
453
|
formState: FORM_STATE
|
|
445
|
-
}
|
|
454
|
+
};
|
|
446
455
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
447
456
|
preActionChecks();
|
|
448
457
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -456,8 +465,8 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
456
465
|
// This action type uses the default onPageChange.
|
|
457
466
|
expect(onPageChangeCalls).toEqual(1);
|
|
458
467
|
});
|
|
459
|
-
it(
|
|
460
|
-
|
|
468
|
+
it(`should not store a reference to the removed item if action.recordRemoval is false`, () => {
|
|
469
|
+
const FORM_STATE = {
|
|
461
470
|
page: {
|
|
462
471
|
formData: {
|
|
463
472
|
testCollectionActiveId: 'removeMe',
|
|
@@ -469,15 +478,16 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
469
478
|
}
|
|
470
479
|
}
|
|
471
480
|
};
|
|
472
|
-
|
|
481
|
+
const ACTION = {
|
|
473
482
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
474
483
|
collection: 'testCollection',
|
|
475
484
|
recordRemoval: false
|
|
476
485
|
};
|
|
477
|
-
|
|
486
|
+
const CUSTOM_ARGS = {
|
|
487
|
+
...ARGS,
|
|
478
488
|
action: ACTION,
|
|
479
489
|
formState: FORM_STATE
|
|
480
|
-
}
|
|
490
|
+
};
|
|
481
491
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
482
492
|
preActionChecks();
|
|
483
493
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -489,8 +499,8 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
489
499
|
// This action type uses the default onPageChange.
|
|
490
500
|
expect(onPageChangeCalls).toEqual(1);
|
|
491
501
|
});
|
|
492
|
-
it(
|
|
493
|
-
|
|
502
|
+
it(`should not store a reference to the removed item if action.recordRemoval is not defined`, () => {
|
|
503
|
+
const FORM_STATE = {
|
|
494
504
|
page: {
|
|
495
505
|
formData: {
|
|
496
506
|
testCollectionActiveId: 'removeMe',
|
|
@@ -502,14 +512,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
502
512
|
}
|
|
503
513
|
}
|
|
504
514
|
};
|
|
505
|
-
|
|
515
|
+
const ACTION = {
|
|
506
516
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
507
517
|
collection: 'testCollection'
|
|
508
518
|
};
|
|
509
|
-
|
|
519
|
+
const CUSTOM_ARGS = {
|
|
520
|
+
...ARGS,
|
|
510
521
|
action: ACTION,
|
|
511
522
|
formState: FORM_STATE
|
|
512
|
-
}
|
|
523
|
+
};
|
|
513
524
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
514
525
|
preActionChecks();
|
|
515
526
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -522,18 +533,17 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
522
533
|
expect(onPageChangeCalls).toEqual(1);
|
|
523
534
|
});
|
|
524
535
|
});
|
|
525
|
-
describe('if validation fails',
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
it("should not continue for the ".concat(actionType, " action type"), function () {
|
|
531
|
-
var ACTION = {
|
|
536
|
+
describe('if validation fails', () => {
|
|
537
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL);
|
|
538
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
539
|
+
it(`should not continue for the ${actionType} action type`, () => {
|
|
540
|
+
const ACTION = {
|
|
532
541
|
type: actionType
|
|
533
542
|
};
|
|
534
|
-
|
|
543
|
+
const CUSTOM_ARGS = {
|
|
544
|
+
...ARGS,
|
|
535
545
|
action: ACTION
|
|
536
|
-
}
|
|
546
|
+
};
|
|
537
547
|
_helpers.default.canActionProceedResult = false;
|
|
538
548
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
539
549
|
expect(_helpers.default.canActionProceedCalls).toEqual(1);
|
|
@@ -544,20 +554,18 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
544
554
|
});
|
|
545
555
|
});
|
|
546
556
|
});
|
|
547
|
-
describe('adding a field to formData if specified on the action',
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
it("should work for the ".concat(actionType, " action type"), function () {
|
|
553
|
-
var FORM_STATE = {
|
|
557
|
+
describe('adding a field to formData if specified on the action', () => {
|
|
558
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE);
|
|
559
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
560
|
+
it(`should work for the ${actionType} action type`, () => {
|
|
561
|
+
const FORM_STATE = {
|
|
554
562
|
page: {
|
|
555
563
|
formData: {
|
|
556
564
|
testCollection: []
|
|
557
565
|
}
|
|
558
566
|
}
|
|
559
567
|
};
|
|
560
|
-
|
|
568
|
+
const ACTION = {
|
|
561
569
|
type: actionType,
|
|
562
570
|
collection: 'testCollection',
|
|
563
571
|
addToFormData: {
|
|
@@ -565,10 +573,11 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
565
573
|
value: '123'
|
|
566
574
|
}
|
|
567
575
|
};
|
|
568
|
-
|
|
576
|
+
const CUSTOM_ARGS = {
|
|
577
|
+
...ARGS,
|
|
569
578
|
formState: FORM_STATE,
|
|
570
579
|
action: ACTION
|
|
571
|
-
}
|
|
580
|
+
};
|
|
572
581
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
573
582
|
preActionChecks();
|
|
574
583
|
postActionChecks(CUSTOM_ARGS);
|
|
@@ -577,15 +586,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
577
586
|
});
|
|
578
587
|
});
|
|
579
588
|
});
|
|
580
|
-
it(
|
|
581
|
-
|
|
589
|
+
it(`should work for the ${_models.PageAction.TYPES.NAVIGATE} action type`, () => {
|
|
590
|
+
const FORM_STATE = {
|
|
582
591
|
page: {
|
|
583
592
|
formData: {
|
|
584
593
|
testCollection: []
|
|
585
594
|
}
|
|
586
595
|
}
|
|
587
596
|
};
|
|
588
|
-
|
|
597
|
+
const ACTION = {
|
|
589
598
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
590
599
|
collection: 'testCollection',
|
|
591
600
|
addToFormData: {
|
|
@@ -593,10 +602,11 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
593
602
|
value: '123'
|
|
594
603
|
}
|
|
595
604
|
};
|
|
596
|
-
|
|
605
|
+
const CUSTOM_ARGS = {
|
|
606
|
+
...ARGS,
|
|
597
607
|
formState: FORM_STATE,
|
|
598
608
|
action: ACTION
|
|
599
|
-
}
|
|
609
|
+
};
|
|
600
610
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
601
611
|
preActionChecks();
|
|
602
612
|
// Not doing the usual post-action checks here
|
|
@@ -606,15 +616,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
606
616
|
alpha: '123'
|
|
607
617
|
});
|
|
608
618
|
});
|
|
609
|
-
it('should work for an array of formData',
|
|
610
|
-
|
|
619
|
+
it('should work for an array of formData', () => {
|
|
620
|
+
const FORM_STATE = {
|
|
611
621
|
page: {
|
|
612
622
|
formData: {
|
|
613
623
|
testCollection: []
|
|
614
624
|
}
|
|
615
625
|
}
|
|
616
626
|
};
|
|
617
|
-
|
|
627
|
+
const ACTION = {
|
|
618
628
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
619
629
|
collection: 'testCollection',
|
|
620
630
|
addToFormData: [{
|
|
@@ -625,10 +635,11 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
625
635
|
value: '456'
|
|
626
636
|
}]
|
|
627
637
|
};
|
|
628
|
-
|
|
638
|
+
const CUSTOM_ARGS = {
|
|
639
|
+
...ARGS,
|
|
629
640
|
formState: FORM_STATE,
|
|
630
641
|
action: ACTION
|
|
631
|
-
}
|
|
642
|
+
};
|
|
632
643
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
633
644
|
preActionChecks();
|
|
634
645
|
// Not doing the usual post-action checks here
|
|
@@ -642,34 +653,37 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
642
653
|
});
|
|
643
654
|
});
|
|
644
655
|
});
|
|
645
|
-
describe('recording patchLabel fields correctly when it is defined',
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
it("should work for the ".concat(actionType, " action type"), function () {
|
|
651
|
-
var FORM_STATE = {
|
|
656
|
+
describe('recording patchLabel fields correctly when it is defined', () => {
|
|
657
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE);
|
|
658
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
659
|
+
it(`should work for the ${actionType} action type`, () => {
|
|
660
|
+
const FORM_STATE = {
|
|
652
661
|
page: {
|
|
653
662
|
formData: {
|
|
654
663
|
testCollection: []
|
|
655
664
|
}
|
|
656
665
|
}
|
|
657
666
|
};
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
667
|
+
const KEY = 'testField';
|
|
668
|
+
const VALUE = 'testValue';
|
|
669
|
+
const PATCH_LABEL = {
|
|
670
|
+
[KEY]: VALUE
|
|
671
|
+
};
|
|
672
|
+
const PATCH = {
|
|
673
|
+
[KEY]: VALUE
|
|
674
|
+
};
|
|
675
|
+
const ACTION = {
|
|
663
676
|
type: actionType,
|
|
664
677
|
collection: 'testCollection'
|
|
665
678
|
};
|
|
666
|
-
|
|
679
|
+
const CUSTOM_ARGS = {
|
|
680
|
+
...ARGS,
|
|
667
681
|
action: ACTION,
|
|
668
682
|
formState: FORM_STATE,
|
|
669
683
|
patch: PATCH,
|
|
670
684
|
patchLabel: PATCH_LABEL,
|
|
671
685
|
type: _models.FormTypes.HUB
|
|
672
|
-
}
|
|
686
|
+
};
|
|
673
687
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
674
688
|
preActionChecks();
|
|
675
689
|
postActionChecks(CUSTOM_ARGS); // Specific check for patchLabel done in here.
|