@ukhomeoffice/cop-react-form-renderer 5.44.1-alpha → 5.45.2-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +12 -12
- package/dist/components/CheckYourAnswers/Answer.test.js +92 -127
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +101 -131
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +464 -769
- package/dist/components/CollectionPage/CollectionPage.js +66 -58
- package/dist/components/CollectionPage/CollectionPage.test.js +300 -342
- package/dist/components/CollectionSummary/BannerStrip.js +12 -12
- package/dist/components/CollectionSummary/BannerStrip.test.js +63 -59
- package/dist/components/CollectionSummary/CollectionSummary.js +104 -77
- package/dist/components/CollectionSummary/CollectionSummary.test.js +126 -81
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/SummaryCard.js +96 -131
- package/dist/components/CollectionSummary/SummaryCard.test.js +959 -810
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +66 -0
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +86 -0
- package/dist/components/FormComponent/Collection.js +73 -107
- package/dist/components/FormComponent/Collection.test.js +809 -945
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +67 -70
- package/dist/components/FormComponent/FormComponent.test.js +284 -342
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +65 -80
- package/dist/components/FormPage/FormPage.test.js +127 -163
- package/dist/components/FormRenderer/FormRenderer.js +142 -178
- package/dist/components/FormRenderer/FormRenderer.test.js +730 -1115
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +9 -9
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +16 -20
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +17 -22
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +3 -5
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +5 -7
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -24
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +6 -7
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +96 -110
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -73
- package/dist/components/FormRenderer/helpers/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +59 -51
- package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
- package/dist/components/FormRenderer/onPageAction.js +43 -39
- package/dist/components/FormRenderer/onPageAction.test.js +223 -206
- package/dist/components/FormRenderer/onTaskAction.js +9 -13
- package/dist/components/FormRenderer/onTaskAction.test.js +93 -88
- package/dist/components/PageActions/ActionButton.js +12 -15
- package/dist/components/PageActions/ActionButton.test.js +56 -78
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +86 -115
- package/dist/components/SummaryList/GroupAction.js +9 -17
- package/dist/components/SummaryList/GroupAction.test.js +37 -33
- package/dist/components/SummaryList/RowAction.js +11 -16
- package/dist/components/SummaryList/RowAction.test.js +37 -33
- package/dist/components/SummaryList/SummaryList.js +21 -26
- package/dist/components/SummaryList/SummaryList.test.js +143 -166
- package/dist/components/SummaryList/SummaryListHeadingRow.js +6 -4
- package/dist/components/SummaryList/SummaryListRow.js +6 -4
- package/dist/components/SummaryList/SummaryListTitleRow.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +19 -29
- package/dist/components/TaskList/Task.test.js +83 -76
- package/dist/components/TaskList/TaskList.js +45 -71
- package/dist/components/TaskList/TaskList.test.js +113 -111
- package/dist/components/TaskList/TaskState.js +7 -5
- package/dist/components/TaskList/TaskState.test.js +52 -45
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +58 -79
- package/dist/context/HooksContext/HooksContext.test.js +26 -35
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +32 -72
- package/dist/context/ValidationContext/ValidationContext.test.js +47 -59
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +9 -10
- package/dist/hooks/useAxios.js +14 -40
- package/dist/hooks/useGetRequest.js +61 -97
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +26 -39
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +13 -14
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +44 -38
- package/dist/models/TaskStates.js +30 -28
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +52 -54
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +15 -25
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +33 -35
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -31
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +42 -44
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +18 -24
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +15 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +33 -36
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +58 -60
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +79 -88
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +146 -124
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +25 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +103 -97
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +13 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +70 -76
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +24 -24
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +1 -1
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +9 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +27 -22
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +12 -16
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +29 -30
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +17 -17
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +17 -17
- package/dist/utils/Component/addShowWhen.js +4 -8
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +27 -32
- package/dist/utils/Component/cleanAttributes.js +10 -13
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +88 -94
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +18 -17
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +46 -59
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +39 -48
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +23 -33
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +20 -18
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +20 -25
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +9 -8
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +22 -26
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +57 -70
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +31 -38
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +20 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +9 -8
- package/dist/utils/Component/getDefaultValue.js +6 -8
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +22 -21
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +27 -29
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +7 -7
- package/dist/utils/Condition/meetsAllConditions.test.js +17 -17
- package/dist/utils/Condition/meetsCondition.js +14 -17
- package/dist/utils/Condition/meetsCondition.test.js +376 -376
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +13 -18
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +3 -5
- package/dist/utils/Container/getEditableComponents.test.js +43 -45
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +16 -20
- package/dist/utils/Container/setupNesting.test.js +27 -30
- package/dist/utils/Container/showContainer.js +3 -7
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +38 -48
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +18 -26
- package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +19 -25
- package/dist/utils/Data/getOptions.test.js +20 -20
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +84 -80
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/refDataToOptions.js +10 -13
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +13 -21
- package/dist/utils/Data/setupFormData.test.js +51 -50
- package/dist/utils/Data/setupRefDataUrlForComponent.js +20 -26
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +5 -9
- package/dist/utils/FormPage/applyConditionalProperties.test.js +15 -18
- package/dist/utils/FormPage/getFormPage.js +15 -16
- package/dist/utils/FormPage/getFormPage.test.js +47 -46
- package/dist/utils/FormPage/getFormPages.js +7 -12
- package/dist/utils/FormPage/getFormPages.test.js +20 -23
- package/dist/utils/FormPage/getPageActions.js +9 -15
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getPageTitle.js +2 -2
- package/dist/utils/FormPage/getPageTitle.test.js +22 -22
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +1 -1
- package/dist/utils/FormPage/showFormPage.js +3 -7
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +21 -28
- package/dist/utils/FormPage/useComponent.test.js +78 -79
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +5 -6
- package/dist/utils/Format/formatDataForComponent.test.js +50 -77
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +13 -15
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -23
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +28 -31
- package/dist/utils/Hub/index.js +1 -1
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +24 -16
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +14 -16
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +68 -34
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -46
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +22 -20
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +35 -36
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +21 -26
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +6 -6
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +7 -11
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -41
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +14 -16
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +28 -26
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +19 -25
- package/dist/utils/Validate/validateCollection.test.js +74 -66
- package/dist/utils/Validate/validateComponent.js +17 -15
- package/dist/utils/Validate/validateComponent.test.js +167 -146
- package/dist/utils/Validate/validateContainer.js +14 -19
- package/dist/utils/Validate/validateContainer.test.js +49 -45
- package/dist/utils/Validate/validateDate.js +11 -17
- package/dist/utils/Validate/validateDate.test.js +28 -29
- package/dist/utils/Validate/validateEmail.js +6 -8
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +17 -18
- package/dist/utils/Validate/validatePage.test.js +185 -182
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +7 -14
- package/dist/utils/Validate/validateTime.test.js +14 -14
- package/dist/utils/index.js +7 -9
- package/package.json +2 -2
|
@@ -6,115 +6,107 @@ var _handlers = _interopRequireDefault(require("./handlers"));
|
|
|
6
6
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
7
7
|
var _onPageAction = _interopRequireDefault(require("./onPageAction"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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 = [];
|
|
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
|
}
|
|
82
73
|
},
|
|
83
|
-
CollectionPage:
|
|
74
|
+
CollectionPage: {
|
|
75
|
+
...originalModule.default.CollectionPage,
|
|
84
76
|
duplicateActiveEntryCalls: 0,
|
|
85
77
|
duplicateActiveEntryResult: true,
|
|
86
|
-
duplicateActiveEntry
|
|
78
|
+
duplicateActiveEntry() {
|
|
87
79
|
this.duplicateActiveEntryCalls += 1;
|
|
88
80
|
return this.duplicateActiveEntryResult;
|
|
89
81
|
},
|
|
90
82
|
addEntryCalls: 0,
|
|
91
83
|
addEntryResult: true,
|
|
92
|
-
addEntry
|
|
84
|
+
addEntry(collectionName, formData) {
|
|
93
85
|
originalModule.default.CollectionPage.addEntry(collectionName, formData);
|
|
94
86
|
this.addEntryCalls += 1;
|
|
95
87
|
return this.addEntryResult;
|
|
96
88
|
}
|
|
97
|
-
}
|
|
98
|
-
reset
|
|
89
|
+
},
|
|
90
|
+
reset() {
|
|
99
91
|
this.Format.formCalls = 0;
|
|
100
92
|
this.CollectionPage.duplicateActiveEntryCalls = 0;
|
|
101
93
|
this.duplicateActiveEntryResult = true;
|
|
102
94
|
this.CollectionPage.addEntryCalls = 0;
|
|
103
95
|
this.addEntryResult = true;
|
|
104
96
|
}
|
|
105
|
-
}
|
|
97
|
+
};
|
|
106
98
|
});
|
|
107
|
-
describe('components.FormRenderer.onPageAction',
|
|
108
|
-
|
|
99
|
+
describe('components.FormRenderer.onPageAction', () => {
|
|
100
|
+
const MOCK_HOOKS = {
|
|
109
101
|
onSubmitCalls: 0,
|
|
110
102
|
onSubmitArgs: [],
|
|
111
|
-
onSubmit
|
|
103
|
+
onSubmit(type, payload, onSuccess, onError, changedFieldName, changedFieldValue) {
|
|
112
104
|
this.onSubmitCalls += 1;
|
|
113
105
|
this.onSubmitArgs.push({
|
|
114
|
-
type
|
|
115
|
-
payload
|
|
116
|
-
changedFieldName
|
|
117
|
-
changedFieldValue
|
|
106
|
+
type,
|
|
107
|
+
payload,
|
|
108
|
+
changedFieldName,
|
|
109
|
+
changedFieldValue
|
|
118
110
|
});
|
|
119
111
|
if (typeof onSuccess === 'function') {
|
|
120
112
|
onSuccess();
|
|
@@ -127,14 +119,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
127
119
|
}
|
|
128
120
|
},
|
|
129
121
|
onFormCompleteCalls: 0,
|
|
130
|
-
onFormComplete
|
|
122
|
+
onFormComplete() {
|
|
131
123
|
this.onFormCompleteCalls += 1;
|
|
132
124
|
},
|
|
133
125
|
onCancelArgs: [],
|
|
134
|
-
onCancel
|
|
126
|
+
onCancel(data) {
|
|
135
127
|
this.onCancelArgs.push(data);
|
|
136
128
|
},
|
|
137
|
-
reset
|
|
129
|
+
reset() {
|
|
138
130
|
this.onSubmitCalls = 0;
|
|
139
131
|
this.onSubmitArgs = [];
|
|
140
132
|
this.onFormCompleteCalls = 0;
|
|
@@ -142,54 +134,54 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
142
134
|
this.onActionCalls = 0;
|
|
143
135
|
},
|
|
144
136
|
onActionCalls: 0,
|
|
145
|
-
onAction
|
|
137
|
+
onAction(formData, patch) {
|
|
146
138
|
this.onActionCalls += 1;
|
|
147
139
|
return {
|
|
148
|
-
formData
|
|
149
|
-
patch
|
|
140
|
+
formData,
|
|
141
|
+
patch
|
|
150
142
|
};
|
|
151
143
|
}
|
|
152
144
|
};
|
|
153
|
-
|
|
145
|
+
const MOCK_VALIDATE = {
|
|
154
146
|
pageCalls: 0,
|
|
155
|
-
page
|
|
147
|
+
page() {
|
|
156
148
|
MOCK_VALIDATE.pageCalls += 1;
|
|
157
149
|
},
|
|
158
|
-
reset
|
|
150
|
+
reset() {
|
|
159
151
|
this.pageCalls = 0;
|
|
160
152
|
}
|
|
161
153
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
154
|
+
let setPagePointCalls = 0;
|
|
155
|
+
let setPagePointArgs = [];
|
|
156
|
+
const mockSetPagePoint = point => {
|
|
165
157
|
setPagePointCalls += 1;
|
|
166
158
|
setPagePointArgs.push(point);
|
|
167
159
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
160
|
+
let setDataCalls = 0;
|
|
161
|
+
let setDataArgs = [];
|
|
162
|
+
const mockSetData = data => {
|
|
171
163
|
setDataCalls += 1;
|
|
172
164
|
setDataArgs.push(data);
|
|
173
165
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
166
|
+
let onPageChangeCalls = 0;
|
|
167
|
+
let onPageChangeArgs = [];
|
|
168
|
+
const mockOnPageChange = pageId => {
|
|
177
169
|
onPageChangeCalls += 1;
|
|
178
170
|
onPageChangeArgs.push(pageId);
|
|
179
171
|
};
|
|
180
|
-
|
|
181
|
-
|
|
172
|
+
let addErrorsArgs = [];
|
|
173
|
+
const mockAddErrors = errors => {
|
|
182
174
|
addErrorsArgs.push(errors);
|
|
183
175
|
};
|
|
184
|
-
|
|
185
|
-
|
|
176
|
+
let setSubmittedArgs = [];
|
|
177
|
+
const mockSetSubmitted = newSubmitted => {
|
|
186
178
|
setSubmittedArgs.push(newSubmitted);
|
|
187
179
|
};
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
let mockSubmitting = false;
|
|
181
|
+
const mockSetSubmitting = submitting => {
|
|
190
182
|
mockSubmitting = submitting;
|
|
191
183
|
};
|
|
192
|
-
|
|
184
|
+
const COMPONENTS = [{
|
|
193
185
|
id: 'alpha',
|
|
194
186
|
fieldId: 'alpha'
|
|
195
187
|
}, {
|
|
@@ -202,18 +194,26 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
202
194
|
id: 'delta',
|
|
203
195
|
fieldId: 'delta'
|
|
204
196
|
}];
|
|
205
|
-
|
|
197
|
+
const PAGES = [{
|
|
206
198
|
id: 'page1',
|
|
207
|
-
components: [
|
|
199
|
+
components: [{
|
|
200
|
+
...COMPONENTS[0]
|
|
201
|
+
}, {
|
|
202
|
+
...COMPONENTS[1]
|
|
203
|
+
}]
|
|
208
204
|
}, {
|
|
209
205
|
id: 'page2',
|
|
210
|
-
components: [
|
|
206
|
+
components: [{
|
|
207
|
+
...COMPONENTS[2]
|
|
208
|
+
}, {
|
|
209
|
+
...COMPONENTS[3]
|
|
210
|
+
}]
|
|
211
211
|
}];
|
|
212
|
-
|
|
212
|
+
const CURRENT_TASK = {
|
|
213
213
|
name: 'testTask',
|
|
214
214
|
fullPages: PAGES
|
|
215
215
|
};
|
|
216
|
-
|
|
216
|
+
const ARGS = {
|
|
217
217
|
action: {
|
|
218
218
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
219
219
|
},
|
|
@@ -241,7 +241,7 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
241
241
|
submitting: mockSubmitting,
|
|
242
242
|
setSubmitting: mockSetSubmitting
|
|
243
243
|
};
|
|
244
|
-
beforeEach(
|
|
244
|
+
beforeEach(() => {
|
|
245
245
|
_handlers.default.reset();
|
|
246
246
|
_helpers.default.reset();
|
|
247
247
|
_utils.default.reset();
|
|
@@ -257,12 +257,12 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
257
257
|
setSubmittedArgs = [];
|
|
258
258
|
mockSetSubmitting(false);
|
|
259
259
|
});
|
|
260
|
-
|
|
260
|
+
const preActionChecks = () => {
|
|
261
261
|
expect(_helpers.default.canActionProceedCalls).toEqual(1);
|
|
262
262
|
expect(MOCK_VALIDATE.pageCalls).toEqual(1);
|
|
263
263
|
expect(_helpers.default.cleanHiddenNestedDataCalls).toEqual(1);
|
|
264
264
|
};
|
|
265
|
-
|
|
265
|
+
const postActionChecks = argsUsed => {
|
|
266
266
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
267
267
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
268
268
|
// setData is always called once in the error callback
|
|
@@ -270,8 +270,12 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
270
270
|
// to this if patch is valid.
|
|
271
271
|
if (argsUsed.patch) {
|
|
272
272
|
expect(setDataCalls).toEqual(2);
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
const dataUsed = {
|
|
274
|
+
...argsUsed.data,
|
|
275
|
+
...argsUsed.patch,
|
|
276
|
+
...argsUsed.formState.page.formData
|
|
277
|
+
};
|
|
278
|
+
const submissionData = _utils.default.Format.form(null, dataUsed, null);
|
|
275
279
|
submissionData.formStatus = _helpers.default.getSubmissionStatus();
|
|
276
280
|
expect(setDataArgs[0]).toEqual(submissionData);
|
|
277
281
|
} else {
|
|
@@ -279,7 +283,7 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
279
283
|
}
|
|
280
284
|
expect(MOCK_HOOKS.onSubmitCalls).toEqual(1);
|
|
281
285
|
if (argsUsed.type === _models.FormTypes.HUB && Object.keys(argsUsed.patchLabel).length > 0) {
|
|
282
|
-
|
|
286
|
+
const firstKey = Object.keys(argsUsed.patchLabel)[0];
|
|
283
287
|
expect(MOCK_HOOKS.onSubmitArgs[0]).toMatchObject({
|
|
284
288
|
changedFieldName: firstKey,
|
|
285
289
|
changedFieldValue: argsUsed.patchLabel[firstKey]
|
|
@@ -298,13 +302,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
298
302
|
expect(setDataArgs[setDataCalls - 1]).toEqual(argsUsed.data); // Data is reset in the case of an error.
|
|
299
303
|
};
|
|
300
304
|
|
|
301
|
-
it("should handle the ".concat(_models.PageAction.TYPES.CANCEL, " Page Action type"),
|
|
302
|
-
|
|
305
|
+
it("should handle the ".concat(_models.PageAction.TYPES.CANCEL, " Page Action type"), () => {
|
|
306
|
+
const ACTION = {
|
|
303
307
|
type: _models.PageAction.TYPES.CANCEL
|
|
304
308
|
};
|
|
305
|
-
|
|
309
|
+
const CUSTOM_ARGS = {
|
|
310
|
+
...ARGS,
|
|
306
311
|
action: ACTION
|
|
307
|
-
}
|
|
312
|
+
};
|
|
308
313
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
309
314
|
expect(MOCK_HOOKS.onCancelArgs.length).toEqual(1);
|
|
310
315
|
expect(MOCK_HOOKS.onCancelArgs[0]).toMatchObject({});
|
|
@@ -313,13 +318,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
313
318
|
expect(_helpers.default.canActionProceedCalls).toEqual(0);
|
|
314
319
|
expect(MOCK_VALIDATE.pageCalls).toEqual(0);
|
|
315
320
|
});
|
|
316
|
-
it("should handle the ".concat(_models.PageAction.TYPES.NAVIGATE, " Page Action type"),
|
|
317
|
-
|
|
321
|
+
it("should handle the ".concat(_models.PageAction.TYPES.NAVIGATE, " Page Action type"), () => {
|
|
322
|
+
const ACTION = {
|
|
318
323
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
319
324
|
};
|
|
320
|
-
|
|
325
|
+
const CUSTOM_ARGS = {
|
|
326
|
+
...ARGS,
|
|
321
327
|
action: ACTION
|
|
322
|
-
}
|
|
328
|
+
};
|
|
323
329
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
324
330
|
preActionChecks();
|
|
325
331
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
@@ -329,26 +335,28 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
329
335
|
// hooks.navigate.
|
|
330
336
|
});
|
|
331
337
|
|
|
332
|
-
it("should handle the ".concat(_models.PageAction.TYPES.SUBMIT, " Page Action type"),
|
|
333
|
-
|
|
338
|
+
it("should handle the ".concat(_models.PageAction.TYPES.SUBMIT, " Page Action type"), () => {
|
|
339
|
+
const ACTION = {
|
|
334
340
|
type: _models.PageAction.TYPES.SUBMIT
|
|
335
341
|
};
|
|
336
|
-
|
|
342
|
+
const CUSTOM_ARGS = {
|
|
343
|
+
...ARGS,
|
|
337
344
|
action: ACTION
|
|
338
|
-
}
|
|
345
|
+
};
|
|
339
346
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
340
347
|
preActionChecks();
|
|
341
348
|
expect(setPagePointCalls).toEqual(1);
|
|
342
349
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
343
350
|
postActionChecks(CUSTOM_ARGS);
|
|
344
351
|
});
|
|
345
|
-
it("should handle the ".concat(_models.PageAction.TYPES.SAVE_AND_NAVIGATE, " Page Action type"),
|
|
346
|
-
|
|
352
|
+
it("should handle the ".concat(_models.PageAction.TYPES.SAVE_AND_NAVIGATE, " Page Action type"), () => {
|
|
353
|
+
const ACTION = {
|
|
347
354
|
type: _models.PageAction.TYPES.SAVE_AND_NAVIGATE
|
|
348
355
|
};
|
|
349
|
-
|
|
356
|
+
const CUSTOM_ARGS = {
|
|
357
|
+
...ARGS,
|
|
350
358
|
action: ACTION
|
|
351
|
-
}
|
|
359
|
+
};
|
|
352
360
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
353
361
|
preActionChecks();
|
|
354
362
|
// All the actions does in this case is set a function
|
|
@@ -356,22 +364,23 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
356
364
|
postActionChecks(CUSTOM_ARGS);
|
|
357
365
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
358
366
|
});
|
|
359
|
-
it("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_ADD, " Page Action type"),
|
|
360
|
-
|
|
367
|
+
it("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_ADD, " Page Action type"), () => {
|
|
368
|
+
const FORM_STATE = {
|
|
361
369
|
page: {
|
|
362
370
|
formData: {
|
|
363
371
|
'testCollection': []
|
|
364
372
|
}
|
|
365
373
|
}
|
|
366
374
|
};
|
|
367
|
-
|
|
375
|
+
const ACTION = {
|
|
368
376
|
type: _models.PageAction.TYPES.COLLECTION_ADD,
|
|
369
377
|
collection: 'testCollection'
|
|
370
378
|
};
|
|
371
|
-
|
|
379
|
+
const CUSTOM_ARGS = {
|
|
380
|
+
...ARGS,
|
|
372
381
|
action: ACTION,
|
|
373
382
|
formState: FORM_STATE
|
|
374
|
-
}
|
|
383
|
+
};
|
|
375
384
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
376
385
|
preActionChecks();
|
|
377
386
|
expect(FORM_STATE.page.formData["".concat(ACTION.collection, "ActiveId")]).toBeDefined();
|
|
@@ -381,23 +390,24 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
381
390
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
382
391
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
383
392
|
});
|
|
384
|
-
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_DUPLICATE, " Page Action type"),
|
|
385
|
-
it("calling handlers.navigate if the duplication was successful",
|
|
386
|
-
|
|
393
|
+
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_DUPLICATE, " Page Action type"), () => {
|
|
394
|
+
it("calling handlers.navigate if the duplication was successful", () => {
|
|
395
|
+
const FORM_STATE = {
|
|
387
396
|
page: {
|
|
388
397
|
formData: {
|
|
389
398
|
'testCollection': []
|
|
390
399
|
}
|
|
391
400
|
}
|
|
392
401
|
};
|
|
393
|
-
|
|
402
|
+
const ACTION = {
|
|
394
403
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
395
404
|
collection: 'testCollection'
|
|
396
405
|
};
|
|
397
|
-
|
|
406
|
+
const CUSTOM_ARGS = {
|
|
407
|
+
...ARGS,
|
|
398
408
|
action: ACTION,
|
|
399
409
|
formState: FORM_STATE
|
|
400
|
-
}
|
|
410
|
+
};
|
|
401
411
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
402
412
|
preActionChecks();
|
|
403
413
|
expect(_utils.default.CollectionPage.duplicateActiveEntryCalls).toEqual(1);
|
|
@@ -407,22 +417,23 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
407
417
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
408
418
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
409
419
|
});
|
|
410
|
-
it("calling onPageChange if the duplication was unsuccessful",
|
|
411
|
-
|
|
420
|
+
it("calling onPageChange if the duplication was unsuccessful", () => {
|
|
421
|
+
const FORM_STATE = {
|
|
412
422
|
page: {
|
|
413
423
|
formData: {
|
|
414
424
|
'testCollection': []
|
|
415
425
|
}
|
|
416
426
|
}
|
|
417
427
|
};
|
|
418
|
-
|
|
428
|
+
const ACTION = {
|
|
419
429
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
420
430
|
collection: 'testCollection'
|
|
421
431
|
};
|
|
422
|
-
|
|
432
|
+
const CUSTOM_ARGS = {
|
|
433
|
+
...ARGS,
|
|
423
434
|
action: ACTION,
|
|
424
435
|
formState: FORM_STATE
|
|
425
|
-
}
|
|
436
|
+
};
|
|
426
437
|
_utils.default.CollectionPage.duplicateActiveEntryResult = false;
|
|
427
438
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
428
439
|
preActionChecks();
|
|
@@ -436,9 +447,9 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
436
447
|
expect(onPageChangeCalls).toEqual(1);
|
|
437
448
|
});
|
|
438
449
|
});
|
|
439
|
-
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_REMOVE, " Page Action type"),
|
|
440
|
-
it("should store a reference to the removed item if action.recordRemoval is true",
|
|
441
|
-
|
|
450
|
+
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_REMOVE, " Page Action type"), () => {
|
|
451
|
+
it("should store a reference to the removed item if action.recordRemoval is true", () => {
|
|
452
|
+
const FORM_STATE = {
|
|
442
453
|
page: {
|
|
443
454
|
formData: {
|
|
444
455
|
testCollectionActiveId: 'removeMe',
|
|
@@ -450,15 +461,16 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
450
461
|
}
|
|
451
462
|
}
|
|
452
463
|
};
|
|
453
|
-
|
|
464
|
+
const ACTION = {
|
|
454
465
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
455
466
|
collection: 'testCollection',
|
|
456
467
|
recordRemoval: true
|
|
457
468
|
};
|
|
458
|
-
|
|
469
|
+
const CUSTOM_ARGS = {
|
|
470
|
+
...ARGS,
|
|
459
471
|
action: ACTION,
|
|
460
472
|
formState: FORM_STATE
|
|
461
|
-
}
|
|
473
|
+
};
|
|
462
474
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
463
475
|
preActionChecks();
|
|
464
476
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -472,8 +484,8 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
472
484
|
// This action type uses the default onPageChange.
|
|
473
485
|
expect(onPageChangeCalls).toEqual(1);
|
|
474
486
|
});
|
|
475
|
-
it("should not store a reference to the removed item if action.recordRemoval is false",
|
|
476
|
-
|
|
487
|
+
it("should not store a reference to the removed item if action.recordRemoval is false", () => {
|
|
488
|
+
const FORM_STATE = {
|
|
477
489
|
page: {
|
|
478
490
|
formData: {
|
|
479
491
|
testCollectionActiveId: 'removeMe',
|
|
@@ -485,15 +497,16 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
485
497
|
}
|
|
486
498
|
}
|
|
487
499
|
};
|
|
488
|
-
|
|
500
|
+
const ACTION = {
|
|
489
501
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
490
502
|
collection: 'testCollection',
|
|
491
503
|
recordRemoval: false
|
|
492
504
|
};
|
|
493
|
-
|
|
505
|
+
const CUSTOM_ARGS = {
|
|
506
|
+
...ARGS,
|
|
494
507
|
action: ACTION,
|
|
495
508
|
formState: FORM_STATE
|
|
496
|
-
}
|
|
509
|
+
};
|
|
497
510
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
498
511
|
preActionChecks();
|
|
499
512
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -505,8 +518,8 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
505
518
|
// This action type uses the default onPageChange.
|
|
506
519
|
expect(onPageChangeCalls).toEqual(1);
|
|
507
520
|
});
|
|
508
|
-
it("should not store a reference to the removed item if action.recordRemoval is not defined",
|
|
509
|
-
|
|
521
|
+
it("should not store a reference to the removed item if action.recordRemoval is not defined", () => {
|
|
522
|
+
const FORM_STATE = {
|
|
510
523
|
page: {
|
|
511
524
|
formData: {
|
|
512
525
|
testCollectionActiveId: 'removeMe',
|
|
@@ -518,14 +531,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
518
531
|
}
|
|
519
532
|
}
|
|
520
533
|
};
|
|
521
|
-
|
|
534
|
+
const ACTION = {
|
|
522
535
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
523
536
|
collection: 'testCollection'
|
|
524
537
|
};
|
|
525
|
-
|
|
538
|
+
const CUSTOM_ARGS = {
|
|
539
|
+
...ARGS,
|
|
526
540
|
action: ACTION,
|
|
527
541
|
formState: FORM_STATE
|
|
528
|
-
}
|
|
542
|
+
};
|
|
529
543
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
530
544
|
preActionChecks();
|
|
531
545
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -538,18 +552,17 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
538
552
|
expect(onPageChangeCalls).toEqual(1);
|
|
539
553
|
});
|
|
540
554
|
});
|
|
541
|
-
describe('if validation fails',
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
it("should not continue for the ".concat(actionType, " action type"), function () {
|
|
547
|
-
var ACTION = {
|
|
555
|
+
describe('if validation fails', () => {
|
|
556
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL);
|
|
557
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
558
|
+
it("should not continue for the ".concat(actionType, " action type"), () => {
|
|
559
|
+
const ACTION = {
|
|
548
560
|
type: actionType
|
|
549
561
|
};
|
|
550
|
-
|
|
562
|
+
const CUSTOM_ARGS = {
|
|
563
|
+
...ARGS,
|
|
551
564
|
action: ACTION
|
|
552
|
-
}
|
|
565
|
+
};
|
|
553
566
|
_helpers.default.canActionProceedResult = false;
|
|
554
567
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
555
568
|
expect(_helpers.default.canActionProceedCalls).toEqual(1);
|
|
@@ -560,20 +573,18 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
560
573
|
});
|
|
561
574
|
});
|
|
562
575
|
});
|
|
563
|
-
describe('adding a field to formData if specified on the action',
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
it("should work for the ".concat(actionType, " action type"), function () {
|
|
569
|
-
var FORM_STATE = {
|
|
576
|
+
describe('adding a field to formData if specified on the action', () => {
|
|
577
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE);
|
|
578
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
579
|
+
it("should work for the ".concat(actionType, " action type"), () => {
|
|
580
|
+
const FORM_STATE = {
|
|
570
581
|
page: {
|
|
571
582
|
formData: {
|
|
572
583
|
testCollection: []
|
|
573
584
|
}
|
|
574
585
|
}
|
|
575
586
|
};
|
|
576
|
-
|
|
587
|
+
const ACTION = {
|
|
577
588
|
type: actionType,
|
|
578
589
|
collection: 'testCollection',
|
|
579
590
|
addToFormData: {
|
|
@@ -581,10 +592,11 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
581
592
|
value: '123'
|
|
582
593
|
}
|
|
583
594
|
};
|
|
584
|
-
|
|
595
|
+
const CUSTOM_ARGS = {
|
|
596
|
+
...ARGS,
|
|
585
597
|
formState: FORM_STATE,
|
|
586
598
|
action: ACTION
|
|
587
|
-
}
|
|
599
|
+
};
|
|
588
600
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
589
601
|
preActionChecks();
|
|
590
602
|
postActionChecks(CUSTOM_ARGS);
|
|
@@ -593,15 +605,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
593
605
|
});
|
|
594
606
|
});
|
|
595
607
|
});
|
|
596
|
-
it("should work for the ".concat(_models.PageAction.TYPES.NAVIGATE, " action type"),
|
|
597
|
-
|
|
608
|
+
it("should work for the ".concat(_models.PageAction.TYPES.NAVIGATE, " action type"), () => {
|
|
609
|
+
const FORM_STATE = {
|
|
598
610
|
page: {
|
|
599
611
|
formData: {
|
|
600
612
|
testCollection: []
|
|
601
613
|
}
|
|
602
614
|
}
|
|
603
615
|
};
|
|
604
|
-
|
|
616
|
+
const ACTION = {
|
|
605
617
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
606
618
|
collection: 'testCollection',
|
|
607
619
|
addToFormData: {
|
|
@@ -609,10 +621,11 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
609
621
|
value: '123'
|
|
610
622
|
}
|
|
611
623
|
};
|
|
612
|
-
|
|
624
|
+
const CUSTOM_ARGS = {
|
|
625
|
+
...ARGS,
|
|
613
626
|
formState: FORM_STATE,
|
|
614
627
|
action: ACTION
|
|
615
|
-
}
|
|
628
|
+
};
|
|
616
629
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
617
630
|
preActionChecks();
|
|
618
631
|
// Not doing the usual post-action checks here
|
|
@@ -622,15 +635,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
622
635
|
alpha: '123'
|
|
623
636
|
});
|
|
624
637
|
});
|
|
625
|
-
it('should work for an array of formData',
|
|
626
|
-
|
|
638
|
+
it('should work for an array of formData', () => {
|
|
639
|
+
const FORM_STATE = {
|
|
627
640
|
page: {
|
|
628
641
|
formData: {
|
|
629
642
|
testCollection: []
|
|
630
643
|
}
|
|
631
644
|
}
|
|
632
645
|
};
|
|
633
|
-
|
|
646
|
+
const ACTION = {
|
|
634
647
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
635
648
|
collection: 'testCollection',
|
|
636
649
|
addToFormData: [{
|
|
@@ -641,10 +654,11 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
641
654
|
value: '456'
|
|
642
655
|
}]
|
|
643
656
|
};
|
|
644
|
-
|
|
657
|
+
const CUSTOM_ARGS = {
|
|
658
|
+
...ARGS,
|
|
645
659
|
formState: FORM_STATE,
|
|
646
660
|
action: ACTION
|
|
647
|
-
}
|
|
661
|
+
};
|
|
648
662
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
649
663
|
preActionChecks();
|
|
650
664
|
// Not doing the usual post-action checks here
|
|
@@ -658,34 +672,37 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
658
672
|
});
|
|
659
673
|
});
|
|
660
674
|
});
|
|
661
|
-
describe('recording patchLabel fields correctly when it is defined',
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
it("should work for the ".concat(actionType, " action type"), function () {
|
|
667
|
-
var FORM_STATE = {
|
|
675
|
+
describe('recording patchLabel fields correctly when it is defined', () => {
|
|
676
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE);
|
|
677
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
678
|
+
it("should work for the ".concat(actionType, " action type"), () => {
|
|
679
|
+
const FORM_STATE = {
|
|
668
680
|
page: {
|
|
669
681
|
formData: {
|
|
670
682
|
testCollection: []
|
|
671
683
|
}
|
|
672
684
|
}
|
|
673
685
|
};
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
686
|
+
const KEY = 'testField';
|
|
687
|
+
const VALUE = 'testValue';
|
|
688
|
+
const PATCH_LABEL = {
|
|
689
|
+
[KEY]: VALUE
|
|
690
|
+
};
|
|
691
|
+
const PATCH = {
|
|
692
|
+
[KEY]: VALUE
|
|
693
|
+
};
|
|
694
|
+
const ACTION = {
|
|
679
695
|
type: actionType,
|
|
680
696
|
collection: 'testCollection'
|
|
681
697
|
};
|
|
682
|
-
|
|
698
|
+
const CUSTOM_ARGS = {
|
|
699
|
+
...ARGS,
|
|
683
700
|
action: ACTION,
|
|
684
701
|
formState: FORM_STATE,
|
|
685
702
|
patch: PATCH,
|
|
686
703
|
patchLabel: PATCH_LABEL,
|
|
687
704
|
type: _models.FormTypes.HUB
|
|
688
|
-
}
|
|
705
|
+
};
|
|
689
706
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
690
707
|
preActionChecks();
|
|
691
708
|
postActionChecks(CUSTOM_ARGS); // Specific check for patchLabel done in here.
|