@ukhomeoffice/cop-react-form-renderer 6.5.1-peter → 6.7.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +12 -12
- package/dist/components/CheckYourAnswers/Answer.test.js +92 -127
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +101 -131
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +463 -769
- package/dist/components/CollectionPage/CollectionPage.js +73 -63
- package/dist/components/CollectionPage/CollectionPage.test.js +316 -366
- package/dist/components/CollectionSummary/BannerStrip.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.test.js +80 -76
- package/dist/components/CollectionSummary/CollectionSummary.js +97 -107
- package/dist/components/CollectionSummary/CollectionSummary.test.js +152 -142
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +45 -51
- package/dist/components/CollectionSummary/RenderListView.test.js +78 -77
- package/dist/components/CollectionSummary/SummaryCard.js +104 -135
- package/dist/components/CollectionSummary/SummaryCard.test.js +930 -962
- package/dist/components/CollectionSummary/SummaryCardDetails.js +72 -71
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +128 -135
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +30 -35
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +62 -74
- package/dist/components/FormComponent/Collection.js +74 -108
- package/dist/components/FormComponent/Collection.test.js +909 -1081
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +69 -72
- package/dist/components/FormComponent/FormComponent.test.js +353 -414
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +65 -80
- package/dist/components/FormPage/FormPage.test.js +127 -163
- package/dist/components/FormRenderer/FormRenderer.js +143 -179
- package/dist/components/FormRenderer/FormRenderer.test.js +730 -1115
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +15 -15
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +16 -20
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +17 -22
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +3 -5
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +5 -7
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -24
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +103 -97
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -78
- package/dist/components/FormRenderer/helpers/index.js +2 -4
- package/dist/components/FormRenderer/onCYAAction.js +59 -51
- package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
- package/dist/components/FormRenderer/onPageAction.js +44 -47
- package/dist/components/FormRenderer/onPageAction.test.js +223 -213
- package/dist/components/FormRenderer/onTaskAction.js +9 -13
- package/dist/components/FormRenderer/onTaskAction.test.js +93 -88
- package/dist/components/PageActions/ActionButton.js +12 -15
- package/dist/components/PageActions/ActionButton.test.js +56 -78
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +86 -115
- package/dist/components/SummaryList/GroupAction.js +9 -17
- package/dist/components/SummaryList/GroupAction.test.js +37 -33
- package/dist/components/SummaryList/RowAction.js +11 -16
- package/dist/components/SummaryList/RowAction.test.js +37 -33
- package/dist/components/SummaryList/SummaryList.js +21 -26
- package/dist/components/SummaryList/SummaryList.test.js +143 -166
- package/dist/components/SummaryList/SummaryListHeadingRow.js +6 -4
- package/dist/components/SummaryList/SummaryListRow.js +6 -4
- package/dist/components/SummaryList/SummaryListTitleRow.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +19 -29
- package/dist/components/TaskList/Task.test.js +83 -76
- package/dist/components/TaskList/TaskList.js +45 -71
- package/dist/components/TaskList/TaskList.test.js +113 -111
- package/dist/components/TaskList/TaskState.js +7 -5
- package/dist/components/TaskList/TaskState.test.js +52 -45
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +57 -80
- package/dist/context/HooksContext/HooksContext.test.js +26 -35
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +43 -94
- package/dist/context/ValidationContext/ValidationContext.test.js +56 -68
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +9 -10
- package/dist/hooks/useAxios.js +14 -40
- package/dist/hooks/useGetRequest.js +61 -97
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +26 -39
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +13 -14
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +44 -38
- package/dist/models/TaskStates.js +29 -28
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +52 -54
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +15 -25
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +33 -35
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -31
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +42 -44
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +18 -24
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +15 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +33 -36
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +58 -61
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +83 -89
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +164 -138
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +25 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +103 -97
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +13 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +70 -76
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +11 -11
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +7 -7
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +18 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +55 -26
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getErrorsForCollection.js +24 -24
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +20 -22
- package/dist/utils/CollectionPage/getQuickEditPage.js +36 -28
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +26 -45
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +31 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +20 -20
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
- package/dist/utils/Component/addShowWhen.js +4 -8
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +27 -32
- package/dist/utils/Component/cleanAttributes.js +10 -13
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +88 -94
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +18 -17
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +46 -59
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +39 -48
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +23 -33
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +20 -18
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +20 -25
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +9 -8
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +22 -26
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +57 -72
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +31 -38
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +20 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +9 -8
- package/dist/utils/Component/getDefaultValue.js +6 -8
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +22 -21
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +27 -29
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +8 -8
- package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
- package/dist/utils/Condition/meetsCondition.js +16 -25
- package/dist/utils/Condition/meetsCondition.test.js +402 -402
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +13 -18
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +3 -5
- package/dist/utils/Container/getEditableComponents.test.js +43 -45
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +16 -20
- package/dist/utils/Container/setupNesting.test.js +27 -30
- package/dist/utils/Container/showContainer.js +3 -7
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +38 -48
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +18 -26
- package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +24 -30
- package/dist/utils/Data/getOptions.test.js +27 -27
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +84 -80
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/nestInRefdataOptions.js +9 -16
- package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
- package/dist/utils/Data/refDataToOptions.js +10 -13
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +13 -21
- package/dist/utils/Data/setupFormData.test.js +51 -50
- package/dist/utils/Data/setupRefDataUrlForComponent.js +20 -26
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +5 -9
- package/dist/utils/FormPage/applyConditionalProperties.test.js +15 -18
- package/dist/utils/FormPage/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- package/dist/utils/FormPage/getFormPage.js +15 -16
- package/dist/utils/FormPage/getFormPage.test.js +47 -46
- package/dist/utils/FormPage/getFormPages.js +7 -12
- package/dist/utils/FormPage/getFormPages.test.js +20 -23
- package/dist/utils/FormPage/getPageActions.js +9 -15
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +2 -4
- package/dist/utils/FormPage/showFormPage.js +3 -7
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +21 -28
- package/dist/utils/FormPage/useComponent.test.js +77 -79
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +5 -6
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +13 -16
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +28 -31
- package/dist/utils/Hub/index.js +1 -1
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +24 -16
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +14 -16
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +68 -34
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -52
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +22 -20
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +35 -36
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +21 -27
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +6 -6
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +7 -11
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -41
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +8 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +64 -32
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +14 -16
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +28 -26
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +19 -25
- package/dist/utils/Validate/validateCollection.test.js +74 -66
- package/dist/utils/Validate/validateComponent.js +17 -15
- package/dist/utils/Validate/validateComponent.test.js +167 -146
- package/dist/utils/Validate/validateContainer.js +15 -20
- package/dist/utils/Validate/validateContainer.test.js +58 -52
- package/dist/utils/Validate/validateDate.js +15 -21
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +6 -8
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +19 -22
- package/dist/utils/Validate/validatePage.test.js +215 -203
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +11 -18
- package/dist/utils/Validate/validateTime.test.js +16 -16
- package/dist/utils/index.js +7 -9
- package/package.json +2 -2
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-data.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-form.json +0 -61
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-after.json +0 -429
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-before.json +0 -449
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-form.json +0 -15219
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-after.json +0 -516
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-before.json +0 -593
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab2-form.json +0 -15219
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-after.json +0 -84
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-before.json +0 -98
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-form.json +0 -9158
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collection-data-removed.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collections.json +0 -8
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components.json +0 -5
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-entire-collection-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-component-removed.json +0 -10
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-components.json +0 -11
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-for-nested-components.json +0 -96
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections-delete-entire.json +0 -47
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections.json +0 -46
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-components.json +0 -48
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test.json +0 -1605
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test2.json +0 -205
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +0 -206
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +0 -143
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +0 -26
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.test.js +0 -56
|
@@ -3,55 +3,49 @@
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
4
|
var _validatePage = _interopRequireDefault(require("./validatePage"));
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
required: required
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
describe('with FormPage', function () {
|
|
23
|
-
it('should return no error when the components array is null', function () {
|
|
24
|
-
var PAGE = {
|
|
6
|
+
// Local imports
|
|
7
|
+
|
|
8
|
+
describe('utils.Validate.Page', () => {
|
|
9
|
+
const setup = (id, type, label, required) => ({
|
|
10
|
+
id,
|
|
11
|
+
fieldId: id,
|
|
12
|
+
type,
|
|
13
|
+
label,
|
|
14
|
+
required
|
|
15
|
+
});
|
|
16
|
+
describe('with FormPage', () => {
|
|
17
|
+
it('should return no error when the components array is null', () => {
|
|
18
|
+
const PAGE = {
|
|
25
19
|
components: null,
|
|
26
20
|
formData: null
|
|
27
21
|
};
|
|
28
22
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
29
23
|
});
|
|
30
|
-
it('should return no error when the components array is empty',
|
|
31
|
-
|
|
24
|
+
it('should return no error when the components array is empty', () => {
|
|
25
|
+
const PAGE = {
|
|
32
26
|
components: [],
|
|
33
27
|
formData: null
|
|
34
28
|
};
|
|
35
29
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
36
30
|
});
|
|
37
|
-
describe('when there is no form data',
|
|
38
|
-
it('should return no errors when no components are required',
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
describe('when there is no form data', () => {
|
|
32
|
+
it('should return no errors when no components are required', () => {
|
|
33
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', false), setup('b', _models.ComponentTypes.TEXT, 'Bravo', false)];
|
|
34
|
+
const PAGE = {
|
|
41
35
|
components: COMPONENTS,
|
|
42
36
|
formData: null
|
|
43
37
|
};
|
|
44
38
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
45
39
|
});
|
|
46
|
-
it('should return an error for each required component',
|
|
47
|
-
|
|
40
|
+
it('should return an error for each required component', () => {
|
|
41
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
48
42
|
// The only unrequired one
|
|
49
43
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
50
|
-
|
|
44
|
+
const PAGE = {
|
|
51
45
|
components: COMPONENTS,
|
|
52
46
|
formData: null
|
|
53
47
|
};
|
|
54
|
-
|
|
48
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
55
49
|
expect(RESULT.length).toEqual(4);
|
|
56
50
|
expect(RESULT[0]).toEqual({
|
|
57
51
|
id: 'a',
|
|
@@ -70,18 +64,18 @@ describe('utils.Validate.Page', function () {
|
|
|
70
64
|
error: 'Echo is required'
|
|
71
65
|
});
|
|
72
66
|
});
|
|
73
|
-
it('should return an error for each required component on a collection page',
|
|
74
|
-
|
|
67
|
+
it('should return an error for each required component on a collection page', () => {
|
|
68
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
75
69
|
// The only unrequired one
|
|
76
70
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
77
|
-
|
|
71
|
+
const PAGE = {
|
|
78
72
|
components: COMPONENTS,
|
|
79
73
|
collection: {
|
|
80
74
|
name: 'testCollection'
|
|
81
75
|
},
|
|
82
76
|
formData: null
|
|
83
77
|
};
|
|
84
|
-
|
|
78
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
85
79
|
expect(RESULT.length).toEqual(4);
|
|
86
80
|
expect(RESULT[0]).toEqual({
|
|
87
81
|
id: 'a',
|
|
@@ -100,18 +94,18 @@ describe('utils.Validate.Page', function () {
|
|
|
100
94
|
error: 'Echo is required'
|
|
101
95
|
});
|
|
102
96
|
});
|
|
103
|
-
it('should return an error for each required component on a nested collection page',
|
|
104
|
-
|
|
97
|
+
it('should return an error for each required component on a nested collection page', () => {
|
|
98
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
105
99
|
// The only unrequired one
|
|
106
100
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
107
|
-
|
|
101
|
+
const PAGE = {
|
|
108
102
|
components: COMPONENTS,
|
|
109
103
|
collection: {
|
|
110
104
|
name: 'parent.child'
|
|
111
105
|
},
|
|
112
106
|
formData: null
|
|
113
107
|
};
|
|
114
|
-
|
|
108
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
115
109
|
expect(RESULT.length).toEqual(4);
|
|
116
110
|
expect(RESULT).toEqual([{
|
|
117
111
|
id: 'a',
|
|
@@ -127,8 +121,8 @@ describe('utils.Validate.Page', function () {
|
|
|
127
121
|
error: 'Echo is required'
|
|
128
122
|
}]);
|
|
129
123
|
});
|
|
130
|
-
it('should return an error for each required component with interpolated label',
|
|
131
|
-
|
|
124
|
+
it('should return an error for each required component with interpolated label', () => {
|
|
125
|
+
const COMPONENTS = [
|
|
132
126
|
// eslint-disable-next-line no-template-curly-in-string
|
|
133
127
|
setup('a', _models.ComponentTypes.TEXT, 'Alpha ${tiger}', true),
|
|
134
128
|
// eslint-disable-next-line no-template-curly-in-string
|
|
@@ -139,7 +133,7 @@ describe('utils.Validate.Page', function () {
|
|
|
139
133
|
setup('d', _models.ComponentTypes.CHECKBOXES, 'Delta ${lion}', true),
|
|
140
134
|
// eslint-disable-next-line no-template-curly-in-string
|
|
141
135
|
setup('e', _models.ComponentTypes.FILE, 'Echo ${zoo}', true)];
|
|
142
|
-
|
|
136
|
+
const PAGE = {
|
|
143
137
|
components: COMPONENTS,
|
|
144
138
|
formData: {
|
|
145
139
|
tiger: 'Tiger',
|
|
@@ -149,7 +143,7 @@ describe('utils.Validate.Page', function () {
|
|
|
149
143
|
zoo: 'Zoo'
|
|
150
144
|
}
|
|
151
145
|
};
|
|
152
|
-
|
|
146
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
153
147
|
expect(RESULT.length).toEqual(5);
|
|
154
148
|
expect(RESULT).toEqual([{
|
|
155
149
|
id: 'a',
|
|
@@ -169,90 +163,90 @@ describe('utils.Validate.Page', function () {
|
|
|
169
163
|
}]);
|
|
170
164
|
});
|
|
171
165
|
});
|
|
172
|
-
describe('when the form data is fully valid',
|
|
173
|
-
|
|
166
|
+
describe('when the form data is fully valid', () => {
|
|
167
|
+
const DATA = {
|
|
174
168
|
alpha: 'alpha.smith@digital.homeoffice.gov.uk',
|
|
175
169
|
bravo: 'bravo.jones@digital.homeoffice.gov.uk'
|
|
176
170
|
};
|
|
177
|
-
it('should return no errors when none of the components are required or email types',
|
|
178
|
-
|
|
179
|
-
|
|
171
|
+
it('should return no errors when none of the components are required or email types', () => {
|
|
172
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false)];
|
|
173
|
+
const PAGE = {
|
|
180
174
|
components: COMPONENTS,
|
|
181
175
|
formData: DATA
|
|
182
176
|
};
|
|
183
177
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
184
178
|
});
|
|
185
|
-
it('should return no errors when all of the components are required but not email types',
|
|
186
|
-
|
|
187
|
-
|
|
179
|
+
it('should return no errors when all of the components are required but not email types', () => {
|
|
180
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true)];
|
|
181
|
+
const PAGE = {
|
|
188
182
|
components: COMPONENTS,
|
|
189
183
|
formData: DATA
|
|
190
184
|
};
|
|
191
185
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
192
186
|
});
|
|
193
|
-
it('should return no errors when none of the components are required but are all email types',
|
|
194
|
-
|
|
195
|
-
|
|
187
|
+
it('should return no errors when none of the components are required but are all email types', () => {
|
|
188
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false)];
|
|
189
|
+
const PAGE = {
|
|
196
190
|
components: COMPONENTS,
|
|
197
191
|
formData: DATA
|
|
198
192
|
};
|
|
199
193
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
200
194
|
});
|
|
201
|
-
it('should return no errors when all of the components are required and email types',
|
|
202
|
-
|
|
203
|
-
|
|
195
|
+
it('should return no errors when all of the components are required and email types', () => {
|
|
196
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true)];
|
|
197
|
+
const PAGE = {
|
|
204
198
|
components: COMPONENTS,
|
|
205
199
|
formData: DATA
|
|
206
200
|
};
|
|
207
201
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
208
202
|
});
|
|
209
203
|
});
|
|
210
|
-
describe('when the form data has one field missing and includes an invalid email',
|
|
211
|
-
|
|
204
|
+
describe('when the form data has one field missing and includes an invalid email', () => {
|
|
205
|
+
const DATA = {
|
|
212
206
|
alpha: 'alpha.smith@digital.homeoffice.gov.uk',
|
|
213
207
|
bravo: 'bravo.jones@hotmail.com'
|
|
214
208
|
};
|
|
215
|
-
it('should return no errors when none of the components are required or email types',
|
|
216
|
-
|
|
217
|
-
|
|
209
|
+
it('should return no errors when none of the components are required or email types', () => {
|
|
210
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', false)];
|
|
211
|
+
const PAGE = {
|
|
218
212
|
components: COMPONENTS,
|
|
219
213
|
formData: null
|
|
220
214
|
};
|
|
221
215
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
222
216
|
});
|
|
223
|
-
it('should return an error for the missing field when all are required but not email types',
|
|
224
|
-
|
|
225
|
-
|
|
217
|
+
it('should return an error for the missing field when all are required but not email types', () => {
|
|
218
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', true)];
|
|
219
|
+
const PAGE = {
|
|
226
220
|
components: COMPONENTS,
|
|
227
221
|
formData: DATA
|
|
228
222
|
};
|
|
229
|
-
|
|
223
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
230
224
|
expect(RESULT.length).toEqual(1);
|
|
231
225
|
expect(RESULT[0]).toEqual({
|
|
232
226
|
id: 'charlie',
|
|
233
227
|
error: 'Charlie is required'
|
|
234
228
|
});
|
|
235
229
|
});
|
|
236
|
-
it('should return an error for the invalid email field when none are required but all email types',
|
|
237
|
-
|
|
238
|
-
|
|
230
|
+
it('should return an error for the invalid email field when none are required but all email types', () => {
|
|
231
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', false)];
|
|
232
|
+
const PAGE = {
|
|
239
233
|
components: COMPONENTS,
|
|
240
234
|
formData: DATA
|
|
241
235
|
};
|
|
242
|
-
|
|
236
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
243
237
|
expect(RESULT.length).toEqual(1);
|
|
244
238
|
expect(RESULT[0]).toEqual({
|
|
245
239
|
id: 'bravo',
|
|
246
240
|
error: 'Enter bravo in the correct format, like jane.doe@homeoffice.gov.uk'
|
|
247
241
|
});
|
|
248
242
|
});
|
|
249
|
-
it('should return an error for both invalid fields when all are required and email types',
|
|
250
|
-
|
|
251
|
-
|
|
243
|
+
it('should return an error for both invalid fields when all are required and email types', () => {
|
|
244
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', true)];
|
|
245
|
+
const PAGE = {
|
|
252
246
|
components: COMPONENTS,
|
|
253
247
|
formData: DATA
|
|
254
248
|
};
|
|
255
|
-
|
|
249
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
256
250
|
expect(RESULT.length).toEqual(2);
|
|
257
251
|
expect(RESULT[0]).toEqual({
|
|
258
252
|
id: 'bravo',
|
|
@@ -263,20 +257,21 @@ describe('utils.Validate.Page', function () {
|
|
|
263
257
|
error: 'Charlie is required'
|
|
264
258
|
});
|
|
265
259
|
});
|
|
266
|
-
it('should return an interpolated error for both invalid fields when all are required and email types',
|
|
267
|
-
|
|
260
|
+
it('should return an interpolated error for both invalid fields when all are required and email types', () => {
|
|
261
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true),
|
|
268
262
|
// eslint-disable-next-line no-template-curly-in-string
|
|
269
263
|
setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo ${lion}', true),
|
|
270
264
|
// eslint-disable-next-line no-template-curly-in-string
|
|
271
265
|
setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie ${panther}', true)];
|
|
272
|
-
|
|
266
|
+
const PAGE = {
|
|
273
267
|
components: COMPONENTS,
|
|
274
|
-
formData:
|
|
268
|
+
formData: {
|
|
269
|
+
...DATA,
|
|
275
270
|
lion: 'Lion',
|
|
276
271
|
panther: 'Panther'
|
|
277
|
-
}
|
|
272
|
+
}
|
|
278
273
|
};
|
|
279
|
-
|
|
274
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
280
275
|
expect(RESULT.length).toEqual(2);
|
|
281
276
|
expect(RESULT[0]).toEqual({
|
|
282
277
|
id: 'bravo',
|
|
@@ -289,58 +284,60 @@ describe('utils.Validate.Page', function () {
|
|
|
289
284
|
});
|
|
290
285
|
});
|
|
291
286
|
});
|
|
292
|
-
describe('with CollectionPage',
|
|
293
|
-
|
|
287
|
+
describe('with CollectionPage', () => {
|
|
288
|
+
const COLLECTION = {
|
|
294
289
|
name: 'pageCollection'
|
|
295
290
|
};
|
|
296
|
-
describe('when the form data is fully valid',
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
291
|
+
describe('when the form data is fully valid', () => {
|
|
292
|
+
const DATA = {
|
|
293
|
+
["".concat(COLLECTION.name, "ActiveId")]: '01',
|
|
294
|
+
[COLLECTION.name]: [{
|
|
295
|
+
id: '01',
|
|
296
|
+
alpha: 'alpha.smith@digital.homeoffice.gov.uk',
|
|
297
|
+
bravo: 'bravo.jones@digital.homeoffice.gov.uk'
|
|
298
|
+
}]
|
|
299
|
+
};
|
|
300
|
+
it('should return no errors when none of the components are required or email types', () => {
|
|
301
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false)];
|
|
302
|
+
const PAGE = {
|
|
306
303
|
collection: COLLECTION,
|
|
307
304
|
components: COMPONENTS,
|
|
308
305
|
formData: DATA
|
|
309
306
|
};
|
|
310
307
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
311
308
|
});
|
|
312
|
-
it('should return no errors when all of the components are required but not email types',
|
|
313
|
-
|
|
314
|
-
|
|
309
|
+
it('should return no errors when all of the components are required but not email types', () => {
|
|
310
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true)];
|
|
311
|
+
const PAGE = {
|
|
315
312
|
collection: COLLECTION,
|
|
316
313
|
components: COMPONENTS,
|
|
317
314
|
formData: DATA
|
|
318
315
|
};
|
|
319
316
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
320
317
|
});
|
|
321
|
-
it('should return no errors when none of the components are required but are all email types',
|
|
322
|
-
|
|
323
|
-
|
|
318
|
+
it('should return no errors when none of the components are required but are all email types', () => {
|
|
319
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false)];
|
|
320
|
+
const PAGE = {
|
|
324
321
|
collection: COLLECTION,
|
|
325
322
|
components: COMPONENTS,
|
|
326
323
|
formData: DATA
|
|
327
324
|
};
|
|
328
325
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
329
326
|
});
|
|
330
|
-
it('should return no errors when all of the components are required and email types',
|
|
331
|
-
|
|
332
|
-
|
|
327
|
+
it('should return no errors when all of the components are required and email types', () => {
|
|
328
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true)];
|
|
329
|
+
const PAGE = {
|
|
333
330
|
collection: COLLECTION,
|
|
334
331
|
components: COMPONENTS,
|
|
335
332
|
formData: DATA
|
|
336
333
|
};
|
|
337
334
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
338
335
|
});
|
|
339
|
-
it('should return an error for each required component on a collection page with a show_when that is true',
|
|
340
|
-
|
|
336
|
+
it('should return an error for each required component on a collection page with a show_when that is true', () => {
|
|
337
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
341
338
|
// The only unrequired one
|
|
342
339
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
343
|
-
|
|
340
|
+
const PAGE = {
|
|
344
341
|
components: COMPONENTS,
|
|
345
342
|
collection: {
|
|
346
343
|
name: 'testCollection'
|
|
@@ -358,7 +355,7 @@ describe('utils.Validate.Page', function () {
|
|
|
358
355
|
}]
|
|
359
356
|
}
|
|
360
357
|
};
|
|
361
|
-
|
|
358
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
362
359
|
expect(RESULT.length).toEqual(4);
|
|
363
360
|
expect(RESULT).toEqual([{
|
|
364
361
|
id: 'a',
|
|
@@ -374,11 +371,11 @@ describe('utils.Validate.Page', function () {
|
|
|
374
371
|
error: 'Echo is required'
|
|
375
372
|
}]);
|
|
376
373
|
});
|
|
377
|
-
it('should return no errors on a collection page with a show_when that is false',
|
|
378
|
-
|
|
374
|
+
it('should return no errors on a collection page with a show_when that is false', () => {
|
|
375
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
379
376
|
// The only unrequired one
|
|
380
377
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
381
|
-
|
|
378
|
+
const PAGE = {
|
|
382
379
|
components: COMPONENTS,
|
|
383
380
|
collection: {
|
|
384
381
|
name: 'testCollection'
|
|
@@ -396,62 +393,64 @@ describe('utils.Validate.Page', function () {
|
|
|
396
393
|
}]
|
|
397
394
|
}
|
|
398
395
|
};
|
|
399
|
-
|
|
396
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
400
397
|
expect(RESULT.length).toEqual(0);
|
|
401
398
|
});
|
|
402
399
|
});
|
|
403
|
-
describe('when the form data has one field missing and includes an invalid email',
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
400
|
+
describe('when the form data has one field missing and includes an invalid email', () => {
|
|
401
|
+
const DATA = {
|
|
402
|
+
["".concat(COLLECTION.name, "ActiveId")]: '01',
|
|
403
|
+
[COLLECTION.name]: [{
|
|
404
|
+
id: '01',
|
|
405
|
+
alpha: 'alpha.smith@digital.homeoffice.gov.uk',
|
|
406
|
+
bravo: 'bravo.jones@hotmail.com'
|
|
407
|
+
}]
|
|
408
|
+
};
|
|
409
|
+
it('should return no errors when none of the components are required or email types', () => {
|
|
410
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', false)];
|
|
411
|
+
const PAGE = {
|
|
413
412
|
collection: COLLECTION,
|
|
414
413
|
components: COMPONENTS,
|
|
415
414
|
formData: null
|
|
416
415
|
};
|
|
417
416
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
418
417
|
});
|
|
419
|
-
it('should return an error for the missing field when all are required but not email types',
|
|
420
|
-
|
|
421
|
-
|
|
418
|
+
it('should return an error for the missing field when all are required but not email types', () => {
|
|
419
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', true)];
|
|
420
|
+
const PAGE = {
|
|
422
421
|
collection: COLLECTION,
|
|
423
422
|
components: COMPONENTS,
|
|
424
423
|
formData: DATA
|
|
425
424
|
};
|
|
426
|
-
|
|
425
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
427
426
|
expect(RESULT.length).toEqual(1);
|
|
428
427
|
expect(RESULT[0]).toEqual({
|
|
429
428
|
id: 'charlie',
|
|
430
429
|
error: 'Charlie is required'
|
|
431
430
|
});
|
|
432
431
|
});
|
|
433
|
-
it('should return an error for the invalid email field when none are required but all email types',
|
|
434
|
-
|
|
435
|
-
|
|
432
|
+
it('should return an error for the invalid email field when none are required but all email types', () => {
|
|
433
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', false)];
|
|
434
|
+
const PAGE = {
|
|
436
435
|
collection: COLLECTION,
|
|
437
436
|
components: COMPONENTS,
|
|
438
437
|
formData: DATA
|
|
439
438
|
};
|
|
440
|
-
|
|
439
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
441
440
|
expect(RESULT.length).toEqual(1);
|
|
442
441
|
expect(RESULT[0]).toEqual({
|
|
443
442
|
id: 'bravo',
|
|
444
443
|
error: 'Enter bravo in the correct format, like jane.doe@homeoffice.gov.uk'
|
|
445
444
|
});
|
|
446
445
|
});
|
|
447
|
-
it('should return an error for both invalid fields when all are required and email types',
|
|
448
|
-
|
|
449
|
-
|
|
446
|
+
it('should return an error for both invalid fields when all are required and email types', () => {
|
|
447
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', true)];
|
|
448
|
+
const PAGE = {
|
|
450
449
|
collection: COLLECTION,
|
|
451
450
|
components: COMPONENTS,
|
|
452
451
|
formData: DATA
|
|
453
452
|
};
|
|
454
|
-
|
|
453
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
455
454
|
expect(RESULT.length).toEqual(2);
|
|
456
455
|
expect(RESULT[0]).toEqual({
|
|
457
456
|
id: 'bravo',
|
|
@@ -462,21 +461,25 @@ describe('utils.Validate.Page', function () {
|
|
|
462
461
|
error: 'Charlie is required'
|
|
463
462
|
});
|
|
464
463
|
});
|
|
465
|
-
it('should return an interpolated error for both invalid fields when all are required and email types',
|
|
466
|
-
|
|
464
|
+
it('should return an interpolated error for both invalid fields when all are required and email types', () => {
|
|
465
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true),
|
|
467
466
|
// eslint-disable-next-line no-template-curly-in-string
|
|
468
467
|
setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo ${lion}', true),
|
|
469
468
|
// eslint-disable-next-line no-template-curly-in-string
|
|
470
469
|
setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie ${panther}', true)];
|
|
471
|
-
|
|
470
|
+
const PAGE = {
|
|
472
471
|
collection: COLLECTION,
|
|
473
472
|
components: COMPONENTS,
|
|
474
|
-
formData:
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
473
|
+
formData: {
|
|
474
|
+
...DATA,
|
|
475
|
+
[COLLECTION.name]: [{
|
|
476
|
+
...DATA[COLLECTION.name][0],
|
|
477
|
+
lion: 'Lion',
|
|
478
|
+
panther: 'Panther'
|
|
479
|
+
}]
|
|
480
|
+
}
|
|
478
481
|
};
|
|
479
|
-
|
|
482
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
480
483
|
expect(RESULT.length).toEqual(2);
|
|
481
484
|
expect(RESULT[0]).toEqual({
|
|
482
485
|
id: 'bravo',
|
|
@@ -489,12 +492,12 @@ describe('utils.Validate.Page', function () {
|
|
|
489
492
|
});
|
|
490
493
|
});
|
|
491
494
|
});
|
|
492
|
-
describe('with a nested CollectionPage',
|
|
493
|
-
|
|
495
|
+
describe('with a nested CollectionPage', () => {
|
|
496
|
+
const COLLECTION = {
|
|
494
497
|
name: 'parent.child'
|
|
495
498
|
};
|
|
496
|
-
describe('when the form data is fully valid',
|
|
497
|
-
|
|
499
|
+
describe('when the form data is fully valid', () => {
|
|
500
|
+
const DATA = {
|
|
498
501
|
parentActiveId: '01',
|
|
499
502
|
childActiveId: '01',
|
|
500
503
|
parent: [{
|
|
@@ -506,47 +509,47 @@ describe('utils.Validate.Page', function () {
|
|
|
506
509
|
}]
|
|
507
510
|
}]
|
|
508
511
|
};
|
|
509
|
-
it('should return no errors when none of the components are required or email types',
|
|
510
|
-
|
|
511
|
-
|
|
512
|
+
it('should return no errors when none of the components are required or email types', () => {
|
|
513
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false)];
|
|
514
|
+
const PAGE = {
|
|
512
515
|
collection: COLLECTION,
|
|
513
516
|
components: COMPONENTS,
|
|
514
517
|
formData: DATA
|
|
515
518
|
};
|
|
516
519
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
517
520
|
});
|
|
518
|
-
it('should return no errors when all of the components are required but not email types',
|
|
519
|
-
|
|
520
|
-
|
|
521
|
+
it('should return no errors when all of the components are required but not email types', () => {
|
|
522
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true)];
|
|
523
|
+
const PAGE = {
|
|
521
524
|
collection: COLLECTION,
|
|
522
525
|
components: COMPONENTS,
|
|
523
526
|
formData: DATA
|
|
524
527
|
};
|
|
525
528
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
526
529
|
});
|
|
527
|
-
it('should return no errors when none of the components are required but are all email types',
|
|
528
|
-
|
|
529
|
-
|
|
530
|
+
it('should return no errors when none of the components are required but are all email types', () => {
|
|
531
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false)];
|
|
532
|
+
const PAGE = {
|
|
530
533
|
collection: COLLECTION,
|
|
531
534
|
components: COMPONENTS,
|
|
532
535
|
formData: DATA
|
|
533
536
|
};
|
|
534
537
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
535
538
|
});
|
|
536
|
-
it('should return no errors when all of the components are required and email types',
|
|
537
|
-
|
|
538
|
-
|
|
539
|
+
it('should return no errors when all of the components are required and email types', () => {
|
|
540
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true)];
|
|
541
|
+
const PAGE = {
|
|
539
542
|
collection: COLLECTION,
|
|
540
543
|
components: COMPONENTS,
|
|
541
544
|
formData: DATA
|
|
542
545
|
};
|
|
543
546
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
544
547
|
});
|
|
545
|
-
it('should return an error for each required component on a collection page with a show_when that is true',
|
|
546
|
-
|
|
548
|
+
it('should return an error for each required component on a collection page with a show_when that is true', () => {
|
|
549
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
547
550
|
// The only unrequired one
|
|
548
551
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
549
|
-
|
|
552
|
+
const PAGE = {
|
|
550
553
|
components: COMPONENTS,
|
|
551
554
|
collection: {
|
|
552
555
|
name: 'parent.child'
|
|
@@ -568,7 +571,7 @@ describe('utils.Validate.Page', function () {
|
|
|
568
571
|
}]
|
|
569
572
|
}
|
|
570
573
|
};
|
|
571
|
-
|
|
574
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
572
575
|
expect(RESULT.length).toEqual(4);
|
|
573
576
|
expect(RESULT).toEqual([{
|
|
574
577
|
id: 'a',
|
|
@@ -584,11 +587,11 @@ describe('utils.Validate.Page', function () {
|
|
|
584
587
|
error: 'Echo is required'
|
|
585
588
|
}]);
|
|
586
589
|
});
|
|
587
|
-
it('should return no errors on a collection page with a show_when that is false',
|
|
588
|
-
|
|
590
|
+
it('should return no errors on a collection page with a show_when that is false', () => {
|
|
591
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
589
592
|
// The only unrequired one
|
|
590
593
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
591
|
-
|
|
594
|
+
const PAGE = {
|
|
592
595
|
components: COMPONENTS,
|
|
593
596
|
collection: {
|
|
594
597
|
name: 'parent.child'
|
|
@@ -610,12 +613,12 @@ describe('utils.Validate.Page', function () {
|
|
|
610
613
|
}]
|
|
611
614
|
}
|
|
612
615
|
};
|
|
613
|
-
|
|
616
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
614
617
|
expect(RESULT.length).toEqual(0);
|
|
615
618
|
});
|
|
616
619
|
});
|
|
617
|
-
describe('when the form data has one field missing and includes an invalid email',
|
|
618
|
-
|
|
620
|
+
describe('when the form data has one field missing and includes an invalid email', () => {
|
|
621
|
+
const DATA = {
|
|
619
622
|
parentActiveId: '01',
|
|
620
623
|
childActiveId: '01',
|
|
621
624
|
parent: [{
|
|
@@ -627,51 +630,51 @@ describe('utils.Validate.Page', function () {
|
|
|
627
630
|
}]
|
|
628
631
|
}]
|
|
629
632
|
};
|
|
630
|
-
it('should return no errors when none of the components are required or email types',
|
|
631
|
-
|
|
632
|
-
|
|
633
|
+
it('should return no errors when none of the components are required or email types', () => {
|
|
634
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', false)];
|
|
635
|
+
const PAGE = {
|
|
633
636
|
collection: COLLECTION,
|
|
634
637
|
components: COMPONENTS,
|
|
635
638
|
formData: null
|
|
636
639
|
};
|
|
637
640
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
638
641
|
});
|
|
639
|
-
it('should return an error for the missing field when all are required but not email types',
|
|
640
|
-
|
|
641
|
-
|
|
642
|
+
it('should return an error for the missing field when all are required but not email types', () => {
|
|
643
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', true)];
|
|
644
|
+
const PAGE = {
|
|
642
645
|
collection: COLLECTION,
|
|
643
646
|
components: COMPONENTS,
|
|
644
647
|
formData: DATA
|
|
645
648
|
};
|
|
646
|
-
|
|
649
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
647
650
|
expect(RESULT.length).toEqual(1);
|
|
648
651
|
expect(RESULT[0]).toEqual({
|
|
649
652
|
id: 'charlie',
|
|
650
653
|
error: 'Charlie is required'
|
|
651
654
|
});
|
|
652
655
|
});
|
|
653
|
-
it('should return an error for the invalid email field when none are required but all email types',
|
|
654
|
-
|
|
655
|
-
|
|
656
|
+
it('should return an error for the invalid email field when none are required but all email types', () => {
|
|
657
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', false)];
|
|
658
|
+
const PAGE = {
|
|
656
659
|
collection: COLLECTION,
|
|
657
660
|
components: COMPONENTS,
|
|
658
661
|
formData: DATA
|
|
659
662
|
};
|
|
660
|
-
|
|
663
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
661
664
|
expect(RESULT.length).toEqual(1);
|
|
662
665
|
expect(RESULT[0]).toEqual({
|
|
663
666
|
id: 'bravo',
|
|
664
667
|
error: 'Enter bravo in the correct format, like jane.doe@homeoffice.gov.uk'
|
|
665
668
|
});
|
|
666
669
|
});
|
|
667
|
-
it('should return an error for both invalid fields when all are required and email types',
|
|
668
|
-
|
|
669
|
-
|
|
670
|
+
it('should return an error for both invalid fields when all are required and email types', () => {
|
|
671
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', true)];
|
|
672
|
+
const PAGE = {
|
|
670
673
|
collection: COLLECTION,
|
|
671
674
|
components: COMPONENTS,
|
|
672
675
|
formData: DATA
|
|
673
676
|
};
|
|
674
|
-
|
|
677
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
675
678
|
expect(RESULT.length).toEqual(2);
|
|
676
679
|
expect(RESULT[0]).toEqual({
|
|
677
680
|
id: 'bravo',
|
|
@@ -682,13 +685,13 @@ describe('utils.Validate.Page', function () {
|
|
|
682
685
|
error: 'Charlie is required'
|
|
683
686
|
});
|
|
684
687
|
});
|
|
685
|
-
it('should return an interpolated error for both invalid fields when all are required and email types',
|
|
686
|
-
|
|
688
|
+
it('should return an interpolated error for both invalid fields when all are required and email types', () => {
|
|
689
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true),
|
|
687
690
|
// eslint-disable-next-line no-template-curly-in-string
|
|
688
691
|
setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo ${lion}', true),
|
|
689
692
|
// eslint-disable-next-line no-template-curly-in-string
|
|
690
693
|
setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie ${panther}', true)];
|
|
691
|
-
|
|
694
|
+
const PAGE = {
|
|
692
695
|
collection: COLLECTION,
|
|
693
696
|
components: COMPONENTS,
|
|
694
697
|
formData: {
|
|
@@ -706,7 +709,7 @@ describe('utils.Validate.Page', function () {
|
|
|
706
709
|
}]
|
|
707
710
|
}
|
|
708
711
|
};
|
|
709
|
-
|
|
712
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
710
713
|
expect(RESULT.length).toEqual(2);
|
|
711
714
|
expect(RESULT[0]).toEqual({
|
|
712
715
|
id: 'bravo',
|
|
@@ -719,72 +722,81 @@ describe('utils.Validate.Page', function () {
|
|
|
719
722
|
});
|
|
720
723
|
});
|
|
721
724
|
});
|
|
722
|
-
describe('when there are queued errors',
|
|
723
|
-
it('should return any errors queued for a component as well as errors found during validation',
|
|
724
|
-
|
|
725
|
-
|
|
725
|
+
describe('when there are queued errors', () => {
|
|
726
|
+
it('should return any errors queued for a component as well as errors found during validation', () => {
|
|
727
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true)];
|
|
728
|
+
const PAGE = {
|
|
726
729
|
components: COMPONENTS,
|
|
727
730
|
formData: null
|
|
728
731
|
};
|
|
729
|
-
|
|
732
|
+
const QUEUED_ERRORS = [{
|
|
730
733
|
id: 'a',
|
|
731
734
|
error: 'Error queued for Alpha 1'
|
|
732
735
|
}, {
|
|
733
736
|
id: 'a',
|
|
734
737
|
error: 'Error queued for Alpha 2'
|
|
735
738
|
}];
|
|
736
|
-
|
|
739
|
+
const RESULT = (0, _validatePage.default)(PAGE, QUEUED_ERRORS);
|
|
737
740
|
expect(RESULT.length).toEqual(3);
|
|
738
|
-
expect(RESULT[0]).toEqual(
|
|
739
|
-
|
|
741
|
+
expect(RESULT[0]).toEqual({
|
|
742
|
+
...QUEUED_ERRORS[0]
|
|
743
|
+
});
|
|
744
|
+
expect(RESULT[1]).toEqual({
|
|
745
|
+
...QUEUED_ERRORS[1]
|
|
746
|
+
});
|
|
740
747
|
expect(RESULT[2]).toEqual({
|
|
741
748
|
id: 'a',
|
|
742
749
|
error: 'Alpha is required'
|
|
743
750
|
});
|
|
744
751
|
});
|
|
745
|
-
it('should return any errors queued for a component even if no errors are found during validation',
|
|
746
|
-
|
|
747
|
-
|
|
752
|
+
it('should return any errors queued for a component even if no errors are found during validation', () => {
|
|
753
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true)];
|
|
754
|
+
const PAGE = {
|
|
748
755
|
components: COMPONENTS,
|
|
749
756
|
formData: {
|
|
750
757
|
a: 'Value'
|
|
751
758
|
}
|
|
752
759
|
};
|
|
753
|
-
|
|
760
|
+
const QUEUED_ERRORS = [{
|
|
754
761
|
id: 'a',
|
|
755
762
|
error: 'Error queued for Alpha 1'
|
|
756
763
|
}, {
|
|
757
764
|
id: 'a',
|
|
758
765
|
error: 'Error queued for Alpha 2'
|
|
759
766
|
}];
|
|
760
|
-
|
|
767
|
+
const RESULT = (0, _validatePage.default)(PAGE, QUEUED_ERRORS);
|
|
761
768
|
expect(RESULT.length).toEqual(2);
|
|
762
|
-
expect(RESULT[0]).toEqual(
|
|
763
|
-
|
|
769
|
+
expect(RESULT[0]).toEqual({
|
|
770
|
+
...QUEUED_ERRORS[0]
|
|
771
|
+
});
|
|
772
|
+
expect(RESULT[1]).toEqual({
|
|
773
|
+
...QUEUED_ERRORS[1]
|
|
774
|
+
});
|
|
764
775
|
});
|
|
765
|
-
it('should return any queued errors if the component is not shown',
|
|
766
|
-
|
|
776
|
+
it('should return any queued errors if the component is not shown', () => {
|
|
777
|
+
const COMPONENTS = [{
|
|
778
|
+
...setup('a', _models.ComponentTypes.TEXT, 'Alpha', true),
|
|
767
779
|
show_when: [{
|
|
768
780
|
field: 'b',
|
|
769
781
|
op: '=',
|
|
770
782
|
value: 'yes'
|
|
771
783
|
}]
|
|
772
|
-
}
|
|
773
|
-
|
|
784
|
+
}];
|
|
785
|
+
const PAGE = {
|
|
774
786
|
components: COMPONENTS,
|
|
775
787
|
formData: {
|
|
776
788
|
a: 'Value',
|
|
777
789
|
b: 'no'
|
|
778
790
|
}
|
|
779
791
|
};
|
|
780
|
-
|
|
792
|
+
const QUEUED_ERRORS = [{
|
|
781
793
|
id: 'a',
|
|
782
794
|
error: 'Error queued for Alpha 1'
|
|
783
795
|
}, {
|
|
784
796
|
id: 'a',
|
|
785
797
|
error: 'Error queued for Alpha 2'
|
|
786
798
|
}];
|
|
787
|
-
|
|
799
|
+
const RESULT = (0, _validatePage.default)(PAGE, QUEUED_ERRORS);
|
|
788
800
|
expect(RESULT.length).toEqual(0);
|
|
789
801
|
});
|
|
790
802
|
});
|