@ukhomeoffice/cop-react-form-renderer 6.14.0 → 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 +5 -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 +75 -97
- 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 +34 -47
- package/dist/components/CollectionSummary/RenderListView.test.js +113 -111
- package/dist/components/CollectionSummary/SummaryCard.js +101 -133
- package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
- package/dist/components/CollectionSummary/SummaryCardButtons.js +25 -30
- package/dist/components/CollectionSummary/SummaryCardButtons.test.js +30 -28
- 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 +63 -100
- 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 +70 -93
- package/dist/components/FormPage/FormPage.test.js +150 -202
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +131 -173
- 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 +76 -93
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- 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 +79 -85
- 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 -226
- 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 +35 -42
- package/dist/utils/Data/getOptions.test.js +37 -38
- 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 +12 -15
- 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 +15 -23
- package/dist/utils/FormPage/useComponent.test.js +49 -50
- 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 +7 -9
- package/dist/utils/Validate/validateEmail.test.js +27 -27
- 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 +2 -4
|
@@ -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(e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
6
|
// Local imports
|
|
7
7
|
|
|
8
|
-
describe('components',
|
|
9
|
-
describe('FormRenderer',
|
|
10
|
-
describe('helpers',
|
|
11
|
-
describe('getRelevantPages',
|
|
12
|
-
|
|
8
|
+
describe('components', () => {
|
|
9
|
+
describe('FormRenderer', () => {
|
|
10
|
+
describe('helpers', () => {
|
|
11
|
+
describe('getRelevantPages', () => {
|
|
12
|
+
const pages = [{
|
|
13
13
|
id: 'page1'
|
|
14
14
|
}, {
|
|
15
15
|
id: 'page2'
|
|
@@ -20,7 +20,7 @@ describe('components', function () {
|
|
|
20
20
|
}, {
|
|
21
21
|
id: 'page5'
|
|
22
22
|
}];
|
|
23
|
-
|
|
23
|
+
const taskListPages = [{
|
|
24
24
|
id: 'taskPage1'
|
|
25
25
|
}, {
|
|
26
26
|
id: 'taskPage2'
|
|
@@ -31,8 +31,8 @@ describe('components', function () {
|
|
|
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', () => {
|
|
35
|
+
const formState = {
|
|
36
36
|
page: {
|
|
37
37
|
type: _models.FormPages.PARTIAL_CYA
|
|
38
38
|
},
|
|
@@ -40,8 +40,8 @@ describe('components', function () {
|
|
|
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', () => {
|
|
44
|
+
const formState = {
|
|
45
45
|
page: {
|
|
46
46
|
type: _models.FormPages.PARTIAL_CYA
|
|
47
47
|
},
|
|
@@ -49,15 +49,15 @@ describe('components', function () {
|
|
|
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', () => {
|
|
53
|
+
const 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', () => {
|
|
60
|
+
const formState = {
|
|
61
61
|
page: {},
|
|
62
62
|
pageId: 'taskPage2'
|
|
63
63
|
};
|
|
@@ -6,11 +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(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const 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
|
-
|
|
13
|
+
const formStatus = formData.formStatus || {};
|
|
14
14
|
formStatus.tasks = formStatus.tasks || {};
|
|
15
15
|
formStatus.tasks[currentTask.name] = formStatus.tasks[currentTask.name] || {};
|
|
16
16
|
if (currentPageId === (_models.FormPages.CYA || 'submitForm') && isCompleted) {
|
|
@@ -21,9 +21,9 @@ var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentP
|
|
|
21
21
|
// in this case check whether the page is part of a section defined in the hub sections
|
|
22
22
|
// if it is, set the section to complete as long as isCompleted == true
|
|
23
23
|
if (sections) {
|
|
24
|
-
sections.forEach(
|
|
25
|
-
section.tasks.forEach(
|
|
26
|
-
|
|
24
|
+
sections.forEach(section => {
|
|
25
|
+
section.tasks.forEach(task => {
|
|
26
|
+
const lastPage = task.pages[task.pages.length - 1];
|
|
27
27
|
if ((lastPage === currentPageId || lastPage.id === currentPageId) && isCompleted && (task === null || task === void 0 ? void 0 : task.type) === 'pre-task-list') {
|
|
28
28
|
formStatus.tasks[task.name] = {
|
|
29
29
|
complete: isCompleted,
|
|
@@ -3,23 +3,21 @@
|
|
|
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
|
-
describe('
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
describe('getSubmissionStatus', function () {
|
|
15
|
-
var OPTIONS = [{
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
// Local imports
|
|
8
|
+
|
|
9
|
+
describe('components', () => {
|
|
10
|
+
describe('FormRenderer', () => {
|
|
11
|
+
describe('helpers', () => {
|
|
12
|
+
describe('getSubmissionStatus', () => {
|
|
13
|
+
const OPTIONS = [{
|
|
16
14
|
value: 'romeo',
|
|
17
15
|
label: 'Romeo'
|
|
18
16
|
}, {
|
|
19
17
|
value: 'juliet',
|
|
20
18
|
label: 'Juliet'
|
|
21
19
|
}];
|
|
22
|
-
|
|
20
|
+
const RADIOS = {
|
|
23
21
|
id: 'radios',
|
|
24
22
|
fieldId: 'radios',
|
|
25
23
|
type: _models.ComponentTypes.RADIOS,
|
|
@@ -27,29 +25,29 @@ describe('components', function () {
|
|
|
27
25
|
options: OPTIONS
|
|
28
26
|
}
|
|
29
27
|
};
|
|
30
|
-
|
|
28
|
+
const TEXT = {
|
|
31
29
|
id: 'text',
|
|
32
30
|
fieldId: 'text',
|
|
33
31
|
type: _models.ComponentTypes.TEXT
|
|
34
32
|
};
|
|
35
|
-
|
|
33
|
+
const HTML = {
|
|
36
34
|
type: _models.ComponentTypes.HTML,
|
|
37
35
|
content: 'HTML'
|
|
38
36
|
};
|
|
39
|
-
|
|
37
|
+
const SHOW_WHEN_JULIET = {
|
|
40
38
|
field: RADIOS.fieldId,
|
|
41
39
|
op: '=',
|
|
42
40
|
value: OPTIONS[1].value
|
|
43
41
|
};
|
|
44
|
-
|
|
42
|
+
const SHOW_WHEN_ROMEO = {
|
|
45
43
|
field: RADIOS.fieldId,
|
|
46
44
|
op: '=',
|
|
47
45
|
value: OPTIONS[0].value
|
|
48
46
|
};
|
|
49
|
-
|
|
47
|
+
const FORM_DATA = {
|
|
50
48
|
radios: OPTIONS[0].value
|
|
51
49
|
}; // 'romeo'
|
|
52
|
-
|
|
50
|
+
const PAGES = [{
|
|
53
51
|
id: 'alpha'
|
|
54
52
|
}, {
|
|
55
53
|
id: 'bravo'
|
|
@@ -68,18 +66,18 @@ describe('components', function () {
|
|
|
68
66
|
components: [TEXT],
|
|
69
67
|
show_when: SHOW_WHEN_ROMEO
|
|
70
68
|
}];
|
|
71
|
-
describe("when the action type is '".concat(_models.PageAction.TYPES.NAVIGATE, "'"),
|
|
72
|
-
it('should return undefined if the action has no page property',
|
|
73
|
-
|
|
69
|
+
describe("when the action type is '".concat(_models.PageAction.TYPES.NAVIGATE, "'"), () => {
|
|
70
|
+
it('should return undefined if the action has no page property', () => {
|
|
71
|
+
const ACTION = {
|
|
74
72
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
75
73
|
};
|
|
76
74
|
expect((0, _getSubmissionStatus.default)(_models.FormTypes.HUB, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
77
75
|
page: undefined
|
|
78
76
|
});
|
|
79
77
|
});
|
|
80
|
-
it('should return the page on the action if it exists among the pages',
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
it('should return the page on the action if it exists among the pages', () => {
|
|
79
|
+
const PAGE = PAGES[1].id;
|
|
80
|
+
const ACTION = {
|
|
83
81
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
84
82
|
page: PAGE
|
|
85
83
|
};
|
|
@@ -87,9 +85,9 @@ describe('components', function () {
|
|
|
87
85
|
page: PAGE
|
|
88
86
|
});
|
|
89
87
|
});
|
|
90
|
-
it('should return undefined if the page on the action does not exist among the pages',
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
it('should return undefined if the page on the action does not exist among the pages', () => {
|
|
89
|
+
const PAGE = 'golf';
|
|
90
|
+
const ACTION = {
|
|
93
91
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
94
92
|
page: PAGE
|
|
95
93
|
};
|
|
@@ -98,11 +96,11 @@ describe('components', function () {
|
|
|
98
96
|
});
|
|
99
97
|
});
|
|
100
98
|
});
|
|
101
|
-
describe("when the action type is '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"),
|
|
102
|
-
Object.values(_models.FormTypes).forEach(
|
|
99
|
+
describe("when the action type is '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), () => {
|
|
100
|
+
Object.values(_models.FormTypes).forEach(formType => {
|
|
103
101
|
if (formType !== _models.FormTypes.TASK && formType !== _models.FormTypes.FORM_WITH_TASK) {
|
|
104
|
-
it("should return the current page if the form type is '".concat(formType, "'"),
|
|
105
|
-
|
|
102
|
+
it("should return the current page if the form type is '".concat(formType, "'"), () => {
|
|
103
|
+
const ACTION = _models.PageAction.DEFAULTS.saveAndReturn;
|
|
106
104
|
expect((0, _getSubmissionStatus.default)(formType, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
107
105
|
page: PAGES[0].id
|
|
108
106
|
});
|
|
@@ -110,15 +108,15 @@ describe('components', function () {
|
|
|
110
108
|
}
|
|
111
109
|
});
|
|
112
110
|
});
|
|
113
|
-
describe("when the form type is '".concat(_models.FormTypes.HUB, "'"),
|
|
114
|
-
|
|
115
|
-
it("should return '".concat(_models.FormPages.HUB, "' by default"),
|
|
111
|
+
describe("when the form type is '".concat(_models.FormTypes.HUB, "'"), () => {
|
|
112
|
+
const FORM_TYPE = _models.FormTypes.HUB;
|
|
113
|
+
it("should return '".concat(_models.FormPages.HUB, "' by default"), () => {
|
|
116
114
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES)).toMatchObject({
|
|
117
115
|
page: _models.FormPages.HUB
|
|
118
116
|
});
|
|
119
117
|
});
|
|
120
|
-
it('should return action.page if specified',
|
|
121
|
-
|
|
118
|
+
it('should return action.page if specified', () => {
|
|
119
|
+
const ACTION = {
|
|
122
120
|
page: 'bob'
|
|
123
121
|
};
|
|
124
122
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, undefined, ACTION, FORM_DATA)).toMatchObject({
|
|
@@ -126,63 +124,63 @@ describe('components', function () {
|
|
|
126
124
|
});
|
|
127
125
|
});
|
|
128
126
|
});
|
|
129
|
-
describe("when the form type is '".concat(_models.FormTypes.CYA, "'"),
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
it('should return the first page by default',
|
|
127
|
+
describe("when the form type is '".concat(_models.FormTypes.CYA, "'"), () => {
|
|
128
|
+
const FORM_TYPE = _models.FormTypes.CYA;
|
|
129
|
+
const ACTION = _models.PageAction.DEFAULTS.saveAndContinue;
|
|
130
|
+
it('should return the first page by default', () => {
|
|
133
131
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, ACTION, FORM_DATA)).toMatchObject({
|
|
134
132
|
page: PAGES[0].id
|
|
135
133
|
});
|
|
136
134
|
});
|
|
137
|
-
it('should return the second page when on the first page',
|
|
135
|
+
it('should return the second page when on the first page', () => {
|
|
138
136
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
139
137
|
page: PAGES[1].id
|
|
140
138
|
});
|
|
141
139
|
});
|
|
142
|
-
it('should return the third page when on the second page',
|
|
140
|
+
it('should return the third page when on the second page', () => {
|
|
143
141
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[1].id, ACTION, FORM_DATA)).toMatchObject({
|
|
144
142
|
page: PAGES[2].id
|
|
145
143
|
});
|
|
146
144
|
});
|
|
147
|
-
it("should return the fifth page when on the third page because the fourth page show_when is not met",
|
|
145
|
+
it("should return the fifth page when on the third page because the fourth page show_when is not met", () => {
|
|
148
146
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[2].id, ACTION, FORM_DATA)).toMatchObject({
|
|
149
147
|
page: PAGES[4].id
|
|
150
148
|
});
|
|
151
149
|
});
|
|
152
|
-
it("should return the sixth page when on the fifth page because the sixth page show_when is met",
|
|
150
|
+
it("should return the sixth page when on the fifth page because the sixth page show_when is met", () => {
|
|
153
151
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[4].id, ACTION, FORM_DATA)).toMatchObject({
|
|
154
152
|
page: PAGES[5].id
|
|
155
153
|
});
|
|
156
154
|
});
|
|
157
|
-
it("should return '".concat(_models.FormPages.CYA, "' when on the sixth (last) page"),
|
|
158
|
-
|
|
155
|
+
it("should return '".concat(_models.FormPages.CYA, "' when on the sixth (last) page"), () => {
|
|
156
|
+
const lastPageIndex = PAGES.length - 1;
|
|
159
157
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[lastPageIndex].id, ACTION, FORM_DATA)).toMatchObject({
|
|
160
158
|
page: _models.FormPages.CYA
|
|
161
159
|
});
|
|
162
160
|
});
|
|
163
161
|
});
|
|
164
|
-
describe("when the form type is '".concat(_models.FormTypes.WIZARD, "'"),
|
|
165
|
-
|
|
166
|
-
it('should return the first page by default',
|
|
162
|
+
describe("when the form type is '".concat(_models.FormTypes.WIZARD, "'"), () => {
|
|
163
|
+
const FORM_TYPE = _models.FormTypes.WIZARD;
|
|
164
|
+
it('should return the first page by default', () => {
|
|
167
165
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES)).toMatchObject({
|
|
168
166
|
page: PAGES[0].id
|
|
169
167
|
});
|
|
170
168
|
});
|
|
171
|
-
it('should return the second page when on the first page',
|
|
169
|
+
it('should return the second page when on the first page', () => {
|
|
172
170
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[0].id)).toMatchObject({
|
|
173
171
|
page: PAGES[1].id
|
|
174
172
|
});
|
|
175
173
|
});
|
|
176
|
-
it('should return undefined when on the last page',
|
|
174
|
+
it('should return undefined when on the last page', () => {
|
|
177
175
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[PAGES.length - 1].id)).toMatchObject({
|
|
178
176
|
page: undefined
|
|
179
177
|
});
|
|
180
178
|
});
|
|
181
179
|
});
|
|
182
|
-
describe("when the form type is '".concat(_models.FormTypes.FORM, "'"),
|
|
183
|
-
|
|
184
|
-
it("should always return the first page if there any pages and the action is not '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"),
|
|
185
|
-
|
|
180
|
+
describe("when the form type is '".concat(_models.FormTypes.FORM, "'"), () => {
|
|
181
|
+
const FORM_TYPE = _models.FormTypes.FORM;
|
|
182
|
+
it("should always return the first page if there any pages and the action is not '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), () => {
|
|
183
|
+
const ACTION = {
|
|
186
184
|
type: _models.PageAction.TYPES.SUBMIT,
|
|
187
185
|
nextPageId: 'bob'
|
|
188
186
|
};
|
|
@@ -199,91 +197,99 @@ describe('components', function () {
|
|
|
199
197
|
page: PAGES[0].id
|
|
200
198
|
});
|
|
201
199
|
});
|
|
202
|
-
it('should return undefined if there are no pages',
|
|
200
|
+
it('should return undefined if there are no pages', () => {
|
|
203
201
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, [])).toMatchObject({
|
|
204
202
|
page: undefined
|
|
205
203
|
});
|
|
206
204
|
});
|
|
207
205
|
});
|
|
208
|
-
describe("when the form type is '".concat(_models.FormTypes.TASK, "'"),
|
|
209
|
-
|
|
210
|
-
it("should mark the current task as complete if the current page is '".concat(_models.FormPages.CYA, "' and it is marked as complete"),
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
206
|
+
describe("when the form type is '".concat(_models.FormTypes.TASK, "'"), () => {
|
|
207
|
+
const FORM_TYPE = _models.FormTypes.TASK;
|
|
208
|
+
it("should mark the current task as complete if the current page is '".concat(_models.FormPages.CYA, "' and it is marked as complete"), () => {
|
|
209
|
+
const CURRENT_PAGE_ID = _models.FormPages.CYA;
|
|
210
|
+
const TASK_NAME = 'taskName';
|
|
211
|
+
const CURRENT_TASK = {
|
|
214
212
|
name: TASK_NAME
|
|
215
213
|
};
|
|
216
214
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, undefined, {}, CURRENT_TASK, true)).toMatchObject({
|
|
217
|
-
tasks:
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
tasks: {
|
|
216
|
+
[TASK_NAME]: {
|
|
217
|
+
complete: true
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
220
|
});
|
|
221
221
|
});
|
|
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, "'"),
|
|
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, "'"), () => {
|
|
223
|
+
const CURRENT_PAGE_ID = 'eventDate';
|
|
224
|
+
const TASK_NAME = 'taskName';
|
|
225
|
+
const CURRENT_TASK = {
|
|
226
226
|
name: TASK_NAME
|
|
227
227
|
};
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
const NEXT_PAGE_ID = 'eventMode';
|
|
229
|
+
const 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
|
-
|
|
234
|
+
tasks: {
|
|
235
|
+
[TASK_NAME]: {
|
|
236
|
+
complete: false,
|
|
237
|
+
currentPage: NEXT_PAGE_ID
|
|
238
|
+
}
|
|
239
|
+
}
|
|
238
240
|
});
|
|
239
241
|
});
|
|
240
|
-
it("should mark the current task as complete if the action indicates as much",
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
it("should mark the current task as complete if the action indicates as much", () => {
|
|
243
|
+
const CURRENT_PAGE_ID = PAGES[0].id;
|
|
244
|
+
const TASK_NAME = 'taskName';
|
|
245
|
+
const CURRENT_TASK = {
|
|
244
246
|
name: TASK_NAME,
|
|
245
247
|
pages: [CURRENT_PAGE_ID]
|
|
246
248
|
};
|
|
247
|
-
|
|
249
|
+
const ACTION = {
|
|
248
250
|
complete: true
|
|
249
251
|
};
|
|
250
252
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK, true)).toMatchObject({
|
|
251
|
-
tasks:
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
tasks: {
|
|
254
|
+
[TASK_NAME]: {
|
|
255
|
+
complete: true
|
|
256
|
+
}
|
|
257
|
+
}
|
|
254
258
|
});
|
|
255
259
|
});
|
|
256
|
-
it("should mark the current task as complete if the current task is a pre-task-list task",
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
+
it("should mark the current task as complete if the current task is a pre-task-list task", () => {
|
|
261
|
+
const CURRENT_PAGE_ID = PAGES[PAGES.length - 1].id;
|
|
262
|
+
const TASK_NAME = undefined;
|
|
263
|
+
const CURRENT_TASK = {
|
|
260
264
|
name: TASK_NAME
|
|
261
265
|
};
|
|
262
|
-
|
|
266
|
+
const ACTION = {
|
|
263
267
|
complete: true
|
|
264
268
|
};
|
|
265
|
-
|
|
269
|
+
const TASKS = [{
|
|
266
270
|
type: 'pre-task-list',
|
|
267
271
|
pages: PAGES
|
|
268
272
|
}];
|
|
269
|
-
|
|
273
|
+
const SECTIONS = [{
|
|
270
274
|
tasks: TASKS
|
|
271
275
|
}];
|
|
272
276
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK, true, SECTIONS)).toMatchObject({
|
|
273
|
-
tasks:
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
tasks: {
|
|
278
|
+
[TASK_NAME]: {
|
|
279
|
+
complete: true
|
|
280
|
+
}
|
|
281
|
+
}
|
|
276
282
|
});
|
|
277
283
|
});
|
|
278
|
-
it('should not update the current task state if the current page does not belong in the task',
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
284
|
+
it('should not update the current task state if the current page does not belong in the task', () => {
|
|
285
|
+
const CUSTOM_FORM_TYPE = _models.FormTypes.FORM_WITH_TASK;
|
|
286
|
+
const ACTION = _models.PageAction.DEFAULTS.saveAndContinue;
|
|
287
|
+
const CURRENT_TASK = {
|
|
282
288
|
name: 'test-task',
|
|
283
289
|
pages: ['page-a']
|
|
284
290
|
};
|
|
285
|
-
|
|
286
|
-
|
|
291
|
+
const CURRENT_PAGE_ID = 'page-b';
|
|
292
|
+
const CUSTOM_FORM_DATA = {
|
|
287
293
|
formStatus: {
|
|
288
294
|
tasks: {
|
|
289
295
|
'test-task': {
|