@ukhomeoffice/cop-react-form-renderer 5.90.1 → 5.90.2
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 +181 -132
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +142 -106
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +941 -563
- package/dist/components/CheckYourAnswers/index.js +1 -1
- package/dist/components/CollectionPage/CollectionPage.js +66 -75
- package/dist/components/CollectionPage/CollectionPage.test.js +369 -318
- package/dist/components/CollectionPage/index.js +1 -1
- package/dist/components/CollectionSummary/BannerStrip.js +15 -15
- package/dist/components/CollectionSummary/BannerStrip.test.js +79 -83
- package/dist/components/CollectionSummary/CollectionSummary.js +131 -109
- package/dist/components/CollectionSummary/CollectionSummary.test.js +180 -198
- package/dist/components/CollectionSummary/Confirmation.js +13 -15
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/RenderListView.js +55 -47
- package/dist/components/CollectionSummary/RenderListView.test.js +81 -82
- package/dist/components/CollectionSummary/SummaryCard.js +157 -121
- package/dist/components/CollectionSummary/SummaryCard.test.js +1000 -970
- package/dist/components/CollectionSummary/SummaryCardDetails.js +94 -103
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +195 -187
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +36 -31
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +76 -64
- package/dist/components/CollectionSummary/index.js +1 -1
- package/dist/components/FormComponent/Collection.js +117 -80
- package/dist/components/FormComponent/Collection.test.js +1082 -910
- package/dist/components/FormComponent/Container.js +38 -43
- package/dist/components/FormComponent/Container.test.js +411 -379
- package/dist/components/FormComponent/FormComponent.js +74 -71
- package/dist/components/FormComponent/FormComponent.test.js +415 -354
- package/dist/components/FormComponent/helpers/addLabel.js +7 -4
- 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 +5 -3
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +4 -3
- 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 +87 -71
- package/dist/components/FormPage/FormPage.test.js +170 -133
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +198 -153
- package/dist/components/FormRenderer/FormRenderer.test.js +1116 -731
- package/dist/components/FormRenderer/handlers/cyaAction.js +3 -3
- package/dist/components/FormRenderer/handlers/getPageId.js +3 -1
- 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 +3 -1
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +21 -17
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +30 -27
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
- package/dist/components/FormRenderer/helpers/getCYA.js +7 -5
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +8 -6
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +32 -18
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +4 -2
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +11 -8
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +13 -12
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +98 -104
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +64 -65
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +79 -72
- package/dist/components/FormRenderer/helpers/index.js +2 -2
- package/dist/components/FormRenderer/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +54 -61
- package/dist/components/FormRenderer/onCYAAction.test.js +153 -165
- package/dist/components/FormRenderer/onPageAction.js +41 -45
- package/dist/components/FormRenderer/onPageAction.test.js +210 -225
- package/dist/components/FormRenderer/onTaskAction.js +15 -11
- package/dist/components/FormRenderer/onTaskAction.test.js +89 -94
- package/dist/components/PageActions/ActionButton.js +16 -13
- package/dist/components/PageActions/ActionButton.test.js +79 -57
- package/dist/components/PageActions/PageActions.js +11 -11
- package/dist/components/PageActions/PageActions.test.js +116 -87
- package/dist/components/PageActions/index.js +1 -1
- package/dist/components/SummaryList/GroupAction.js +21 -13
- package/dist/components/SummaryList/GroupAction.test.js +37 -41
- package/dist/components/SummaryList/RowAction.js +17 -12
- package/dist/components/SummaryList/RowAction.test.js +37 -41
- package/dist/components/SummaryList/SummaryList.js +28 -23
- package/dist/components/SummaryList/SummaryList.test.js +206 -179
- package/dist/components/SummaryList/SummaryListHeadingRow.js +6 -8
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +5 -7
- package/dist/components/SummaryList/SummaryListRow.js +6 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +5 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +6 -4
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +6 -4
- 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 +30 -20
- package/dist/components/TaskList/Task.test.js +77 -84
- package/dist/components/TaskList/TaskList.js +84 -53
- package/dist/components/TaskList/TaskList.test.js +150 -150
- package/dist/components/TaskList/TaskState.js +6 -8
- package/dist/components/TaskList/TaskState.test.js +49 -56
- package/dist/components/TaskList/index.js +1 -1
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +81 -58
- package/dist/context/HooksContext/HooksContext.test.js +36 -27
- package/dist/context/HooksContext/index.js +4 -3
- package/dist/context/ValidationContext/ValidationContext.js +95 -44
- package/dist/context/ValidationContext/ValidationContext.test.js +70 -58
- package/dist/context/ValidationContext/index.js +4 -3
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +11 -10
- package/dist/hooks/useAxios.js +41 -15
- package/dist/hooks/useGetRequest.js +98 -62
- package/dist/hooks/useHooks.js +3 -1
- package/dist/hooks/useRefData.js +41 -28
- package/dist/hooks/useValidation.js +3 -1
- package/dist/index.js +15 -14
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +38 -44
- package/dist/models/TaskStates.js +28 -29
- package/dist/models/index.js +10 -10
- package/dist/setupTests.js +32 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +55 -53
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +27 -17
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +36 -34
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +34 -20
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +45 -43
- package/dist/utils/CheckYourAnswers/getCYARow.js +10 -8
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +25 -19
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +17 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +45 -39
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +75 -72
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +105 -100
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +182 -218
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +21 -26
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +106 -112
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +21 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +83 -77
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +13 -13
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +19 -14
- 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 +22 -21
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +24 -14
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +43 -52
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +3 -3
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +12 -7
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
- package/dist/utils/CollectionPage/getCollectionPageData.js +13 -8
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
- package/dist/utils/CollectionPage/getErrorsForCollection.js +26 -25
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +23 -21
- package/dist/utils/CollectionPage/getQuickEditPage.js +32 -37
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +22 -18
- package/dist/utils/CollectionPage/index.js +2 -2
- package/dist/utils/CollectionPage/mergeCollectionPages.js +42 -37
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +18 -48
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +7 -5
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
- package/dist/utils/CollectionPage/setCollectionPageData.js +19 -12
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +26 -26
- package/dist/utils/Component/addShowWhen.js +8 -4
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +20 -19
- package/dist/utils/Component/applyToComponentTree.test.js +33 -28
- package/dist/utils/Component/cleanAttributes.js +13 -10
- package/dist/utils/Component/cleanAttributes.test.js +18 -17
- package/dist/utils/Component/elevateNestedComponents.js +7 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
- package/dist/utils/Component/getComponent.js +97 -90
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +18 -19
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +63 -50
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +49 -40
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +40 -30
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +19 -21
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +23 -18
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +27 -22
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +11 -12
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +16 -18
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +9 -10
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +16 -18
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +27 -23
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +175 -155
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +16 -18
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +23 -18
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +73 -58
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +23 -18
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +23 -18
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +41 -34
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +32 -23
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +9 -10
- package/dist/utils/Component/getDefaultValue.js +9 -7
- 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 +4 -2
- package/dist/utils/Component/isEditable.test.js +15 -14
- package/dist/utils/Component/optionIsSelected.js +4 -2
- package/dist/utils/Component/optionIsSelected.test.js +12 -12
- package/dist/utils/Component/setupContainerComponentsPath.js +31 -29
- package/dist/utils/Component/setupContainerComponentsPath.test.js +16 -16
- package/dist/utils/Component/showComponent.js +4 -3
- 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 +31 -20
- 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 +19 -14
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +6 -4
- package/dist/utils/Container/getEditableComponents.test.js +46 -44
- package/dist/utils/Container/index.js +2 -2
- package/dist/utils/Container/setupNesting.js +22 -16
- package/dist/utils/Container/setupNesting.test.js +31 -28
- package/dist/utils/Container/showContainer.js +8 -4
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +50 -40
- package/dist/utils/Data/applyFormula.test.js +26 -26
- package/dist/utils/Data/deleteValues.js +8 -4
- package/dist/utils/Data/deleteValues.test.js +11 -11
- package/dist/utils/Data/getAutocompleteSource.js +29 -20
- package/dist/utils/Data/getAutocompleteSource.test.js +87 -81
- package/dist/utils/Data/getDataPath.js +30 -20
- package/dist/utils/Data/getDataPath.test.js +20 -20
- package/dist/utils/Data/getOptions.js +34 -27
- package/dist/utils/Data/getOptions.test.js +28 -28
- package/dist/utils/Data/getSourceData.js +19 -6
- package/dist/utils/Data/getSourceData.test.js +81 -85
- package/dist/utils/Data/index.js +2 -2
- package/dist/utils/Data/nestInRefdataOptions.js +16 -9
- package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
- package/dist/utils/Data/refDataToOptions.js +15 -11
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +8 -7
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +22 -14
- package/dist/utils/Data/setupFormData.test.js +51 -52
- package/dist/utils/Data/setupRefDataUrlForComponent.js +28 -21
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +28 -28
- package/dist/utils/FormPage/applyConditionalProperties.js +10 -6
- package/dist/utils/FormPage/applyConditionalProperties.test.js +19 -16
- package/dist/utils/FormPage/getConditionalText.js +4 -4
- package/dist/utils/FormPage/getConditionalText.test.js +35 -35
- package/dist/utils/FormPage/getFormPage.js +17 -16
- package/dist/utils/FormPage/getFormPage.test.js +48 -49
- package/dist/utils/FormPage/getFormPages.js +13 -8
- package/dist/utils/FormPage/getFormPages.test.js +25 -22
- package/dist/utils/FormPage/getPageActions.js +17 -10
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +7 -5
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +5 -3
- package/dist/utils/FormPage/showFormPage.js +8 -4
- 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 +28 -21
- package/dist/utils/FormPage/useComponent.test.js +80 -78
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +7 -6
- package/dist/utils/Format/formatDataForComponent.test.js +78 -50
- package/dist/utils/Format/formatDataForForm.js +8 -6
- package/dist/utils/Format/formatDataForForm.test.js +17 -14
- package/dist/utils/Format/formatDataForPage.js +5 -4
- package/dist/utils/Format/formatDataForPage.test.js +25 -20
- package/dist/utils/Format/index.js +2 -2
- package/dist/utils/Hub/getFormHub.js +2 -2
- package/dist/utils/Hub/getFormHub.test.js +32 -29
- package/dist/utils/Hub/index.js +2 -2
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +4 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +17 -25
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +17 -15
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +35 -69
- 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 +53 -47
- 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 +21 -23
- package/dist/utils/Operate/runPageOperations.js +9 -9
- package/dist/utils/Operate/runPageOperations.test.js +37 -36
- 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 +28 -22
- 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 +5 -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 +14 -9
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +42 -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 +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 +40 -36
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +5 -3
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +17 -15
- 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 +4 -3
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +15 -15
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +5 -3
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +27 -29
- package/dist/utils/Validate/additional/utils.js +24 -11
- package/dist/utils/Validate/index.js +2 -2
- package/dist/utils/Validate/validateCollection.js +27 -21
- package/dist/utils/Validate/validateCollection.test.js +77 -85
- package/dist/utils/Validate/validateComponent.js +23 -22
- package/dist/utils/Validate/validateComponent.test.js +165 -188
- package/dist/utils/Validate/validateContainer.js +21 -16
- package/dist/utils/Validate/validateContainer.test.js +56 -62
- package/dist/utils/Validate/validateDate.js +23 -17
- package/dist/utils/Validate/validateDate.test.js +32 -31
- package/dist/utils/Validate/validateEmail.js +9 -7
- package/dist/utils/Validate/validateEmail.test.js +26 -26
- package/dist/utils/Validate/validateMultifile.js +7 -5
- package/dist/utils/Validate/validateMultifile.test.js +18 -17
- package/dist/utils/Validate/validatePage.js +24 -20
- package/dist/utils/Validate/validatePage.test.js +215 -227
- package/dist/utils/Validate/validateRegex.js +8 -5
- package/dist/utils/Validate/validateRegex.test.js +17 -17
- package/dist/utils/Validate/validateRequired.js +7 -5
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +7 -5
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +19 -12
- package/dist/utils/Validate/validateTime.test.js +27 -27
- package/dist/utils/index.js +10 -8
- package/package.json +1 -1
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var _models = require("../../../models");
|
|
4
4
|
var _getRelevantPages = _interopRequireDefault(require("./getRelevantPages"));
|
|
5
|
-
function _interopRequireDefault(
|
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
6
|
// Local imports
|
|
7
7
|
|
|
8
|
-
describe('components', ()
|
|
9
|
-
describe('FormRenderer', ()
|
|
10
|
-
describe('helpers', ()
|
|
11
|
-
describe('getRelevantPages', ()
|
|
12
|
-
|
|
8
|
+
describe('components', function () {
|
|
9
|
+
describe('FormRenderer', function () {
|
|
10
|
+
describe('helpers', function () {
|
|
11
|
+
describe('getRelevantPages', function () {
|
|
12
|
+
var pages = [{
|
|
13
13
|
id: 'page1'
|
|
14
14
|
}, {
|
|
15
15
|
id: 'page2'
|
|
@@ -20,7 +20,7 @@ describe('components', () => {
|
|
|
20
20
|
}, {
|
|
21
21
|
id: 'page5'
|
|
22
22
|
}];
|
|
23
|
-
|
|
23
|
+
var taskListPages = [{
|
|
24
24
|
id: 'taskPage1'
|
|
25
25
|
}, {
|
|
26
26
|
id: 'taskPage2'
|
|
@@ -31,8 +31,8 @@ describe('components', () => {
|
|
|
31
31
|
}, {
|
|
32
32
|
id: 'taskPage5'
|
|
33
33
|
}];
|
|
34
|
-
it('return all pages from the start of the given list to the current page outside of a task when the page type is partial-cya', ()
|
|
35
|
-
|
|
34
|
+
it('return all pages from the start of the given list to the current page outside of a task when the page type is partial-cya', function () {
|
|
35
|
+
var formState = {
|
|
36
36
|
page: {
|
|
37
37
|
type: _models.FormPages.PARTIAL_CYA
|
|
38
38
|
},
|
|
@@ -40,8 +40,8 @@ describe('components', () => {
|
|
|
40
40
|
};
|
|
41
41
|
expect((0, _getRelevantPages.default)(formState, pages, undefined)).toEqual(pages.slice(0, 2));
|
|
42
42
|
});
|
|
43
|
-
it('return all pages from the start of the given list to the current page in a task when the page type is partial-cya', ()
|
|
44
|
-
|
|
43
|
+
it('return all pages from the start of the given list to the current page in a task when the page type is partial-cya', function () {
|
|
44
|
+
var formState = {
|
|
45
45
|
page: {
|
|
46
46
|
type: _models.FormPages.PARTIAL_CYA
|
|
47
47
|
},
|
|
@@ -49,15 +49,15 @@ describe('components', () => {
|
|
|
49
49
|
};
|
|
50
50
|
expect((0, _getRelevantPages.default)(formState, pages, taskListPages)).toEqual(taskListPages.slice(0, 3));
|
|
51
51
|
});
|
|
52
|
-
it('return all pages when the page type is not partial-cya', ()
|
|
53
|
-
|
|
52
|
+
it('return all pages when the page type is not partial-cya', function () {
|
|
53
|
+
var formState = {
|
|
54
54
|
page: {},
|
|
55
55
|
pageId: 'page2'
|
|
56
56
|
};
|
|
57
57
|
expect((0, _getRelevantPages.default)(formState, pages, undefined)).toEqual(pages);
|
|
58
58
|
});
|
|
59
|
-
it('return all task pages when the page type is not partial-cya', ()
|
|
60
|
-
|
|
59
|
+
it('return all task pages when the page type is not partial-cya', function () {
|
|
60
|
+
var formState = {
|
|
61
61
|
page: {},
|
|
62
62
|
pageId: 'taskPage2'
|
|
63
63
|
};
|
|
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _models = require("../../../models");
|
|
8
8
|
var _getNextPageId = _interopRequireDefault(require("./getNextPageId"));
|
|
9
|
-
function _interopRequireDefault(
|
|
10
|
-
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentPageId, action, formData, currentTask, isCompleted, sections) {
|
|
11
11
|
if (formType === _models.FormTypes.TASK || formType === _models.FormTypes.FORM_WITH_TASK) {
|
|
12
|
-
|
|
12
|
+
var _currentTask$pages;
|
|
13
|
+
var formStatus = formData.formStatus || {};
|
|
13
14
|
formStatus.tasks = formStatus.tasks || {};
|
|
14
15
|
formStatus.tasks[currentTask.name] = formStatus.tasks[currentTask.name] || {};
|
|
15
16
|
if (currentPageId === (_models.FormPages.CYA || 'submitForm') && isCompleted) {
|
|
@@ -20,15 +21,15 @@ const getSubmissionStatus = (formType, pages, currentPageId, action, formData, c
|
|
|
20
21
|
// in this case check whether the page is part of a section defined in the hub sections
|
|
21
22
|
// if it is, set the section to complete as long as isCompleted == true
|
|
22
23
|
if (sections) {
|
|
23
|
-
sections.forEach(section
|
|
24
|
-
section.tasks.forEach(task
|
|
25
|
-
|
|
26
|
-
if ((lastPage === currentPageId || lastPage.id === currentPageId) && isCompleted && task
|
|
24
|
+
sections.forEach(function (section) {
|
|
25
|
+
section.tasks.forEach(function (task) {
|
|
26
|
+
var lastPage = task.pages[task.pages.length - 1];
|
|
27
|
+
if ((lastPage === currentPageId || lastPage.id === currentPageId) && isCompleted && (task === null || task === void 0 ? void 0 : task.type) === 'pre-task-list') {
|
|
27
28
|
formStatus.tasks[task.name] = {
|
|
28
29
|
complete: isCompleted,
|
|
29
30
|
currentPage: currentPageId
|
|
30
31
|
};
|
|
31
|
-
} else if (task.pages.includes(currentPageId) && task
|
|
32
|
+
} else if (task.pages.includes(currentPageId) && (task === null || task === void 0 ? void 0 : task.type) === 'pre-task-list') {
|
|
32
33
|
formStatus.tasks[task.name] = {
|
|
33
34
|
complete: false,
|
|
34
35
|
currentPage: currentPageId
|
|
@@ -37,21 +38,21 @@ const getSubmissionStatus = (formType, pages, currentPageId, action, formData, c
|
|
|
37
38
|
});
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
} else if (action
|
|
41
|
+
} else if ((action === null || action === void 0 ? void 0 : action.type) === _models.PageAction.TYPES.SAVE_AND_NAVIGATE) {
|
|
41
42
|
formStatus.tasks[currentTask.name] = {
|
|
42
43
|
complete: false,
|
|
43
44
|
currentPage: (0, _getNextPageId.default)(formType, pages, currentPageId, action, formData)
|
|
44
45
|
};
|
|
45
|
-
} else if (currentTask.pages
|
|
46
|
+
} else if ((_currentTask$pages = currentTask.pages) !== null && _currentTask$pages !== void 0 && _currentTask$pages.includes(currentPageId)) {
|
|
46
47
|
formStatus.tasks[currentTask.name] = {
|
|
47
|
-
complete: !!action
|
|
48
|
+
complete: !!(action !== null && action !== void 0 && action.complete),
|
|
48
49
|
currentPage: currentPageId
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
formStatus.taskPage = formStatus.tasks[currentTask.name].currentPage;
|
|
52
53
|
return formStatus;
|
|
53
54
|
}
|
|
54
|
-
if (action
|
|
55
|
+
if ((action === null || action === void 0 ? void 0 : action.type) === _models.PageAction.TYPES.SAVE_AND_RETURN) {
|
|
55
56
|
return {
|
|
56
57
|
page: currentPageId
|
|
57
58
|
};
|
|
@@ -3,21 +3,23 @@
|
|
|
3
3
|
var _models = require("../../../models");
|
|
4
4
|
var _PageAction = require("../../../models/PageAction");
|
|
5
5
|
var _getSubmissionStatus = _interopRequireDefault(require("./getSubmissionStatus"));
|
|
6
|
-
function _interopRequireDefault(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
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 _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
|
|
11
|
+
describe('components', function () {
|
|
12
|
+
describe('FormRenderer', function () {
|
|
13
|
+
describe('helpers', function () {
|
|
14
|
+
describe('getSubmissionStatus', function () {
|
|
15
|
+
var OPTIONS = [{
|
|
14
16
|
value: 'romeo',
|
|
15
17
|
label: 'Romeo'
|
|
16
18
|
}, {
|
|
17
19
|
value: 'juliet',
|
|
18
20
|
label: 'Juliet'
|
|
19
21
|
}];
|
|
20
|
-
|
|
22
|
+
var RADIOS = {
|
|
21
23
|
id: 'radios',
|
|
22
24
|
fieldId: 'radios',
|
|
23
25
|
type: _models.ComponentTypes.RADIOS,
|
|
@@ -25,29 +27,29 @@ describe('components', () => {
|
|
|
25
27
|
options: OPTIONS
|
|
26
28
|
}
|
|
27
29
|
};
|
|
28
|
-
|
|
30
|
+
var TEXT = {
|
|
29
31
|
id: 'text',
|
|
30
32
|
fieldId: 'text',
|
|
31
33
|
type: _models.ComponentTypes.TEXT
|
|
32
34
|
};
|
|
33
|
-
|
|
35
|
+
var HTML = {
|
|
34
36
|
type: _models.ComponentTypes.HTML,
|
|
35
37
|
content: 'HTML'
|
|
36
38
|
};
|
|
37
|
-
|
|
39
|
+
var SHOW_WHEN_JULIET = {
|
|
38
40
|
field: RADIOS.fieldId,
|
|
39
41
|
op: '=',
|
|
40
42
|
value: OPTIONS[1].value
|
|
41
43
|
};
|
|
42
|
-
|
|
44
|
+
var SHOW_WHEN_ROMEO = {
|
|
43
45
|
field: RADIOS.fieldId,
|
|
44
46
|
op: '=',
|
|
45
47
|
value: OPTIONS[0].value
|
|
46
48
|
};
|
|
47
|
-
|
|
49
|
+
var FORM_DATA = {
|
|
48
50
|
radios: OPTIONS[0].value
|
|
49
51
|
}; // 'romeo'
|
|
50
|
-
|
|
52
|
+
var PAGES = [{
|
|
51
53
|
id: 'alpha'
|
|
52
54
|
}, {
|
|
53
55
|
id: 'bravo'
|
|
@@ -66,18 +68,18 @@ describe('components', () => {
|
|
|
66
68
|
components: [TEXT],
|
|
67
69
|
show_when: SHOW_WHEN_ROMEO
|
|
68
70
|
}];
|
|
69
|
-
describe(
|
|
70
|
-
it('should return undefined if the action has no page property', ()
|
|
71
|
-
|
|
71
|
+
describe("when the action type is '".concat(_models.PageAction.TYPES.NAVIGATE, "'"), function () {
|
|
72
|
+
it('should return undefined if the action has no page property', function () {
|
|
73
|
+
var ACTION = {
|
|
72
74
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
73
75
|
};
|
|
74
76
|
expect((0, _getSubmissionStatus.default)(_models.FormTypes.HUB, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
75
77
|
page: undefined
|
|
76
78
|
});
|
|
77
79
|
});
|
|
78
|
-
it('should return the page on the action if it exists among the pages', ()
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
it('should return the page on the action if it exists among the pages', function () {
|
|
81
|
+
var PAGE = PAGES[1].id;
|
|
82
|
+
var ACTION = {
|
|
81
83
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
82
84
|
page: PAGE
|
|
83
85
|
};
|
|
@@ -85,9 +87,9 @@ describe('components', () => {
|
|
|
85
87
|
page: PAGE
|
|
86
88
|
});
|
|
87
89
|
});
|
|
88
|
-
it('should return undefined if the page on the action does not exist among the pages', ()
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
it('should return undefined if the page on the action does not exist among the pages', function () {
|
|
91
|
+
var PAGE = 'golf';
|
|
92
|
+
var ACTION = {
|
|
91
93
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
92
94
|
page: PAGE
|
|
93
95
|
};
|
|
@@ -96,11 +98,11 @@ describe('components', () => {
|
|
|
96
98
|
});
|
|
97
99
|
});
|
|
98
100
|
});
|
|
99
|
-
describe(
|
|
100
|
-
Object.values(_models.FormTypes).forEach(formType
|
|
101
|
+
describe("when the action type is '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), function () {
|
|
102
|
+
Object.values(_models.FormTypes).forEach(function (formType) {
|
|
101
103
|
if (formType !== _models.FormTypes.TASK && formType !== _models.FormTypes.FORM_WITH_TASK) {
|
|
102
|
-
it(
|
|
103
|
-
|
|
104
|
+
it("should return the current page if the form type is '".concat(formType, "'"), function () {
|
|
105
|
+
var ACTION = _models.PageAction.DEFAULTS.saveAndReturn;
|
|
104
106
|
expect((0, _getSubmissionStatus.default)(formType, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
105
107
|
page: PAGES[0].id
|
|
106
108
|
});
|
|
@@ -108,15 +110,15 @@ describe('components', () => {
|
|
|
108
110
|
}
|
|
109
111
|
});
|
|
110
112
|
});
|
|
111
|
-
describe(
|
|
112
|
-
|
|
113
|
-
it(
|
|
113
|
+
describe("when the form type is '".concat(_models.FormTypes.HUB, "'"), function () {
|
|
114
|
+
var FORM_TYPE = _models.FormTypes.HUB;
|
|
115
|
+
it("should return '".concat(_models.FormPages.HUB, "' by default"), function () {
|
|
114
116
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES)).toMatchObject({
|
|
115
117
|
page: _models.FormPages.HUB
|
|
116
118
|
});
|
|
117
119
|
});
|
|
118
|
-
it('should return action.page if specified', ()
|
|
119
|
-
|
|
120
|
+
it('should return action.page if specified', function () {
|
|
121
|
+
var ACTION = {
|
|
120
122
|
page: 'bob'
|
|
121
123
|
};
|
|
122
124
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, undefined, ACTION, FORM_DATA)).toMatchObject({
|
|
@@ -124,63 +126,63 @@ describe('components', () => {
|
|
|
124
126
|
});
|
|
125
127
|
});
|
|
126
128
|
});
|
|
127
|
-
describe(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
it('should return the first page by default', ()
|
|
129
|
+
describe("when the form type is '".concat(_models.FormTypes.CYA, "'"), function () {
|
|
130
|
+
var FORM_TYPE = _models.FormTypes.CYA;
|
|
131
|
+
var ACTION = _models.PageAction.DEFAULTS.saveAndContinue;
|
|
132
|
+
it('should return the first page by default', function () {
|
|
131
133
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, ACTION, FORM_DATA)).toMatchObject({
|
|
132
134
|
page: PAGES[0].id
|
|
133
135
|
});
|
|
134
136
|
});
|
|
135
|
-
it('should return the second page when on the first page', ()
|
|
137
|
+
it('should return the second page when on the first page', function () {
|
|
136
138
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
137
139
|
page: PAGES[1].id
|
|
138
140
|
});
|
|
139
141
|
});
|
|
140
|
-
it('should return the third page when on the second page', ()
|
|
142
|
+
it('should return the third page when on the second page', function () {
|
|
141
143
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[1].id, ACTION, FORM_DATA)).toMatchObject({
|
|
142
144
|
page: PAGES[2].id
|
|
143
145
|
});
|
|
144
146
|
});
|
|
145
|
-
it(
|
|
147
|
+
it("should return the fifth page when on the third page because the fourth page show_when is not met", function () {
|
|
146
148
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[2].id, ACTION, FORM_DATA)).toMatchObject({
|
|
147
149
|
page: PAGES[4].id
|
|
148
150
|
});
|
|
149
151
|
});
|
|
150
|
-
it(
|
|
152
|
+
it("should return the sixth page when on the fifth page because the sixth page show_when is met", function () {
|
|
151
153
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[4].id, ACTION, FORM_DATA)).toMatchObject({
|
|
152
154
|
page: PAGES[5].id
|
|
153
155
|
});
|
|
154
156
|
});
|
|
155
|
-
it(
|
|
156
|
-
|
|
157
|
+
it("should return '".concat(_models.FormPages.CYA, "' when on the sixth (last) page"), function () {
|
|
158
|
+
var lastPageIndex = PAGES.length - 1;
|
|
157
159
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[lastPageIndex].id, ACTION, FORM_DATA)).toMatchObject({
|
|
158
160
|
page: _models.FormPages.CYA
|
|
159
161
|
});
|
|
160
162
|
});
|
|
161
163
|
});
|
|
162
|
-
describe(
|
|
163
|
-
|
|
164
|
-
it('should return the first page by default', ()
|
|
164
|
+
describe("when the form type is '".concat(_models.FormTypes.WIZARD, "'"), function () {
|
|
165
|
+
var FORM_TYPE = _models.FormTypes.WIZARD;
|
|
166
|
+
it('should return the first page by default', function () {
|
|
165
167
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES)).toMatchObject({
|
|
166
168
|
page: PAGES[0].id
|
|
167
169
|
});
|
|
168
170
|
});
|
|
169
|
-
it('should return the second page when on the first page', ()
|
|
171
|
+
it('should return the second page when on the first page', function () {
|
|
170
172
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[0].id)).toMatchObject({
|
|
171
173
|
page: PAGES[1].id
|
|
172
174
|
});
|
|
173
175
|
});
|
|
174
|
-
it('should return undefined when on the last page', ()
|
|
176
|
+
it('should return undefined when on the last page', function () {
|
|
175
177
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[PAGES.length - 1].id)).toMatchObject({
|
|
176
178
|
page: undefined
|
|
177
179
|
});
|
|
178
180
|
});
|
|
179
181
|
});
|
|
180
|
-
describe(
|
|
181
|
-
|
|
182
|
-
it(
|
|
183
|
-
|
|
182
|
+
describe("when the form type is '".concat(_models.FormTypes.FORM, "'"), function () {
|
|
183
|
+
var FORM_TYPE = _models.FormTypes.FORM;
|
|
184
|
+
it("should always return the first page if there any pages and the action is not '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), function () {
|
|
185
|
+
var ACTION = {
|
|
184
186
|
type: _models.PageAction.TYPES.SUBMIT,
|
|
185
187
|
nextPageId: 'bob'
|
|
186
188
|
};
|
|
@@ -197,99 +199,91 @@ describe('components', () => {
|
|
|
197
199
|
page: PAGES[0].id
|
|
198
200
|
});
|
|
199
201
|
});
|
|
200
|
-
it('should return undefined if there are no pages', ()
|
|
202
|
+
it('should return undefined if there are no pages', function () {
|
|
201
203
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, [])).toMatchObject({
|
|
202
204
|
page: undefined
|
|
203
205
|
});
|
|
204
206
|
});
|
|
205
207
|
});
|
|
206
|
-
describe(
|
|
207
|
-
|
|
208
|
-
it(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
describe("when the form type is '".concat(_models.FormTypes.TASK, "'"), function () {
|
|
209
|
+
var FORM_TYPE = _models.FormTypes.TASK;
|
|
210
|
+
it("should mark the current task as complete if the current page is '".concat(_models.FormPages.CYA, "' and it is marked as complete"), function () {
|
|
211
|
+
var CURRENT_PAGE_ID = _models.FormPages.CYA;
|
|
212
|
+
var TASK_NAME = 'taskName';
|
|
213
|
+
var CURRENT_TASK = {
|
|
212
214
|
name: TASK_NAME
|
|
213
215
|
};
|
|
214
216
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, undefined, {}, CURRENT_TASK, true)).toMatchObject({
|
|
215
|
-
tasks: {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
}
|
|
217
|
+
tasks: _defineProperty({}, TASK_NAME, {
|
|
218
|
+
complete: true
|
|
219
|
+
})
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
|
-
it(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
it("should update the current task with the current page and a false complete flag if the next page is not '".concat(_models.FormPages.CYA, "'"), function () {
|
|
223
|
+
var CURRENT_PAGE_ID = 'eventDate';
|
|
224
|
+
var TASK_NAME = 'taskName';
|
|
225
|
+
var CURRENT_TASK = {
|
|
226
226
|
name: TASK_NAME
|
|
227
227
|
};
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
var NEXT_PAGE_ID = 'eventMode';
|
|
229
|
+
var ACTION = {
|
|
230
230
|
type: _PageAction.PageActionTypes.SAVE_AND_NAVIGATE,
|
|
231
231
|
page: NEXT_PAGE_ID
|
|
232
232
|
};
|
|
233
233
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK)).toMatchObject({
|
|
234
|
-
tasks: {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
}
|
|
234
|
+
tasks: _defineProperty({}, TASK_NAME, {
|
|
235
|
+
complete: false,
|
|
236
|
+
currentPage: NEXT_PAGE_ID
|
|
237
|
+
})
|
|
240
238
|
});
|
|
241
239
|
});
|
|
242
|
-
it(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
240
|
+
it("should mark the current task as complete if the action indicates as much", function () {
|
|
241
|
+
var CURRENT_PAGE_ID = PAGES[0].id;
|
|
242
|
+
var TASK_NAME = 'taskName';
|
|
243
|
+
var CURRENT_TASK = {
|
|
246
244
|
name: TASK_NAME,
|
|
247
245
|
pages: [CURRENT_PAGE_ID]
|
|
248
246
|
};
|
|
249
|
-
|
|
247
|
+
var ACTION = {
|
|
250
248
|
complete: true
|
|
251
249
|
};
|
|
252
250
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK, true)).toMatchObject({
|
|
253
|
-
tasks: {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
}
|
|
251
|
+
tasks: _defineProperty({}, TASK_NAME, {
|
|
252
|
+
complete: true
|
|
253
|
+
})
|
|
258
254
|
});
|
|
259
255
|
});
|
|
260
|
-
it(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
256
|
+
it("should mark the current task as complete if the current task is a pre-task-list task", function () {
|
|
257
|
+
var CURRENT_PAGE_ID = PAGES[PAGES.length - 1].id;
|
|
258
|
+
var TASK_NAME = undefined;
|
|
259
|
+
var CURRENT_TASK = {
|
|
264
260
|
name: TASK_NAME
|
|
265
261
|
};
|
|
266
|
-
|
|
262
|
+
var ACTION = {
|
|
267
263
|
complete: true
|
|
268
264
|
};
|
|
269
|
-
|
|
265
|
+
var TASKS = [{
|
|
270
266
|
type: 'pre-task-list',
|
|
271
267
|
pages: PAGES
|
|
272
268
|
}];
|
|
273
|
-
|
|
269
|
+
var SECTIONS = [{
|
|
274
270
|
tasks: TASKS
|
|
275
271
|
}];
|
|
276
272
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK, true, SECTIONS)).toMatchObject({
|
|
277
|
-
tasks: {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
}
|
|
273
|
+
tasks: _defineProperty({}, TASK_NAME, {
|
|
274
|
+
complete: true
|
|
275
|
+
})
|
|
282
276
|
});
|
|
283
277
|
});
|
|
284
|
-
it('should not update the current task state if the current page does not belong in the task', ()
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
278
|
+
it('should not update the current task state if the current page does not belong in the task', function () {
|
|
279
|
+
var CUSTOM_FORM_TYPE = _models.FormTypes.FORM_WITH_TASK;
|
|
280
|
+
var ACTION = _models.PageAction.DEFAULTS.saveAndContinue;
|
|
281
|
+
var CURRENT_TASK = {
|
|
288
282
|
name: 'test-task',
|
|
289
283
|
pages: ['page-a']
|
|
290
284
|
};
|
|
291
|
-
|
|
292
|
-
|
|
285
|
+
var CURRENT_PAGE_ID = 'page-b';
|
|
286
|
+
var CUSTOM_FORM_DATA = {
|
|
293
287
|
formStatus: {
|
|
294
288
|
tasks: {
|
|
295
289
|
'test-task': {
|