@ukhomeoffice/cop-react-form-renderer 5.89.0 → 5.90.1
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 +132 -181
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +106 -142
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +563 -941
- package/dist/components/CheckYourAnswers/index.js +1 -1
- package/dist/components/CollectionPage/CollectionPage.js +76 -66
- package/dist/components/CollectionPage/CollectionPage.test.js +318 -369
- package/dist/components/CollectionPage/index.js +1 -1
- package/dist/components/CollectionSummary/BannerStrip.js +15 -15
- package/dist/components/CollectionSummary/BannerStrip.test.js +83 -79
- package/dist/components/CollectionSummary/CollectionSummary.js +109 -131
- package/dist/components/CollectionSummary/CollectionSummary.test.js +198 -180
- package/dist/components/CollectionSummary/Confirmation.js +15 -13
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +47 -55
- package/dist/components/CollectionSummary/RenderListView.test.js +82 -81
- package/dist/components/CollectionSummary/SummaryCard.js +121 -157
- package/dist/components/CollectionSummary/SummaryCard.test.js +970 -1000
- package/dist/components/CollectionSummary/SummaryCardDetails.js +103 -94
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +187 -195
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +64 -76
- package/dist/components/CollectionSummary/index.js +1 -1
- package/dist/components/FormComponent/Collection.js +81 -117
- package/dist/components/FormComponent/Collection.scss +1 -1
- package/dist/components/FormComponent/Collection.test.js +910 -1082
- package/dist/components/FormComponent/Container.js +45 -38
- package/dist/components/FormComponent/Container.scss +15 -0
- package/dist/components/FormComponent/Container.test.js +379 -411
- package/dist/components/FormComponent/FormComponent.js +71 -74
- package/dist/components/FormComponent/FormComponent.test.js +354 -415
- 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 +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- 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 +1 -1
- package/dist/components/FormPage/FormPage.js +71 -87
- package/dist/components/FormPage/FormPage.test.js +133 -170
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +153 -198
- package/dist/components/FormRenderer/FormRenderer.test.js +731 -1116
- package/dist/components/FormRenderer/handlers/cyaAction.js +3 -3
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- 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 +2 -2
- package/dist/components/FormRenderer/handlers/navigate.js +4 -4
- 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 +16 -16
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +27 -30
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
- package/dist/components/FormRenderer/helpers/getCYA.js +5 -7
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +6 -8
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +18 -32
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +8 -11
- 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 +104 -98
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +65 -64
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +72 -79
- package/dist/components/FormRenderer/helpers/index.js +2 -2
- package/dist/components/FormRenderer/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +61 -54
- package/dist/components/FormRenderer/onCYAAction.test.js +165 -153
- package/dist/components/FormRenderer/onPageAction.js +45 -41
- package/dist/components/FormRenderer/onPageAction.test.js +225 -210
- package/dist/components/FormRenderer/onTaskAction.js +11 -15
- package/dist/components/FormRenderer/onTaskAction.test.js +94 -89
- package/dist/components/PageActions/ActionButton.js +13 -16
- package/dist/components/PageActions/ActionButton.test.js +57 -79
- package/dist/components/PageActions/PageActions.js +11 -11
- package/dist/components/PageActions/PageActions.test.js +87 -116
- package/dist/components/PageActions/index.js +1 -1
- package/dist/components/SummaryList/GroupAction.js +13 -21
- package/dist/components/SummaryList/GroupAction.test.js +41 -37
- package/dist/components/SummaryList/RowAction.js +12 -17
- package/dist/components/SummaryList/RowAction.test.js +41 -37
- package/dist/components/SummaryList/SummaryList.js +23 -28
- package/dist/components/SummaryList/SummaryList.test.js +179 -206
- package/dist/components/SummaryList/SummaryListHeadingRow.js +8 -6
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
- package/dist/components/SummaryList/SummaryListRow.js +8 -6
- package/dist/components/SummaryList/SummaryListTitleRow.js +7 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +4 -6
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +4 -6
- 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 +1 -1
- package/dist/components/TaskList/Task.js +20 -30
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +53 -84
- package/dist/components/TaskList/TaskList.test.js +150 -150
- package/dist/components/TaskList/TaskState.js +8 -6
- package/dist/components/TaskList/TaskState.test.js +56 -49
- package/dist/components/TaskList/index.js +1 -1
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +58 -81
- package/dist/context/HooksContext/HooksContext.test.js +27 -36
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +44 -95
- package/dist/context/ValidationContext/ValidationContext.test.js +58 -70
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +15 -41
- package/dist/hooks/useGetRequest.js +62 -98
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +28 -41
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +14 -15
- 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 +29 -28
- package/dist/models/index.js +10 -10
- package/dist/setupTests.js +31 -32
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +17 -27
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +34 -36
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +20 -34
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +43 -45
- package/dist/utils/CheckYourAnswers/getCYARow.js +8 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -25
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +39 -45
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +72 -75
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +100 -105
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +218 -182
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +26 -21
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +15 -21
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +77 -83
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +13 -13
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +14 -19
- package/dist/utils/CheckYourAnswers/index.js +2 -2
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +6 -6
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +3 -3
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +21 -22
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +15 -24
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +52 -43
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +3 -3
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -12
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -13
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
- package/dist/utils/CollectionPage/getErrorsForCollection.js +25 -26
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
- package/dist/utils/CollectionPage/getQuickEditPage.js +37 -32
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +18 -22
- package/dist/utils/CollectionPage/index.js +2 -2
- package/dist/utils/CollectionPage/mergeCollectionPages.js +37 -42
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +26 -22
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
- package/dist/utils/CollectionPage/setCollectionPageData.js +13 -19
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +26 -26
- package/dist/utils/Component/addShowWhen.js +4 -8
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +19 -20
- package/dist/utils/Component/applyToComponentTree.test.js +28 -33
- package/dist/utils/Component/cleanAttributes.js +10 -13
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +6 -7
- package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
- package/dist/utils/Component/getComponent.js +90 -97
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +50 -63
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +30 -40
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +22 -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 +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +58 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +34 -41
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +23 -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 +13 -13
- package/dist/utils/Component/getDefaultValueFromConfig.js +24 -24
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +32 -32
- package/dist/utils/Component/index.js +2 -2
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -4
- package/dist/utils/Component/optionIsSelected.test.js +12 -12
- package/dist/utils/Component/setupContainerComponentsPath.js +29 -31
- package/dist/utils/Component/setupContainerComponentsPath.test.js +16 -16
- package/dist/utils/Component/showComponent.js +3 -4
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +4 -4
- package/dist/utils/Condition/index.js +2 -2
- package/dist/utils/Condition/meetsAllConditions.js +9 -9
- package/dist/utils/Condition/meetsAllConditions.test.js +21 -21
- package/dist/utils/Condition/meetsCondition.js +20 -31
- package/dist/utils/Condition/meetsCondition.test.js +403 -403
- package/dist/utils/Condition/meetsOneCondition.js +6 -6
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +14 -19
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +4 -6
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +2 -2
- package/dist/utils/Container/setupNesting.js +16 -22
- package/dist/utils/Container/setupNesting.test.js +28 -31
- package/dist/utils/Container/showContainer.js +4 -8
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +40 -50
- package/dist/utils/Data/applyFormula.test.js +26 -26
- package/dist/utils/Data/deleteValues.js +4 -8
- package/dist/utils/Data/deleteValues.test.js +11 -11
- package/dist/utils/Data/getAutocompleteSource.js +20 -29
- package/dist/utils/Data/getAutocompleteSource.test.js +81 -87
- package/dist/utils/Data/getDataPath.js +20 -30
- package/dist/utils/Data/getDataPath.test.js +20 -20
- package/dist/utils/Data/getOptions.js +27 -34
- package/dist/utils/Data/getOptions.test.js +28 -28
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +2 -2
- package/dist/utils/Data/nestInRefdataOptions.js +9 -16
- package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
- package/dist/utils/Data/refDataToOptions.js +11 -15
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +14 -22
- package/dist/utils/Data/setupFormData.test.js +52 -51
- package/dist/utils/Data/setupRefDataUrlForComponent.js +21 -28
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +28 -28
- package/dist/utils/FormPage/applyConditionalProperties.js +6 -10
- package/dist/utils/FormPage/applyConditionalProperties.test.js +16 -19
- package/dist/utils/FormPage/getConditionalText.js +4 -4
- package/dist/utils/FormPage/getConditionalText.test.js +35 -35
- package/dist/utils/FormPage/getFormPage.js +16 -17
- package/dist/utils/FormPage/getFormPage.test.js +49 -48
- package/dist/utils/FormPage/getFormPages.js +8 -13
- package/dist/utils/FormPage/getFormPages.test.js +22 -25
- package/dist/utils/FormPage/getPageActions.js +10 -17
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -5
- package/dist/utils/FormPage/showFormPage.js +4 -8
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +3 -3
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +21 -28
- package/dist/utils/FormPage/useComponent.test.js +78 -80
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -7
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +2 -2
- package/dist/utils/Hub/getFormHub.js +2 -2
- package/dist/utils/Hub/getFormHub.test.js +29 -32
- package/dist/utils/Hub/index.js +2 -2
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +15 -17
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +69 -35
- package/dist/utils/Meta/index.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.js +4 -4
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/deleteValueInFormData.js +3 -3
- package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
- package/dist/utils/Operate/getFirstOf.js +8 -8
- package/dist/utils/Operate/getFirstOf.test.js +33 -33
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +12 -12
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/getLength.js +11 -11
- package/dist/utils/Operate/getLength.test.js +19 -19
- package/dist/utils/Operate/index.js +2 -2
- package/dist/utils/Operate/persistValueInFormData.js +6 -6
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +9 -9
- package/dist/utils/Operate/runPageOperations.test.js +36 -37
- package/dist/utils/Operate/setValueInFormData.js +5 -5
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +8 -8
- package/dist/utils/Operate/shouldRun.test.js +22 -28
- package/dist/utils/Validate/additional/conditionallyPermittedChange.js +25 -0
- package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +33 -0
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -5
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +10 -8
- package/dist/utils/Validate/additional/index.test.js +22 -22
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -3
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -3
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +9 -14
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +38 -42
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +4 -4
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -5
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeOneOf.js +1 -1
- package/dist/utils/Validate/additional/mustBeOneOf.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +5 -5
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +36 -40
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +3 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +15 -15
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +3 -5
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +11 -24
- package/dist/utils/Validate/index.js +2 -2
- package/dist/utils/Validate/validateCollection.js +21 -27
- package/dist/utils/Validate/validateCollection.test.js +85 -77
- package/dist/utils/Validate/validateComponent.js +22 -23
- package/dist/utils/Validate/validateComponent.test.js +188 -165
- package/dist/utils/Validate/validateContainer.js +16 -21
- package/dist/utils/Validate/validateContainer.test.js +62 -56
- package/dist/utils/Validate/validateDate.js +17 -23
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +7 -9
- package/dist/utils/Validate/validateEmail.test.js +26 -26
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +20 -24
- package/dist/utils/Validate/validatePage.test.js +227 -215
- package/dist/utils/Validate/validateRegex.js +5 -8
- package/dist/utils/Validate/validateRegex.test.js +17 -17
- package/dist/utils/Validate/validateRequired.js +5 -7
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +5 -7
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +12 -19
- package/dist/utils/Validate/validateTime.test.js +27 -27
- package/dist/utils/index.js +8 -10
- package/package.json +3 -2
|
@@ -5,116 +5,108 @@ 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
|
}
|
|
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]
|
|
@@ -297,14 +301,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
297
301
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
298
302
|
expect(setDataArgs[setDataCalls - 1]).toEqual(argsUsed.data); // Data is reset in the case of an error.
|
|
299
303
|
};
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
var ACTION = {
|
|
304
|
+
it(`should handle the ${_models.PageAction.TYPES.CANCEL} Page Action type`, () => {
|
|
305
|
+
const ACTION = {
|
|
303
306
|
type: _models.PageAction.TYPES.CANCEL
|
|
304
307
|
};
|
|
305
|
-
|
|
308
|
+
const CUSTOM_ARGS = {
|
|
309
|
+
...ARGS,
|
|
306
310
|
action: ACTION
|
|
307
|
-
}
|
|
311
|
+
};
|
|
308
312
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
309
313
|
expect(MOCK_HOOKS.onCancelArgs.length).toEqual(1);
|
|
310
314
|
expect(MOCK_HOOKS.onCancelArgs[0]).toMatchObject({});
|
|
@@ -313,13 +317,14 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
313
317
|
expect(_helpers.default.canActionProceedCalls).toEqual(0);
|
|
314
318
|
expect(MOCK_VALIDATE.pageCalls).toEqual(0);
|
|
315
319
|
});
|
|
316
|
-
it(
|
|
317
|
-
|
|
320
|
+
it(`should handle the ${_models.PageAction.TYPES.NAVIGATE} Page Action type`, () => {
|
|
321
|
+
const ACTION = {
|
|
318
322
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
319
323
|
};
|
|
320
|
-
|
|
324
|
+
const CUSTOM_ARGS = {
|
|
325
|
+
...ARGS,
|
|
321
326
|
action: ACTION
|
|
322
|
-
}
|
|
327
|
+
};
|
|
323
328
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
324
329
|
preActionChecks();
|
|
325
330
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
@@ -328,27 +333,28 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
328
333
|
// as a navigate action should stop at calling
|
|
329
334
|
// hooks.navigate.
|
|
330
335
|
});
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var ACTION = {
|
|
336
|
+
it(`should handle the ${_models.PageAction.TYPES.SUBMIT} Page Action type`, () => {
|
|
337
|
+
const ACTION = {
|
|
334
338
|
type: _models.PageAction.TYPES.SUBMIT
|
|
335
339
|
};
|
|
336
|
-
|
|
340
|
+
const CUSTOM_ARGS = {
|
|
341
|
+
...ARGS,
|
|
337
342
|
action: ACTION
|
|
338
|
-
}
|
|
343
|
+
};
|
|
339
344
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
340
345
|
preActionChecks();
|
|
341
346
|
expect(setPagePointCalls).toEqual(1);
|
|
342
347
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
343
348
|
postActionChecks(CUSTOM_ARGS);
|
|
344
349
|
});
|
|
345
|
-
it(
|
|
346
|
-
|
|
350
|
+
it(`should handle the ${_models.PageAction.TYPES.SAVE_AND_NAVIGATE} Page Action type`, () => {
|
|
351
|
+
const ACTION = {
|
|
347
352
|
type: _models.PageAction.TYPES.SAVE_AND_NAVIGATE
|
|
348
353
|
};
|
|
349
|
-
|
|
354
|
+
const CUSTOM_ARGS = {
|
|
355
|
+
...ARGS,
|
|
350
356
|
action: ACTION
|
|
351
|
-
}
|
|
357
|
+
};
|
|
352
358
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
353
359
|
preActionChecks();
|
|
354
360
|
// All the actions does in this case is set a function
|
|
@@ -356,48 +362,50 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
356
362
|
postActionChecks(CUSTOM_ARGS);
|
|
357
363
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
358
364
|
});
|
|
359
|
-
it(
|
|
360
|
-
|
|
365
|
+
it(`should handle the ${_models.PageAction.TYPES.COLLECTION_ADD} Page Action type`, () => {
|
|
366
|
+
const FORM_STATE = {
|
|
361
367
|
page: {
|
|
362
368
|
formData: {
|
|
363
369
|
'testCollection': []
|
|
364
370
|
}
|
|
365
371
|
}
|
|
366
372
|
};
|
|
367
|
-
|
|
373
|
+
const ACTION = {
|
|
368
374
|
type: _models.PageAction.TYPES.COLLECTION_ADD,
|
|
369
375
|
collection: 'testCollection'
|
|
370
376
|
};
|
|
371
|
-
|
|
377
|
+
const CUSTOM_ARGS = {
|
|
378
|
+
...ARGS,
|
|
372
379
|
action: ACTION,
|
|
373
380
|
formState: FORM_STATE
|
|
374
|
-
}
|
|
381
|
+
};
|
|
375
382
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
376
383
|
preActionChecks();
|
|
377
|
-
expect(FORM_STATE.page.formData[
|
|
384
|
+
expect(FORM_STATE.page.formData[`${ACTION.collection}ActiveId`]).toBeDefined();
|
|
378
385
|
postActionChecks(CUSTOM_ARGS);
|
|
379
386
|
|
|
380
387
|
// This action type also sets up a call to handlers.navigate
|
|
381
388
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
382
389
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
383
390
|
});
|
|
384
|
-
describe(
|
|
385
|
-
it(
|
|
386
|
-
|
|
391
|
+
describe(`should handle the ${_models.PageAction.TYPES.COLLECTION_DUPLICATE} Page Action type`, () => {
|
|
392
|
+
it(`calling handlers.navigate if the duplication was successful`, () => {
|
|
393
|
+
const FORM_STATE = {
|
|
387
394
|
page: {
|
|
388
395
|
formData: {
|
|
389
396
|
'testCollection': []
|
|
390
397
|
}
|
|
391
398
|
}
|
|
392
399
|
};
|
|
393
|
-
|
|
400
|
+
const ACTION = {
|
|
394
401
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
395
402
|
collection: 'testCollection'
|
|
396
403
|
};
|
|
397
|
-
|
|
404
|
+
const CUSTOM_ARGS = {
|
|
405
|
+
...ARGS,
|
|
398
406
|
action: ACTION,
|
|
399
407
|
formState: FORM_STATE
|
|
400
|
-
}
|
|
408
|
+
};
|
|
401
409
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
402
410
|
preActionChecks();
|
|
403
411
|
expect(_utils.default.CollectionPage.duplicateActiveEntryCalls).toEqual(1);
|
|
@@ -407,22 +415,23 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
407
415
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
408
416
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
409
417
|
});
|
|
410
|
-
it(
|
|
411
|
-
|
|
418
|
+
it(`calling onPageChange if the duplication was unsuccessful`, () => {
|
|
419
|
+
const FORM_STATE = {
|
|
412
420
|
page: {
|
|
413
421
|
formData: {
|
|
414
422
|
'testCollection': []
|
|
415
423
|
}
|
|
416
424
|
}
|
|
417
425
|
};
|
|
418
|
-
|
|
426
|
+
const ACTION = {
|
|
419
427
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
420
428
|
collection: 'testCollection'
|
|
421
429
|
};
|
|
422
|
-
|
|
430
|
+
const CUSTOM_ARGS = {
|
|
431
|
+
...ARGS,
|
|
423
432
|
action: ACTION,
|
|
424
433
|
formState: FORM_STATE
|
|
425
|
-
}
|
|
434
|
+
};
|
|
426
435
|
_utils.default.CollectionPage.duplicateActiveEntryResult = false;
|
|
427
436
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
428
437
|
preActionChecks();
|
|
@@ -436,9 +445,9 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
436
445
|
expect(onPageChangeCalls).toEqual(1);
|
|
437
446
|
});
|
|
438
447
|
});
|
|
439
|
-
describe(
|
|
440
|
-
it(
|
|
441
|
-
|
|
448
|
+
describe(`should handle the ${_models.PageAction.TYPES.COLLECTION_REMOVE} Page Action type`, () => {
|
|
449
|
+
it(`should store a reference to the removed item if action.recordRemoval is true`, () => {
|
|
450
|
+
const FORM_STATE = {
|
|
442
451
|
page: {
|
|
443
452
|
formData: {
|
|
444
453
|
testCollectionActiveId: 'removeMe',
|
|
@@ -450,15 +459,16 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
450
459
|
}
|
|
451
460
|
}
|
|
452
461
|
};
|
|
453
|
-
|
|
462
|
+
const ACTION = {
|
|
454
463
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
455
464
|
collection: 'testCollection',
|
|
456
465
|
recordRemoval: true
|
|
457
466
|
};
|
|
458
|
-
|
|
467
|
+
const CUSTOM_ARGS = {
|
|
468
|
+
...ARGS,
|
|
459
469
|
action: ACTION,
|
|
460
470
|
formState: FORM_STATE
|
|
461
|
-
}
|
|
471
|
+
};
|
|
462
472
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
463
473
|
preActionChecks();
|
|
464
474
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -472,8 +482,8 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
472
482
|
// This action type uses the default onPageChange.
|
|
473
483
|
expect(onPageChangeCalls).toEqual(1);
|
|
474
484
|
});
|
|
475
|
-
it(
|
|
476
|
-
|
|
485
|
+
it(`should not store a reference to the removed item if action.recordRemoval is false`, () => {
|
|
486
|
+
const FORM_STATE = {
|
|
477
487
|
page: {
|
|
478
488
|
formData: {
|
|
479
489
|
testCollectionActiveId: 'removeMe',
|
|
@@ -485,15 +495,16 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
485
495
|
}
|
|
486
496
|
}
|
|
487
497
|
};
|
|
488
|
-
|
|
498
|
+
const ACTION = {
|
|
489
499
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
490
500
|
collection: 'testCollection',
|
|
491
501
|
recordRemoval: false
|
|
492
502
|
};
|
|
493
|
-
|
|
503
|
+
const CUSTOM_ARGS = {
|
|
504
|
+
...ARGS,
|
|
494
505
|
action: ACTION,
|
|
495
506
|
formState: FORM_STATE
|
|
496
|
-
}
|
|
507
|
+
};
|
|
497
508
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
498
509
|
preActionChecks();
|
|
499
510
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -505,8 +516,8 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
505
516
|
// This action type uses the default onPageChange.
|
|
506
517
|
expect(onPageChangeCalls).toEqual(1);
|
|
507
518
|
});
|
|
508
|
-
it(
|
|
509
|
-
|
|
519
|
+
it(`should not store a reference to the removed item if action.recordRemoval is not defined`, () => {
|
|
520
|
+
const FORM_STATE = {
|
|
510
521
|
page: {
|
|
511
522
|
formData: {
|
|
512
523
|
testCollectionActiveId: 'removeMe',
|
|
@@ -518,14 +529,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
518
529
|
}
|
|
519
530
|
}
|
|
520
531
|
};
|
|
521
|
-
|
|
532
|
+
const ACTION = {
|
|
522
533
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
523
534
|
collection: 'testCollection'
|
|
524
535
|
};
|
|
525
|
-
|
|
536
|
+
const CUSTOM_ARGS = {
|
|
537
|
+
...ARGS,
|
|
526
538
|
action: ACTION,
|
|
527
539
|
formState: FORM_STATE
|
|
528
|
-
}
|
|
540
|
+
};
|
|
529
541
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
530
542
|
preActionChecks();
|
|
531
543
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -538,18 +550,17 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
538
550
|
expect(onPageChangeCalls).toEqual(1);
|
|
539
551
|
});
|
|
540
552
|
});
|
|
541
|
-
describe('if validation fails',
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
it("should not continue for the ".concat(actionType, " action type"), function () {
|
|
547
|
-
var ACTION = {
|
|
553
|
+
describe('if validation fails', () => {
|
|
554
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL);
|
|
555
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
556
|
+
it(`should not continue for the ${actionType} action type`, () => {
|
|
557
|
+
const ACTION = {
|
|
548
558
|
type: actionType
|
|
549
559
|
};
|
|
550
|
-
|
|
560
|
+
const CUSTOM_ARGS = {
|
|
561
|
+
...ARGS,
|
|
551
562
|
action: ACTION
|
|
552
|
-
}
|
|
563
|
+
};
|
|
553
564
|
_helpers.default.canActionProceedResult = false;
|
|
554
565
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
555
566
|
expect(_helpers.default.canActionProceedCalls).toEqual(1);
|
|
@@ -560,20 +571,18 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
560
571
|
});
|
|
561
572
|
});
|
|
562
573
|
});
|
|
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 = {
|
|
574
|
+
describe('adding a field to formData if specified on the action', () => {
|
|
575
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE);
|
|
576
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
577
|
+
it(`should work for the ${actionType} action type`, () => {
|
|
578
|
+
const FORM_STATE = {
|
|
570
579
|
page: {
|
|
571
580
|
formData: {
|
|
572
581
|
testCollection: []
|
|
573
582
|
}
|
|
574
583
|
}
|
|
575
584
|
};
|
|
576
|
-
|
|
585
|
+
const ACTION = {
|
|
577
586
|
type: actionType,
|
|
578
587
|
collection: 'testCollection',
|
|
579
588
|
addToFormData: [{
|
|
@@ -587,10 +596,11 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
587
596
|
isCollection: true
|
|
588
597
|
}]
|
|
589
598
|
};
|
|
590
|
-
|
|
599
|
+
const CUSTOM_ARGS = {
|
|
600
|
+
...ARGS,
|
|
591
601
|
formState: FORM_STATE,
|
|
592
602
|
action: ACTION
|
|
593
|
-
}
|
|
603
|
+
};
|
|
594
604
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
595
605
|
preActionChecks();
|
|
596
606
|
postActionChecks(CUSTOM_ARGS);
|
|
@@ -600,15 +610,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
600
610
|
expect(FORM_STATE.page.formData.parent[0].child[0].id).toEqual('12345');
|
|
601
611
|
});
|
|
602
612
|
});
|
|
603
|
-
it(
|
|
604
|
-
|
|
613
|
+
it(`should work for the ${_models.PageAction.TYPES.NAVIGATE} action type`, () => {
|
|
614
|
+
const FORM_STATE = {
|
|
605
615
|
page: {
|
|
606
616
|
formData: {
|
|
607
617
|
testCollection: []
|
|
608
618
|
}
|
|
609
619
|
}
|
|
610
620
|
};
|
|
611
|
-
|
|
621
|
+
const ACTION = {
|
|
612
622
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
613
623
|
collection: 'testCollection',
|
|
614
624
|
addToFormData: [{
|
|
@@ -622,10 +632,11 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
622
632
|
isCollection: true
|
|
623
633
|
}]
|
|
624
634
|
};
|
|
625
|
-
|
|
635
|
+
const CUSTOM_ARGS = {
|
|
636
|
+
...ARGS,
|
|
626
637
|
formState: FORM_STATE,
|
|
627
638
|
action: ACTION
|
|
628
|
-
}
|
|
639
|
+
};
|
|
629
640
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
630
641
|
preActionChecks();
|
|
631
642
|
// Not doing the usual post-action checks here
|
|
@@ -636,15 +647,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
636
647
|
});
|
|
637
648
|
expect(FORM_STATE.page.formData.parent[0].child[0].id).toEqual('12345');
|
|
638
649
|
});
|
|
639
|
-
it('should work for an array of formData',
|
|
640
|
-
|
|
650
|
+
it('should work for an array of formData', () => {
|
|
651
|
+
const FORM_STATE = {
|
|
641
652
|
page: {
|
|
642
653
|
formData: {
|
|
643
654
|
testCollection: []
|
|
644
655
|
}
|
|
645
656
|
}
|
|
646
657
|
};
|
|
647
|
-
|
|
658
|
+
const ACTION = {
|
|
648
659
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
649
660
|
collection: 'testCollection',
|
|
650
661
|
addToFormData: [{
|
|
@@ -655,10 +666,11 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
655
666
|
value: '456'
|
|
656
667
|
}]
|
|
657
668
|
};
|
|
658
|
-
|
|
669
|
+
const CUSTOM_ARGS = {
|
|
670
|
+
...ARGS,
|
|
659
671
|
formState: FORM_STATE,
|
|
660
672
|
action: ACTION
|
|
661
|
-
}
|
|
673
|
+
};
|
|
662
674
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
663
675
|
preActionChecks();
|
|
664
676
|
// Not doing the usual post-action checks here
|
|
@@ -672,34 +684,37 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
672
684
|
});
|
|
673
685
|
});
|
|
674
686
|
});
|
|
675
|
-
describe('recording patchLabel fields correctly when it is defined',
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
it("should work for the ".concat(actionType, " action type"), function () {
|
|
681
|
-
var FORM_STATE = {
|
|
687
|
+
describe('recording patchLabel fields correctly when it is defined', () => {
|
|
688
|
+
const VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(a => a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE);
|
|
689
|
+
VALID_ACTIONS.forEach(actionType => {
|
|
690
|
+
it(`should work for the ${actionType} action type`, () => {
|
|
691
|
+
const FORM_STATE = {
|
|
682
692
|
page: {
|
|
683
693
|
formData: {
|
|
684
694
|
testCollection: []
|
|
685
695
|
}
|
|
686
696
|
}
|
|
687
697
|
};
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
698
|
+
const KEY = 'testField';
|
|
699
|
+
const VALUE = 'testValue';
|
|
700
|
+
const PATCH_LABEL = {
|
|
701
|
+
[KEY]: VALUE
|
|
702
|
+
};
|
|
703
|
+
const PATCH = {
|
|
704
|
+
[KEY]: VALUE
|
|
705
|
+
};
|
|
706
|
+
const ACTION = {
|
|
693
707
|
type: actionType,
|
|
694
708
|
collection: 'testCollection'
|
|
695
709
|
};
|
|
696
|
-
|
|
710
|
+
const CUSTOM_ARGS = {
|
|
711
|
+
...ARGS,
|
|
697
712
|
action: ACTION,
|
|
698
713
|
formState: FORM_STATE,
|
|
699
714
|
patch: PATCH,
|
|
700
715
|
patchLabel: PATCH_LABEL,
|
|
701
716
|
type: _models.FormTypes.HUB
|
|
702
|
-
}
|
|
717
|
+
};
|
|
703
718
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
704
719
|
preActionChecks();
|
|
705
720
|
postActionChecks(CUSTOM_ARGS); // Specific check for patchLabel done in here.
|