@ukhomeoffice/cop-react-form-renderer 6.13.2 → 6.14.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/README.md +8 -0
- package/dist/components/CheckYourAnswers/Answer.js +12 -11
- package/dist/components/CheckYourAnswers/Answer.test.js +132 -181
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +98 -133
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +544 -939
- package/dist/components/CheckYourAnswers/index.js +1 -1
- package/dist/components/CollectionPage/CollectionPage.js +62 -60
- package/dist/components/CollectionPage/CollectionPage.test.js +315 -365
- package/dist/components/CollectionPage/index.js +1 -1
- package/dist/components/CollectionSummary/BannerStrip.js +14 -14
- package/dist/components/CollectionSummary/BannerStrip.test.js +79 -74
- package/dist/components/CollectionSummary/CollectionSummary.js +81 -99
- package/dist/components/CollectionSummary/CollectionSummary.test.js +182 -166
- package/dist/components/CollectionSummary/Confirmation.js +15 -13
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +47 -48
- package/dist/components/CollectionSummary/RenderListView.scss +4 -0
- package/dist/components/CollectionSummary/RenderListView.test.js +133 -98
- package/dist/components/CollectionSummary/SummaryCard.js +110 -148
- package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
- package/dist/components/CollectionSummary/SummaryCardButtons.js +71 -0
- package/dist/components/CollectionSummary/SummaryCardButtons.test.js +85 -0
- package/dist/components/CollectionSummary/SummaryCardDetails.js +59 -76
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +170 -180
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +63 -75
- package/dist/components/CollectionSummary/index.js +1 -1
- package/dist/components/FormComponent/Collection.js +67 -102
- package/dist/components/FormComponent/Collection.test.js +907 -1080
- package/dist/components/FormComponent/Container.js +35 -29
- package/dist/components/FormComponent/Container.test.js +378 -409
- package/dist/components/FormComponent/FormComponent.js +59 -63
- 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 +99 -88
- package/dist/components/FormPage/FormPage.test.js +173 -164
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +138 -174
- package/dist/components/FormRenderer/FormRenderer.test.js +732 -1114
- 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 +22 -25
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
- package/dist/components/FormRenderer/helpers/getCYA.js +4 -6
- 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 +14 -25
- 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 +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +6 -6
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +104 -98
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +44 -51
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +68 -74
- package/dist/components/FormRenderer/helpers/index.js +2 -2
- package/dist/components/FormRenderer/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +43 -44
- package/dist/components/FormRenderer/onCYAAction.test.js +126 -133
- package/dist/components/FormRenderer/onPageAction.js +26 -35
- package/dist/components/FormRenderer/onPageAction.test.js +177 -186
- package/dist/components/FormRenderer/onTaskAction.js +11 -12
- package/dist/components/FormRenderer/onTaskAction.test.js +63 -68
- package/dist/components/PageActions/ActionButton.js +14 -14
- 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 +10 -18
- package/dist/components/SummaryList/GroupAction.test.js +38 -34
- package/dist/components/SummaryList/RowAction.js +12 -17
- package/dist/components/SummaryList/RowAction.test.js +38 -34
- package/dist/components/SummaryList/SummaryList.js +23 -25
- package/dist/components/SummaryList/SummaryList.test.js +162 -189
- package/dist/components/SummaryList/SummaryListHeadingRow.js +7 -5
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
- package/dist/components/SummaryList/SummaryListRow.js +7 -5
- package/dist/components/SummaryList/SummaryListTitleRow.js +6 -4
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +23 -23
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +23 -23
- 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 +56 -79
- package/dist/components/TaskList/TaskList.test.js +149 -149
- package/dist/components/TaskList/TaskState.js +8 -6
- package/dist/components/TaskList/TaskState.test.js +53 -46
- package/dist/components/TaskList/index.js +1 -1
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +56 -79
- 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 +57 -69
- 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 +25 -37
- 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 +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +12 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +32 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +15 -28
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +41 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +7 -7
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +27 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +48 -52
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +79 -93
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -14
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +146 -98
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +14 -19
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +69 -73
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +7 -8
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +15 -16
- package/dist/utils/CheckYourAnswers/index.js +2 -2
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +5 -5
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -19
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +48 -39
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
- package/dist/utils/CollectionPage/getErrorsForCollection.js +20 -21
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
- package/dist/utils/CollectionPage/getQuickEditPage.js +22 -23
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +17 -18
- package/dist/utils/CollectionPage/index.js +2 -2
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +18 -18
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
- package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +25 -25
- package/dist/utils/Component/addShowWhen.js +5 -6
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +12 -15
- package/dist/utils/Component/applyToComponentTree.test.js +28 -31
- package/dist/utils/Component/cleanAttributes.js +12 -11
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +6 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
- package/dist/utils/Component/getComponent.js +81 -83
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +41 -58
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +24 -34
- 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 +21 -26
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +11 -10
- 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 +201 -174
- 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 +32 -39
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +21 -30
- 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 +16 -20
- 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 +23 -28
- package/dist/utils/Component/setupContainerComponentsPath.test.js +12 -12
- package/dist/utils/Component/showComponent.js +2 -2
- 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 +17 -26
- 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 +12 -15
- 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 +14 -15
- package/dist/utils/Container/setupNesting.test.js +20 -23
- package/dist/utils/Container/showContainer.js +4 -8
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +30 -44
- package/dist/utils/Data/applyFormula.test.js +21 -21
- package/dist/utils/Data/deleteValues.js +4 -8
- package/dist/utils/Data/deleteValues.test.js +11 -11
- package/dist/utils/Data/getAutocompleteSource.js +19 -27
- package/dist/utils/Data/getAutocompleteSource.test.js +76 -81
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +13 -13
- package/dist/utils/Data/getOptions.js +57 -30
- package/dist/utils/Data/getOptions.test.js +75 -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 -12
- package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
- package/dist/utils/Data/refDataToOptions.js +9 -10
- 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 +13 -20
- package/dist/utils/Data/setupFormData.test.js +48 -47
- package/dist/utils/Data/setupRefDataUrlForComponent.js +11 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +25 -25
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -8
- package/dist/utils/FormPage/applyConditionalProperties.test.js +14 -15
- package/dist/utils/FormPage/getConditionalText.js +4 -4
- package/dist/utils/FormPage/getConditionalText.test.js +30 -30
- package/dist/utils/FormPage/getFormPage.js +16 -12
- package/dist/utils/FormPage/getFormPage.test.js +23 -24
- package/dist/utils/FormPage/getFormPages.js +8 -11
- package/dist/utils/FormPage/getFormPages.test.js +15 -16
- package/dist/utils/FormPage/getPageActions.js +10 -13
- 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 +2 -2
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +25 -22
- package/dist/utils/FormPage/useComponent.test.js +79 -44
- 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 +5 -6
- 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 +23 -24
- package/dist/utils/Hub/index.js +2 -2
- 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 +25 -17
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +12 -13
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +70 -33
- package/dist/utils/Meta/index.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.js +3 -3
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/deleteValueInFormData.js +2 -2
- package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
- package/dist/utils/Operate/getFirstOf.js +6 -6
- package/dist/utils/Operate/getFirstOf.test.js +32 -32
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +11 -11
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/getLength.js +9 -9
- package/dist/utils/Operate/getLength.test.js +19 -19
- package/dist/utils/Operate/index.js +2 -2
- package/dist/utils/Operate/persistValueInFormData.js +4 -4
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +8 -8
- package/dist/utils/Operate/runPageOperations.test.js +24 -25
- package/dist/utils/Operate/setValueInFormData.js +3 -3
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +7 -7
- package/dist/utils/Operate/shouldRun.test.js +22 -24
- package/dist/utils/Validate/additional/conditionallyPermittedChange.js +1 -1
- package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +15 -15
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -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 +8 -12
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -38
- 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 +3 -3
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +4 -4
- 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 +35 -36
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- 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 +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +2 -2
- package/dist/utils/Validate/validateCollection.js +18 -23
- package/dist/utils/Validate/validateCollection.test.js +75 -67
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +179 -154
- package/dist/utils/Validate/validateContainer.js +14 -17
- package/dist/utils/Validate/validateContainer.test.js +59 -53
- package/dist/utils/Validate/validateDate.js +16 -22
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +8 -9
- package/dist/utils/Validate/validateEmail.test.js +29 -26
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +13 -18
- package/dist/utils/Validate/validatePage.test.js +198 -195
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +15 -15
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +4 -6
- 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 +5 -6
- package/package.json +5 -5
|
@@ -8,18 +8,17 @@ var _models = require("../../models");
|
|
|
8
8
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
9
9
|
var _handlers = _interopRequireDefault(require("./handlers"));
|
|
10
10
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
11
|
-
function _interopRequireDefault(
|
|
12
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
-
function _defineProperty(
|
|
16
|
-
function _toPropertyKey(
|
|
17
|
-
function _toPrimitive(
|
|
14
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Local imports.
|
|
18
17
|
/**
|
|
19
18
|
*
|
|
20
19
|
* @param {*} action
|
|
21
20
|
*/
|
|
22
|
-
|
|
21
|
+
const onCYAAction = (setPagePoint, action, pages, validate, components, data, setData, type, pageId, currentTask, hooks, addErrors, hub, onPageChange, formState, submitting, setSubmitting) => {
|
|
23
22
|
// Check to see whether the action is able to proceed, which in
|
|
24
23
|
// in the case of a submission will validate the fields in the page.
|
|
25
24
|
if (action.type === _models.PageAction.TYPES.SUBMIT && hub !== _models.HubFormats.TASK) {
|
|
@@ -27,36 +26,36 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
27
26
|
if (_helpers.default.canCYASubmit(pages, validate.pages) && !submitting) {
|
|
28
27
|
setSubmitting(true);
|
|
29
28
|
// Submit.
|
|
30
|
-
|
|
31
|
-
pages
|
|
32
|
-
components
|
|
29
|
+
const submissionData = _utils.default.Format.form({
|
|
30
|
+
pages,
|
|
31
|
+
components
|
|
33
32
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
34
33
|
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
35
34
|
setData(submissionData);
|
|
36
35
|
// Now submit the data to the backend...
|
|
37
|
-
hooks.onSubmit(action.type, submissionData,
|
|
36
|
+
hooks.onSubmit(action.type, submissionData, () => {
|
|
38
37
|
hooks.onFormComplete();
|
|
39
38
|
setSubmitting(false);
|
|
40
|
-
},
|
|
39
|
+
}, errors => {
|
|
41
40
|
setSubmitting(false);
|
|
42
41
|
_handlers.default.submissionError(errors, addErrors);
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
44
|
} else {
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const shouldValidate = !(Object.prototype.hasOwnProperty.call(action, 'validate') && !action.validate);
|
|
46
|
+
const canSubmit = shouldValidate ? _helpers.default.canCYASubmit(currentTask.fullPages, validate.pages) : true;
|
|
48
47
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_CONTINUE && hub === _models.HubFormats.TASK) {
|
|
49
48
|
if (canSubmit) {
|
|
50
|
-
|
|
51
|
-
pages
|
|
52
|
-
components
|
|
49
|
+
const submissionData = _utils.default.Format.form({
|
|
50
|
+
pages,
|
|
51
|
+
components
|
|
53
52
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
54
|
-
|
|
55
|
-
setData(
|
|
56
|
-
hooks.onSubmit(action.type,
|
|
53
|
+
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
54
|
+
setData(submissionData);
|
|
55
|
+
hooks.onSubmit(action.type, submissionData, () => {
|
|
57
56
|
setSubmitting(false);
|
|
58
57
|
onPageChange(_models.FormPages.HUB);
|
|
59
|
-
},
|
|
58
|
+
}, errors => {
|
|
60
59
|
setSubmitting(false);
|
|
61
60
|
_handlers.default.submissionError(errors, addErrors);
|
|
62
61
|
});
|
|
@@ -66,17 +65,17 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
66
65
|
setPagePoint('submit');
|
|
67
66
|
if (canSubmit) {
|
|
68
67
|
// Submit.
|
|
69
|
-
|
|
70
|
-
pages
|
|
71
|
-
components
|
|
68
|
+
const submissionData = _utils.default.Format.form({
|
|
69
|
+
pages,
|
|
70
|
+
components
|
|
72
71
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
73
|
-
|
|
74
|
-
setData(
|
|
72
|
+
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
73
|
+
setData(submissionData);
|
|
75
74
|
// Now submit the data to the backend...
|
|
76
|
-
hooks.onSubmit(action.type,
|
|
75
|
+
hooks.onSubmit(action.type, submissionData, () => {
|
|
77
76
|
hooks.onFormComplete();
|
|
78
77
|
setSubmitting(false);
|
|
79
|
-
},
|
|
78
|
+
}, errors => {
|
|
80
79
|
setSubmitting(false);
|
|
81
80
|
_handlers.default.submissionError(errors, addErrors);
|
|
82
81
|
});
|
|
@@ -84,16 +83,16 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
84
83
|
}
|
|
85
84
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_NAVIGATE) {
|
|
86
85
|
if (canSubmit) {
|
|
87
|
-
|
|
88
|
-
pages
|
|
89
|
-
components
|
|
86
|
+
const submissionData = _utils.default.Format.form({
|
|
87
|
+
pages,
|
|
88
|
+
components
|
|
90
89
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
91
|
-
|
|
92
|
-
setData(
|
|
93
|
-
hooks.onSubmit(action.type,
|
|
90
|
+
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
91
|
+
setData(submissionData);
|
|
92
|
+
hooks.onSubmit(action.type, submissionData, () => {
|
|
94
93
|
setSubmitting(false);
|
|
95
94
|
onPageChange(action.page);
|
|
96
|
-
},
|
|
95
|
+
}, errors => {
|
|
97
96
|
setSubmitting(false);
|
|
98
97
|
_handlers.default.submissionError(errors, addErrors);
|
|
99
98
|
});
|
|
@@ -101,20 +100,20 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
101
100
|
}
|
|
102
101
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_RETURN) {
|
|
103
102
|
if (canSubmit) {
|
|
104
|
-
|
|
105
|
-
pages
|
|
106
|
-
components
|
|
103
|
+
const submissionData = _utils.default.Format.form({
|
|
104
|
+
pages,
|
|
105
|
+
components
|
|
107
106
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
108
|
-
|
|
109
|
-
setData(
|
|
110
|
-
hooks.onSubmit(action.type,
|
|
107
|
+
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, false);
|
|
108
|
+
setData(submissionData);
|
|
109
|
+
hooks.onSubmit(action.type, submissionData, () => {
|
|
111
110
|
if (type === _models.FormTypes.TASK) {
|
|
112
111
|
onPageChange(undefined);
|
|
113
112
|
} else {
|
|
114
113
|
onPageChange(_models.FormPages.HUB);
|
|
115
114
|
}
|
|
116
115
|
setSubmitting(false);
|
|
117
|
-
},
|
|
116
|
+
}, errors => {
|
|
118
117
|
setSubmitting(false);
|
|
119
118
|
_handlers.default.submissionError(errors, addErrors);
|
|
120
119
|
});
|
|
@@ -126,9 +125,9 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
126
125
|
setSubmitting(false);
|
|
127
126
|
}
|
|
128
127
|
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
129
|
-
|
|
130
|
-
pages
|
|
131
|
-
components
|
|
128
|
+
const formData = _utils.default.Format.form({
|
|
129
|
+
pages,
|
|
130
|
+
components
|
|
132
131
|
}, _objectSpread({}, data), _models.EventTypes.CANCEL);
|
|
133
132
|
hooks.onCancel(formData);
|
|
134
133
|
setSubmitting(false);
|
|
@@ -5,88 +5,81 @@ var _utils = _interopRequireDefault(require("../../utils"));
|
|
|
5
5
|
var _handlers = _interopRequireDefault(require("./handlers"));
|
|
6
6
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
7
7
|
var _onCYAAction = _interopRequireDefault(require("./onCYAAction"));
|
|
8
|
-
function _interopRequireDefault(
|
|
9
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
function _defineProperty(
|
|
13
|
-
function _toPropertyKey(
|
|
14
|
-
function _toPrimitive(
|
|
15
|
-
jest.mock('./handlers',
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
addErrors(errors);
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
reset: function reset() {
|
|
27
|
-
this.submissionErrorCalls = 0;
|
|
28
|
-
this.submissionErrorArgs = [];
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
jest.mock('./helpers', function () {
|
|
33
|
-
return {
|
|
34
|
-
canCYASubmitResult: true,
|
|
35
|
-
canCYASubmitCalls: 0,
|
|
36
|
-
canCYASubmit: function canCYASubmit() {
|
|
37
|
-
this.canCYASubmitCalls += 1;
|
|
38
|
-
return this.canCYASubmitResult;
|
|
39
|
-
},
|
|
40
|
-
getNextPageIdCalls: 0,
|
|
41
|
-
getNextPageId: function getNextPageId() {
|
|
42
|
-
this.getNextPageIdCalls += 1;
|
|
43
|
-
return 'page2';
|
|
44
|
-
},
|
|
45
|
-
getFormStateCalls: 0,
|
|
46
|
-
getFormState: function getFormState() {
|
|
47
|
-
this.getFormStateCalls += 1;
|
|
48
|
-
return {};
|
|
49
|
-
},
|
|
50
|
-
getSubmissionStatusCalls: 0,
|
|
51
|
-
getSubmissionStatus: function getSubmissionStatus() {
|
|
52
|
-
this.getSubmissionStatusCalls += 1;
|
|
53
|
-
return 'Good to go!';
|
|
54
|
-
},
|
|
55
|
-
reset: function reset() {
|
|
56
|
-
this.canCYASubmitCalls = 0;
|
|
57
|
-
this.canCYASubmitResult = true;
|
|
58
|
-
this.getFormStateCalls = 0;
|
|
59
|
-
this.getNextPageIdCalls = 0;
|
|
60
|
-
this.getFormStateCalls = 0;
|
|
61
|
-
this.getSubmissionStatusCalls = 0;
|
|
11
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
jest.mock('./handlers', () => ({
|
|
15
|
+
submissionErrorCalls: 0,
|
|
16
|
+
submissionErrorArgs: [],
|
|
17
|
+
submissionError(errors, addErrors) {
|
|
18
|
+
this.submissionErrorCalls += 1;
|
|
19
|
+
this.submissionErrorArgs.push(errors);
|
|
20
|
+
if (typeof addErrors === 'function') {
|
|
21
|
+
addErrors(errors);
|
|
62
22
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
23
|
+
},
|
|
24
|
+
reset() {
|
|
25
|
+
this.submissionErrorCalls = 0;
|
|
26
|
+
this.submissionErrorArgs = [];
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
jest.mock('./helpers', () => ({
|
|
30
|
+
canCYASubmitResult: true,
|
|
31
|
+
canCYASubmitCalls: 0,
|
|
32
|
+
canCYASubmit() {
|
|
33
|
+
this.canCYASubmitCalls += 1;
|
|
34
|
+
return this.canCYASubmitResult;
|
|
35
|
+
},
|
|
36
|
+
getNextPageIdCalls: 0,
|
|
37
|
+
getNextPageId() {
|
|
38
|
+
this.getNextPageIdCalls += 1;
|
|
39
|
+
return 'page2';
|
|
40
|
+
},
|
|
41
|
+
getFormStateCalls: 0,
|
|
42
|
+
getFormState() {
|
|
43
|
+
this.getFormStateCalls += 1;
|
|
44
|
+
return {};
|
|
45
|
+
},
|
|
46
|
+
getSubmissionStatusCalls: 0,
|
|
47
|
+
getSubmissionStatus() {
|
|
48
|
+
this.getSubmissionStatusCalls += 1;
|
|
49
|
+
return 'Good to go!';
|
|
50
|
+
},
|
|
51
|
+
reset() {
|
|
52
|
+
this.canCYASubmitCalls = 0;
|
|
53
|
+
this.canCYASubmitResult = true;
|
|
54
|
+
this.getFormStateCalls = 0;
|
|
55
|
+
this.getNextPageIdCalls = 0;
|
|
56
|
+
this.getFormStateCalls = 0;
|
|
57
|
+
this.getSubmissionStatusCalls = 0;
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
jest.mock('../../utils', () => ({
|
|
61
|
+
Format: {
|
|
62
|
+
formCalls: 0,
|
|
63
|
+
form() {
|
|
64
|
+
this.formCalls += 1;
|
|
65
|
+
return {
|
|
66
|
+
id: 'formId'
|
|
67
|
+
};
|
|
78
68
|
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
},
|
|
70
|
+
reset() {
|
|
71
|
+
this.Format.formCalls = 0;
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
describe('components.FormRenderer.onCYAAction', () => {
|
|
75
|
+
const MOCK_HOOKS = {
|
|
83
76
|
onSubmitCalls: 0,
|
|
84
77
|
onSubmitArgs: [],
|
|
85
|
-
onSubmit
|
|
78
|
+
onSubmit(type, payload, onSuccess, onError) {
|
|
86
79
|
this.onSubmitCalls += 1;
|
|
87
80
|
this.onSubmitArgs.push({
|
|
88
|
-
type
|
|
89
|
-
payload
|
|
81
|
+
type,
|
|
82
|
+
payload
|
|
90
83
|
});
|
|
91
84
|
if (typeof onSuccess === 'function') {
|
|
92
85
|
onSuccess();
|
|
@@ -99,49 +92,49 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
99
92
|
}
|
|
100
93
|
},
|
|
101
94
|
onFormCompleteCalls: 0,
|
|
102
|
-
onFormComplete
|
|
95
|
+
onFormComplete() {
|
|
103
96
|
this.onFormCompleteCalls += 1;
|
|
104
97
|
},
|
|
105
98
|
onCancelArgs: [],
|
|
106
|
-
onCancel
|
|
99
|
+
onCancel(data) {
|
|
107
100
|
this.onCancelArgs.push(data);
|
|
108
101
|
},
|
|
109
|
-
reset
|
|
102
|
+
reset() {
|
|
110
103
|
this.onSubmitCalls = 0;
|
|
111
104
|
this.onSubmitArgs = [];
|
|
112
105
|
this.onFormCompleteCalls = 0;
|
|
113
106
|
this.onCancelArgs = [];
|
|
114
107
|
}
|
|
115
108
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
109
|
+
let setPagePointCalls = 0;
|
|
110
|
+
let setPagePointArgs = [];
|
|
111
|
+
const mockSetPagePoint = point => {
|
|
119
112
|
setPagePointCalls += 1;
|
|
120
113
|
setPagePointArgs.push(point);
|
|
121
114
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
let setDataCalls = 0;
|
|
116
|
+
let setDataArgs = [];
|
|
117
|
+
const mockSetData = data => {
|
|
125
118
|
setDataCalls += 1;
|
|
126
119
|
setDataArgs.push(data);
|
|
127
120
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
let onPageChangeCalls = 0;
|
|
122
|
+
let onPageChangeArgs = [];
|
|
123
|
+
const mockOnPageChange = pageId => {
|
|
131
124
|
onPageChangeCalls += 1;
|
|
132
125
|
onPageChangeArgs.push(pageId);
|
|
133
126
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
let addErrorsCalls = 0;
|
|
128
|
+
let addErrorsArgs = [];
|
|
129
|
+
const mockAddErrors = errors => {
|
|
137
130
|
addErrorsCalls += 1;
|
|
138
131
|
addErrorsArgs.push(errors);
|
|
139
132
|
};
|
|
140
|
-
|
|
141
|
-
|
|
133
|
+
let mockSubmitting = false;
|
|
134
|
+
const mockSetSubmitting = submitting => {
|
|
142
135
|
mockSubmitting = submitting;
|
|
143
136
|
};
|
|
144
|
-
|
|
137
|
+
const COMPONENTS = [{
|
|
145
138
|
id: 'alpha',
|
|
146
139
|
fieldId: 'alpha'
|
|
147
140
|
}, {
|
|
@@ -154,24 +147,24 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
154
147
|
id: 'delta',
|
|
155
148
|
fieldId: 'delta'
|
|
156
149
|
}];
|
|
157
|
-
|
|
150
|
+
const PAGES = [{
|
|
158
151
|
id: 'page1',
|
|
159
152
|
components: [_objectSpread({}, COMPONENTS[0]), _objectSpread({}, COMPONENTS[1])]
|
|
160
153
|
}, {
|
|
161
154
|
id: 'page2',
|
|
162
155
|
components: [_objectSpread({}, COMPONENTS[2]), _objectSpread({}, COMPONENTS[3])]
|
|
163
156
|
}];
|
|
164
|
-
|
|
157
|
+
const CURRENT_TASK = {
|
|
165
158
|
name: 'testTask',
|
|
166
159
|
fullPages: PAGES
|
|
167
160
|
};
|
|
168
|
-
|
|
161
|
+
const ARGS = {
|
|
169
162
|
setPagePoint: mockSetPagePoint,
|
|
170
163
|
action: {
|
|
171
164
|
type: _models.PageAction.TYPES.SUBMIT
|
|
172
165
|
},
|
|
173
166
|
pages: PAGES,
|
|
174
|
-
validate:
|
|
167
|
+
validate: () => {},
|
|
175
168
|
components: COMPONENTS,
|
|
176
169
|
data: {},
|
|
177
170
|
setData: mockSetData,
|
|
@@ -186,7 +179,7 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
186
179
|
submitting: mockSubmitting,
|
|
187
180
|
setSubmitting: mockSetSubmitting
|
|
188
181
|
};
|
|
189
|
-
beforeEach(
|
|
182
|
+
beforeEach(() => {
|
|
190
183
|
_handlers.default.reset();
|
|
191
184
|
_helpers.default.reset();
|
|
192
185
|
_utils.default.reset();
|
|
@@ -201,9 +194,9 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
201
194
|
addErrorsArgs = [];
|
|
202
195
|
mockSetSubmitting(false);
|
|
203
196
|
});
|
|
204
|
-
describe('with a page action of PageAction.TYPES.SUBMIT',
|
|
205
|
-
it('should handle a hub format of HubFormats.CYA',
|
|
206
|
-
|
|
197
|
+
describe('with a page action of PageAction.TYPES.SUBMIT', () => {
|
|
198
|
+
it('should handle a hub format of HubFormats.CYA', () => {
|
|
199
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
207
200
|
hub: _models.HubFormats.CYA
|
|
208
201
|
});
|
|
209
202
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
@@ -235,8 +228,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
235
228
|
expect(addErrorsCalls).toEqual(1);
|
|
236
229
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
237
230
|
});
|
|
238
|
-
it('should handle a hub format of HubFormats.TASK',
|
|
239
|
-
|
|
231
|
+
it('should handle a hub format of HubFormats.TASK', () => {
|
|
232
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
240
233
|
hub: _models.HubFormats.TASK
|
|
241
234
|
});
|
|
242
235
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
@@ -268,8 +261,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
268
261
|
expect(addErrorsCalls).toEqual(1);
|
|
269
262
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
270
263
|
});
|
|
271
|
-
it('should handle no hub',
|
|
272
|
-
|
|
264
|
+
it('should handle no hub', () => {
|
|
265
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
273
266
|
hub: null
|
|
274
267
|
});
|
|
275
268
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
@@ -301,8 +294,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
301
294
|
expect(addErrorsCalls).toEqual(1);
|
|
302
295
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
303
296
|
});
|
|
304
|
-
it('should not validate if action.validate is false and hub is HubFormats.TASK',
|
|
305
|
-
|
|
297
|
+
it('should not validate if action.validate is false and hub is HubFormats.TASK', () => {
|
|
298
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
306
299
|
action: {
|
|
307
300
|
type: _models.PageAction.TYPES.SUBMIT,
|
|
308
301
|
validate: false
|
|
@@ -333,9 +326,9 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
333
326
|
});
|
|
334
327
|
});
|
|
335
328
|
});
|
|
336
|
-
describe('with a page action of PageAction.TYPES.SAVE_AND_CONTINUE',
|
|
337
|
-
it('should validate if action.validate is not defined',
|
|
338
|
-
|
|
329
|
+
describe('with a page action of PageAction.TYPES.SAVE_AND_CONTINUE', () => {
|
|
330
|
+
it('should validate if action.validate is not defined', () => {
|
|
331
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
339
332
|
action: {
|
|
340
333
|
type: _models.PageAction.TYPES.SAVE_AND_CONTINUE
|
|
341
334
|
},
|
|
@@ -369,8 +362,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
369
362
|
expect(addErrorsCalls).toEqual(1);
|
|
370
363
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
371
364
|
});
|
|
372
|
-
it('should validate if action.validate is true',
|
|
373
|
-
|
|
365
|
+
it('should validate if action.validate is true', () => {
|
|
366
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
374
367
|
action: {
|
|
375
368
|
type: _models.PageAction.TYPES.SAVE_AND_CONTINUE,
|
|
376
369
|
validate: true
|
|
@@ -405,8 +398,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
405
398
|
expect(addErrorsCalls).toEqual(1);
|
|
406
399
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
407
400
|
});
|
|
408
|
-
it('should not validate if action.validate is false',
|
|
409
|
-
|
|
401
|
+
it('should not validate if action.validate is false', () => {
|
|
402
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
410
403
|
action: {
|
|
411
404
|
type: _models.PageAction.TYPES.SAVE_AND_CONTINUE,
|
|
412
405
|
validate: false
|
|
@@ -447,9 +440,9 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
447
440
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
448
441
|
});
|
|
449
442
|
});
|
|
450
|
-
describe('with a page action of PageAction.TYPES.SAVE_AND_NAVIGATE',
|
|
451
|
-
it('should validate if action.validate is not defined',
|
|
452
|
-
|
|
443
|
+
describe('with a page action of PageAction.TYPES.SAVE_AND_NAVIGATE', () => {
|
|
444
|
+
it('should validate if action.validate is not defined', () => {
|
|
445
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
453
446
|
action: {
|
|
454
447
|
type: _models.PageAction.TYPES.SAVE_AND_NAVIGATE,
|
|
455
448
|
page: 'testPage'
|
|
@@ -484,8 +477,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
484
477
|
expect(addErrorsCalls).toEqual(1);
|
|
485
478
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
486
479
|
});
|
|
487
|
-
it('should validate if action.validate is true',
|
|
488
|
-
|
|
480
|
+
it('should validate if action.validate is true', () => {
|
|
481
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
489
482
|
action: {
|
|
490
483
|
type: _models.PageAction.TYPES.SAVE_AND_NAVIGATE,
|
|
491
484
|
page: 'testPage',
|
|
@@ -521,8 +514,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
521
514
|
expect(addErrorsCalls).toEqual(1);
|
|
522
515
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
523
516
|
});
|
|
524
|
-
it('should not validate if action.validate is false',
|
|
525
|
-
|
|
517
|
+
it('should not validate if action.validate is false', () => {
|
|
518
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
526
519
|
action: {
|
|
527
520
|
type: _models.PageAction.TYPES.SAVE_AND_NAVIGATE,
|
|
528
521
|
page: 'testPage',
|
|
@@ -564,9 +557,9 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
564
557
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
565
558
|
});
|
|
566
559
|
});
|
|
567
|
-
describe('with an action type of PageAction.TYPES.SAVE_AND_RETURN',
|
|
568
|
-
it('should validate if action.validate is not defined',
|
|
569
|
-
|
|
560
|
+
describe('with an action type of PageAction.TYPES.SAVE_AND_RETURN', () => {
|
|
561
|
+
it('should validate if action.validate is not defined', () => {
|
|
562
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
570
563
|
action: {
|
|
571
564
|
type: _models.PageAction.TYPES.SAVE_AND_RETURN
|
|
572
565
|
},
|
|
@@ -600,8 +593,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
600
593
|
expect(addErrorsCalls).toEqual(1);
|
|
601
594
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
602
595
|
});
|
|
603
|
-
it('should validate if action.validate is true',
|
|
604
|
-
|
|
596
|
+
it('should validate if action.validate is true', () => {
|
|
597
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
605
598
|
action: {
|
|
606
599
|
type: _models.PageAction.TYPES.SAVE_AND_RETURN,
|
|
607
600
|
validate: true
|
|
@@ -636,8 +629,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
636
629
|
expect(addErrorsCalls).toEqual(1);
|
|
637
630
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
638
631
|
});
|
|
639
|
-
it('should not validate if action.validate is false',
|
|
640
|
-
|
|
632
|
+
it('should not validate if action.validate is false', () => {
|
|
633
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
641
634
|
action: {
|
|
642
635
|
type: _models.PageAction.TYPES.SAVE_AND_RETURN,
|
|
643
636
|
validate: false
|
|
@@ -677,8 +670,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
677
670
|
expect(addErrorsCalls).toEqual(1);
|
|
678
671
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
679
672
|
});
|
|
680
|
-
it('should call onPageChange with undefined if type is FormTypes.TASK',
|
|
681
|
-
|
|
673
|
+
it('should call onPageChange with undefined if type is FormTypes.TASK', () => {
|
|
674
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
682
675
|
action: {
|
|
683
676
|
type: _models.PageAction.TYPES.SAVE_AND_RETURN,
|
|
684
677
|
validate: true
|
|
@@ -715,8 +708,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
715
708
|
expect(addErrorsArgs[0]).toEqual(['an example error']);
|
|
716
709
|
});
|
|
717
710
|
});
|
|
718
|
-
it('should handle a page action type of PageAction.TYPES.NAVIGATE',
|
|
719
|
-
|
|
711
|
+
it('should handle a page action type of PageAction.TYPES.NAVIGATE', () => {
|
|
712
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
720
713
|
action: {
|
|
721
714
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
722
715
|
page: 'page2'
|
|
@@ -726,8 +719,8 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
726
719
|
expect(onPageChangeCalls).toEqual(1);
|
|
727
720
|
expect(onPageChangeArgs[0]).toEqual('page2');
|
|
728
721
|
});
|
|
729
|
-
it('should handle a page action type of PageAction.TYPES.CANCEL',
|
|
730
|
-
|
|
722
|
+
it('should handle a page action type of PageAction.TYPES.CANCEL', () => {
|
|
723
|
+
const CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
731
724
|
action: {
|
|
732
725
|
type: _models.PageAction.TYPES.CANCEL
|
|
733
726
|
}
|