@ukhomeoffice/cop-react-form-renderer 6.14.0 → 6.14.2-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/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 +72 -63
- package/dist/utils/Data/getAutocompleteSource.test.js +106 -98
- 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,56 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
4
|
var _validatePage = _interopRequireDefault(require("./validatePage"));
|
|
5
|
-
function _interopRequireDefault(
|
|
6
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
-
function _defineProperty(
|
|
10
|
-
function _toPropertyKey(
|
|
11
|
-
function _toPrimitive(
|
|
12
|
-
describe('utils.Validate.Page',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
it('should return no error when the components array is null', function () {
|
|
24
|
-
var PAGE = {
|
|
8
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Local imports
|
|
11
|
+
describe('utils.Validate.Page', () => {
|
|
12
|
+
const setup = (id, type, label, required) => ({
|
|
13
|
+
id,
|
|
14
|
+
fieldId: id,
|
|
15
|
+
type,
|
|
16
|
+
label,
|
|
17
|
+
required
|
|
18
|
+
});
|
|
19
|
+
describe('with FormPage', () => {
|
|
20
|
+
it('should return no error when the components array is null', () => {
|
|
21
|
+
const PAGE = {
|
|
25
22
|
components: null,
|
|
26
23
|
formData: null
|
|
27
24
|
};
|
|
28
25
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
29
26
|
});
|
|
30
|
-
it('should return no error when the components array is empty',
|
|
31
|
-
|
|
27
|
+
it('should return no error when the components array is empty', () => {
|
|
28
|
+
const PAGE = {
|
|
32
29
|
components: [],
|
|
33
30
|
formData: null
|
|
34
31
|
};
|
|
35
32
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
36
33
|
});
|
|
37
|
-
describe('when there is no form data',
|
|
38
|
-
it('should return no errors when no components are required',
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
describe('when there is no form data', () => {
|
|
35
|
+
it('should return no errors when no components are required', () => {
|
|
36
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', false), setup('b', _models.ComponentTypes.TEXT, 'Bravo', false)];
|
|
37
|
+
const PAGE = {
|
|
41
38
|
components: COMPONENTS,
|
|
42
39
|
formData: null
|
|
43
40
|
};
|
|
44
41
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
45
42
|
});
|
|
46
|
-
it('should return an error for each required component',
|
|
47
|
-
|
|
43
|
+
it('should return an error for each required component', () => {
|
|
44
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
48
45
|
// The only unrequired one
|
|
49
46
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
50
|
-
|
|
47
|
+
const PAGE = {
|
|
51
48
|
components: COMPONENTS,
|
|
52
49
|
formData: null
|
|
53
50
|
};
|
|
54
|
-
|
|
51
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
55
52
|
expect(RESULT.length).toEqual(4);
|
|
56
53
|
expect(RESULT[0]).toEqual({
|
|
57
54
|
id: 'a',
|
|
@@ -70,18 +67,18 @@ describe('utils.Validate.Page', function () {
|
|
|
70
67
|
error: 'Echo is required'
|
|
71
68
|
});
|
|
72
69
|
});
|
|
73
|
-
it('should return an error for each required component on a collection page',
|
|
74
|
-
|
|
70
|
+
it('should return an error for each required component on a collection page', () => {
|
|
71
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
75
72
|
// The only unrequired one
|
|
76
73
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
77
|
-
|
|
74
|
+
const PAGE = {
|
|
78
75
|
components: COMPONENTS,
|
|
79
76
|
collection: {
|
|
80
77
|
name: 'testCollection'
|
|
81
78
|
},
|
|
82
79
|
formData: null
|
|
83
80
|
};
|
|
84
|
-
|
|
81
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
85
82
|
expect(RESULT.length).toEqual(4);
|
|
86
83
|
expect(RESULT[0]).toEqual({
|
|
87
84
|
id: 'a',
|
|
@@ -100,18 +97,18 @@ describe('utils.Validate.Page', function () {
|
|
|
100
97
|
error: 'Echo is required'
|
|
101
98
|
});
|
|
102
99
|
});
|
|
103
|
-
it('should return an error for each required component on a nested collection page',
|
|
104
|
-
|
|
100
|
+
it('should return an error for each required component on a nested collection page', () => {
|
|
101
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
105
102
|
// The only unrequired one
|
|
106
103
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
107
|
-
|
|
104
|
+
const PAGE = {
|
|
108
105
|
components: COMPONENTS,
|
|
109
106
|
collection: {
|
|
110
107
|
name: 'parent.child'
|
|
111
108
|
},
|
|
112
109
|
formData: null
|
|
113
110
|
};
|
|
114
|
-
|
|
111
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
115
112
|
expect(RESULT.length).toEqual(4);
|
|
116
113
|
expect(RESULT).toEqual([{
|
|
117
114
|
id: 'a',
|
|
@@ -127,8 +124,8 @@ describe('utils.Validate.Page', function () {
|
|
|
127
124
|
error: 'Echo is required'
|
|
128
125
|
}]);
|
|
129
126
|
});
|
|
130
|
-
it('should return an error for each required component with interpolated label',
|
|
131
|
-
|
|
127
|
+
it('should return an error for each required component with interpolated label', () => {
|
|
128
|
+
const COMPONENTS = [
|
|
132
129
|
// eslint-disable-next-line no-template-curly-in-string
|
|
133
130
|
setup('a', _models.ComponentTypes.TEXT, 'Alpha ${tiger}', true),
|
|
134
131
|
// eslint-disable-next-line no-template-curly-in-string
|
|
@@ -139,7 +136,7 @@ describe('utils.Validate.Page', function () {
|
|
|
139
136
|
setup('d', _models.ComponentTypes.CHECKBOXES, 'Delta ${lion}', true),
|
|
140
137
|
// eslint-disable-next-line no-template-curly-in-string
|
|
141
138
|
setup('e', _models.ComponentTypes.FILE, 'Echo ${zoo}', true)];
|
|
142
|
-
|
|
139
|
+
const PAGE = {
|
|
143
140
|
components: COMPONENTS,
|
|
144
141
|
formData: {
|
|
145
142
|
tiger: 'Tiger',
|
|
@@ -149,7 +146,7 @@ describe('utils.Validate.Page', function () {
|
|
|
149
146
|
zoo: 'Zoo'
|
|
150
147
|
}
|
|
151
148
|
};
|
|
152
|
-
|
|
149
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
153
150
|
expect(RESULT.length).toEqual(5);
|
|
154
151
|
expect(RESULT).toEqual([{
|
|
155
152
|
id: 'a',
|
|
@@ -169,90 +166,90 @@ describe('utils.Validate.Page', function () {
|
|
|
169
166
|
}]);
|
|
170
167
|
});
|
|
171
168
|
});
|
|
172
|
-
describe('when the form data is fully valid',
|
|
173
|
-
|
|
169
|
+
describe('when the form data is fully valid', () => {
|
|
170
|
+
const DATA = {
|
|
174
171
|
alpha: 'alpha.smith@digital.homeoffice.gov.uk',
|
|
175
172
|
bravo: 'bravo.jones@digital.homeoffice.gov.uk'
|
|
176
173
|
};
|
|
177
|
-
it('should return no errors when none of the components are required or email types',
|
|
178
|
-
|
|
179
|
-
|
|
174
|
+
it('should return no errors when none of the components are required or email types', () => {
|
|
175
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false)];
|
|
176
|
+
const PAGE = {
|
|
180
177
|
components: COMPONENTS,
|
|
181
178
|
formData: DATA
|
|
182
179
|
};
|
|
183
180
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
184
181
|
});
|
|
185
|
-
it('should return no errors when all of the components are required but not email types',
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
it('should return no errors when all of the components are required but not email types', () => {
|
|
183
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true)];
|
|
184
|
+
const PAGE = {
|
|
188
185
|
components: COMPONENTS,
|
|
189
186
|
formData: DATA
|
|
190
187
|
};
|
|
191
188
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
192
189
|
});
|
|
193
|
-
it('should return no errors when none of the components are required but are all email types',
|
|
194
|
-
|
|
195
|
-
|
|
190
|
+
it('should return no errors when none of the components are required but are all email types', () => {
|
|
191
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false)];
|
|
192
|
+
const PAGE = {
|
|
196
193
|
components: COMPONENTS,
|
|
197
194
|
formData: DATA
|
|
198
195
|
};
|
|
199
196
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
200
197
|
});
|
|
201
|
-
it('should return no errors when all of the components are required and email types',
|
|
202
|
-
|
|
203
|
-
|
|
198
|
+
it('should return no errors when all of the components are required and email types', () => {
|
|
199
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true)];
|
|
200
|
+
const PAGE = {
|
|
204
201
|
components: COMPONENTS,
|
|
205
202
|
formData: DATA
|
|
206
203
|
};
|
|
207
204
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
208
205
|
});
|
|
209
206
|
});
|
|
210
|
-
describe('when the form data has one field missing and includes an invalid email',
|
|
211
|
-
|
|
207
|
+
describe('when the form data has one field missing and includes an invalid email', () => {
|
|
208
|
+
const DATA = {
|
|
212
209
|
alpha: 'alpha.smith@digital.homeoffice.gov.uk',
|
|
213
210
|
bravo: 'bravo.jones@hotmail.com'
|
|
214
211
|
};
|
|
215
|
-
it('should return no errors when none of the components are required or email types',
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
it('should return no errors when none of the components are required or email types', () => {
|
|
213
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', false)];
|
|
214
|
+
const PAGE = {
|
|
218
215
|
components: COMPONENTS,
|
|
219
216
|
formData: null
|
|
220
217
|
};
|
|
221
218
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
222
219
|
});
|
|
223
|
-
it('should return an error for the missing field when all are required but not email types',
|
|
224
|
-
|
|
225
|
-
|
|
220
|
+
it('should return an error for the missing field when all are required but not email types', () => {
|
|
221
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', true)];
|
|
222
|
+
const PAGE = {
|
|
226
223
|
components: COMPONENTS,
|
|
227
224
|
formData: DATA
|
|
228
225
|
};
|
|
229
|
-
|
|
226
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
230
227
|
expect(RESULT.length).toEqual(1);
|
|
231
228
|
expect(RESULT[0]).toEqual({
|
|
232
229
|
id: 'charlie',
|
|
233
230
|
error: 'Charlie is required'
|
|
234
231
|
});
|
|
235
232
|
});
|
|
236
|
-
it('should return an error for the invalid email field when none are required but all email types',
|
|
237
|
-
|
|
238
|
-
|
|
233
|
+
it('should return an error for the invalid email field when none are required but all email types', () => {
|
|
234
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', false)];
|
|
235
|
+
const PAGE = {
|
|
239
236
|
components: COMPONENTS,
|
|
240
237
|
formData: DATA
|
|
241
238
|
};
|
|
242
|
-
|
|
239
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
243
240
|
expect(RESULT.length).toEqual(1);
|
|
244
241
|
expect(RESULT[0]).toEqual({
|
|
245
242
|
id: 'bravo',
|
|
246
243
|
error: 'Enter bravo in the correct format, like jane.doe@homeoffice.gov.uk'
|
|
247
244
|
});
|
|
248
245
|
});
|
|
249
|
-
it('should return an error for both invalid fields when all are required and email types',
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
it('should return an error for both invalid fields when all are required and email types', () => {
|
|
247
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', true)];
|
|
248
|
+
const PAGE = {
|
|
252
249
|
components: COMPONENTS,
|
|
253
250
|
formData: DATA
|
|
254
251
|
};
|
|
255
|
-
|
|
252
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
256
253
|
expect(RESULT.length).toEqual(2);
|
|
257
254
|
expect(RESULT[0]).toEqual({
|
|
258
255
|
id: 'bravo',
|
|
@@ -263,20 +260,20 @@ describe('utils.Validate.Page', function () {
|
|
|
263
260
|
error: 'Charlie is required'
|
|
264
261
|
});
|
|
265
262
|
});
|
|
266
|
-
it('should return an interpolated error for both invalid fields when all are required and email types',
|
|
267
|
-
|
|
263
|
+
it('should return an interpolated error for both invalid fields when all are required and email types', () => {
|
|
264
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true),
|
|
268
265
|
// eslint-disable-next-line no-template-curly-in-string
|
|
269
266
|
setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo ${lion}', true),
|
|
270
267
|
// eslint-disable-next-line no-template-curly-in-string
|
|
271
268
|
setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie ${panther}', true)];
|
|
272
|
-
|
|
269
|
+
const PAGE = {
|
|
273
270
|
components: COMPONENTS,
|
|
274
271
|
formData: _objectSpread(_objectSpread({}, DATA), {}, {
|
|
275
272
|
lion: 'Lion',
|
|
276
273
|
panther: 'Panther'
|
|
277
274
|
})
|
|
278
275
|
};
|
|
279
|
-
|
|
276
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
280
277
|
expect(RESULT.length).toEqual(2);
|
|
281
278
|
expect(RESULT[0]).toEqual({
|
|
282
279
|
id: 'bravo',
|
|
@@ -289,58 +286,60 @@ describe('utils.Validate.Page', function () {
|
|
|
289
286
|
});
|
|
290
287
|
});
|
|
291
288
|
});
|
|
292
|
-
describe('with CollectionPage',
|
|
293
|
-
|
|
289
|
+
describe('with CollectionPage', () => {
|
|
290
|
+
const COLLECTION = {
|
|
294
291
|
name: 'pageCollection'
|
|
295
292
|
};
|
|
296
|
-
describe('when the form data is fully valid',
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
293
|
+
describe('when the form data is fully valid', () => {
|
|
294
|
+
const DATA = {
|
|
295
|
+
["".concat(COLLECTION.name, "ActiveId")]: '01',
|
|
296
|
+
[COLLECTION.name]: [{
|
|
297
|
+
id: '01',
|
|
298
|
+
alpha: 'alpha.smith@digital.homeoffice.gov.uk',
|
|
299
|
+
bravo: 'bravo.jones@digital.homeoffice.gov.uk'
|
|
300
|
+
}]
|
|
301
|
+
};
|
|
302
|
+
it('should return no errors when none of the components are required or email types', () => {
|
|
303
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false)];
|
|
304
|
+
const PAGE = {
|
|
306
305
|
collection: COLLECTION,
|
|
307
306
|
components: COMPONENTS,
|
|
308
307
|
formData: DATA
|
|
309
308
|
};
|
|
310
309
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
311
310
|
});
|
|
312
|
-
it('should return no errors when all of the components are required but not email types',
|
|
313
|
-
|
|
314
|
-
|
|
311
|
+
it('should return no errors when all of the components are required but not email types', () => {
|
|
312
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true)];
|
|
313
|
+
const PAGE = {
|
|
315
314
|
collection: COLLECTION,
|
|
316
315
|
components: COMPONENTS,
|
|
317
316
|
formData: DATA
|
|
318
317
|
};
|
|
319
318
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
320
319
|
});
|
|
321
|
-
it('should return no errors when none of the components are required but are all email types',
|
|
322
|
-
|
|
323
|
-
|
|
320
|
+
it('should return no errors when none of the components are required but are all email types', () => {
|
|
321
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false)];
|
|
322
|
+
const PAGE = {
|
|
324
323
|
collection: COLLECTION,
|
|
325
324
|
components: COMPONENTS,
|
|
326
325
|
formData: DATA
|
|
327
326
|
};
|
|
328
327
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
329
328
|
});
|
|
330
|
-
it('should return no errors when all of the components are required and email types',
|
|
331
|
-
|
|
332
|
-
|
|
329
|
+
it('should return no errors when all of the components are required and email types', () => {
|
|
330
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true)];
|
|
331
|
+
const PAGE = {
|
|
333
332
|
collection: COLLECTION,
|
|
334
333
|
components: COMPONENTS,
|
|
335
334
|
formData: DATA
|
|
336
335
|
};
|
|
337
336
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
338
337
|
});
|
|
339
|
-
it('should return an error for each required component on a collection page with a show_when that is true',
|
|
340
|
-
|
|
338
|
+
it('should return an error for each required component on a collection page with a show_when that is true', () => {
|
|
339
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
341
340
|
// The only unrequired one
|
|
342
341
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
343
|
-
|
|
342
|
+
const PAGE = {
|
|
344
343
|
components: COMPONENTS,
|
|
345
344
|
collection: {
|
|
346
345
|
name: 'testCollection'
|
|
@@ -358,7 +357,7 @@ describe('utils.Validate.Page', function () {
|
|
|
358
357
|
}]
|
|
359
358
|
}
|
|
360
359
|
};
|
|
361
|
-
|
|
360
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
362
361
|
expect(RESULT.length).toEqual(4);
|
|
363
362
|
expect(RESULT).toEqual([{
|
|
364
363
|
id: 'a',
|
|
@@ -374,11 +373,11 @@ describe('utils.Validate.Page', function () {
|
|
|
374
373
|
error: 'Echo is required'
|
|
375
374
|
}]);
|
|
376
375
|
});
|
|
377
|
-
it('should return no errors on a collection page with a show_when that is false',
|
|
378
|
-
|
|
376
|
+
it('should return no errors on a collection page with a show_when that is false', () => {
|
|
377
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false),
|
|
379
378
|
// The only unrequired one
|
|
380
379
|
setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
|
|
381
|
-
|
|
380
|
+
const PAGE = {
|
|
382
381
|
components: COMPONENTS,
|
|
383
382
|
collection: {
|
|
384
383
|
name: 'testCollection'
|
|
@@ -396,62 +395,64 @@ describe('utils.Validate.Page', function () {
|
|
|
396
395
|
}]
|
|
397
396
|
}
|
|
398
397
|
};
|
|
399
|
-
|
|
398
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
400
399
|
expect(RESULT.length).toEqual(0);
|
|
401
400
|
});
|
|
402
401
|
});
|
|
403
|
-
describe('when the form data has one field missing and includes an invalid email',
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
402
|
+
describe('when the form data has one field missing and includes an invalid email', () => {
|
|
403
|
+
const DATA = {
|
|
404
|
+
["".concat(COLLECTION.name, "ActiveId")]: '01',
|
|
405
|
+
[COLLECTION.name]: [{
|
|
406
|
+
id: '01',
|
|
407
|
+
alpha: 'alpha.smith@digital.homeoffice.gov.uk',
|
|
408
|
+
bravo: 'bravo.jones@hotmail.com'
|
|
409
|
+
}]
|
|
410
|
+
};
|
|
411
|
+
it('should return no errors when none of the components are required or email types', () => {
|
|
412
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', false)];
|
|
413
|
+
const PAGE = {
|
|
413
414
|
collection: COLLECTION,
|
|
414
415
|
components: COMPONENTS,
|
|
415
416
|
formData: null
|
|
416
417
|
};
|
|
417
418
|
expect((0, _validatePage.default)(PAGE).length).toEqual(0);
|
|
418
419
|
});
|
|
419
|
-
it('should return an error for the missing field when all are required but not email types',
|
|
420
|
-
|
|
421
|
-
|
|
420
|
+
it('should return an error for the missing field when all are required but not email types', () => {
|
|
421
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', true)];
|
|
422
|
+
const PAGE = {
|
|
422
423
|
collection: COLLECTION,
|
|
423
424
|
components: COMPONENTS,
|
|
424
425
|
formData: DATA
|
|
425
426
|
};
|
|
426
|
-
|
|
427
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
427
428
|
expect(RESULT.length).toEqual(1);
|
|
428
429
|
expect(RESULT[0]).toEqual({
|
|
429
430
|
id: 'charlie',
|
|
430
431
|
error: 'Charlie is required'
|
|
431
432
|
});
|
|
432
433
|
});
|
|
433
|
-
it('should return an error for the invalid email field when none are required but all email types',
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
it('should return an error for the invalid email field when none are required but all email types', () => {
|
|
435
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', false)];
|
|
436
|
+
const PAGE = {
|
|
436
437
|
collection: COLLECTION,
|
|
437
438
|
components: COMPONENTS,
|
|
438
439
|
formData: DATA
|
|
439
440
|
};
|
|
440
|
-
|
|
441
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
441
442
|
expect(RESULT.length).toEqual(1);
|
|
442
443
|
expect(RESULT[0]).toEqual({
|
|
443
444
|
id: 'bravo',
|
|
444
445
|
error: 'Enter bravo in the correct format, like jane.doe@homeoffice.gov.uk'
|
|
445
446
|
});
|
|
446
447
|
});
|
|
447
|
-
it('should return an error for both invalid fields when all are required and email types',
|
|
448
|
-
|
|
449
|
-
|
|
448
|
+
it('should return an error for both invalid fields when all are required and email types', () => {
|
|
449
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', true)];
|
|
450
|
+
const PAGE = {
|
|
450
451
|
collection: COLLECTION,
|
|
451
452
|
components: COMPONENTS,
|
|
452
453
|
formData: DATA
|
|
453
454
|
};
|
|
454
|
-
|
|
455
|
+
const RESULT = (0, _validatePage.default)(PAGE);
|
|
455
456
|
expect(RESULT.length).toEqual(2);
|
|
456
457
|
expect(RESULT[0]).toEqual({
|
|
457
458
|
id: 'bravo',
|
|
@@ -462,21 +463,23 @@ describe('utils.Validate.Page', function () {
|
|
|
462
463
|
error: 'Charlie is required'
|
|
463
464
|
});
|
|
464
465
|
});
|
|
465
|
-
it('should return an interpolated error for both invalid fields when all are required and email types',
|
|
466
|
-
|
|
466
|
+
it('should return an interpolated error for both invalid fields when all are required and email types', () => {
|
|
467
|
+
const COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true),
|
|
467
468
|
// eslint-disable-next-line no-template-curly-in-string
|
|
468
469
|
setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo ${lion}', true),
|
|
469
470
|
// eslint-disable-next-line no-template-curly-in-string
|
|
470
471
|
setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie ${panther}', true)];
|
|
471
|
-
|
|
472
|
+
const PAGE = {
|
|
472
473
|
collection: COLLECTION,
|
|
473
474
|
components: COMPONENTS,
|
|
474
|
-
formData: _objectSpread(_objectSpread({}, DATA), {},
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
475
|
+
formData: _objectSpread(_objectSpread({}, DATA), {}, {
|
|
476
|
+
[COLLECTION.name]: [_objectSpread(_objectSpread({}, 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,21 +722,21 @@ 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
741
|
expect(RESULT[0]).toEqual(_objectSpread({}, QUEUED_ERRORS[0]));
|
|
739
742
|
expect(RESULT[1]).toEqual(_objectSpread({}, QUEUED_ERRORS[1]));
|
|
@@ -742,49 +745,49 @@ describe('utils.Validate.Page', function () {
|
|
|
742
745
|
error: 'Alpha is required'
|
|
743
746
|
});
|
|
744
747
|
});
|
|
745
|
-
it('should return any errors queued for a component even if no errors are found during validation',
|
|
746
|
-
|
|
747
|
-
|
|
748
|
+
it('should return any errors queued for a component even if no errors are found during validation', () => {
|
|
749
|
+
const COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true)];
|
|
750
|
+
const PAGE = {
|
|
748
751
|
components: COMPONENTS,
|
|
749
752
|
formData: {
|
|
750
753
|
a: 'Value'
|
|
751
754
|
}
|
|
752
755
|
};
|
|
753
|
-
|
|
756
|
+
const QUEUED_ERRORS = [{
|
|
754
757
|
id: 'a',
|
|
755
758
|
error: 'Error queued for Alpha 1'
|
|
756
759
|
}, {
|
|
757
760
|
id: 'a',
|
|
758
761
|
error: 'Error queued for Alpha 2'
|
|
759
762
|
}];
|
|
760
|
-
|
|
763
|
+
const RESULT = (0, _validatePage.default)(PAGE, QUEUED_ERRORS);
|
|
761
764
|
expect(RESULT.length).toEqual(2);
|
|
762
765
|
expect(RESULT[0]).toEqual(_objectSpread({}, QUEUED_ERRORS[0]));
|
|
763
766
|
expect(RESULT[1]).toEqual(_objectSpread({}, QUEUED_ERRORS[1]));
|
|
764
767
|
});
|
|
765
|
-
it('should return any queued errors if the component is not shown',
|
|
766
|
-
|
|
768
|
+
it('should return any queued errors if the component is not shown', () => {
|
|
769
|
+
const COMPONENTS = [_objectSpread(_objectSpread({}, setup('a', _models.ComponentTypes.TEXT, 'Alpha', true)), {}, {
|
|
767
770
|
show_when: [{
|
|
768
771
|
field: 'b',
|
|
769
772
|
op: '=',
|
|
770
773
|
value: 'yes'
|
|
771
774
|
}]
|
|
772
775
|
})];
|
|
773
|
-
|
|
776
|
+
const PAGE = {
|
|
774
777
|
components: COMPONENTS,
|
|
775
778
|
formData: {
|
|
776
779
|
a: 'Value',
|
|
777
780
|
b: 'no'
|
|
778
781
|
}
|
|
779
782
|
};
|
|
780
|
-
|
|
783
|
+
const QUEUED_ERRORS = [{
|
|
781
784
|
id: 'a',
|
|
782
785
|
error: 'Error queued for Alpha 1'
|
|
783
786
|
}, {
|
|
784
787
|
id: 'a',
|
|
785
788
|
error: 'Error queued for Alpha 2'
|
|
786
789
|
}];
|
|
787
|
-
|
|
790
|
+
const RESULT = (0, _validatePage.default)(PAGE, QUEUED_ERRORS);
|
|
788
791
|
expect(RESULT.length).toEqual(0);
|
|
789
792
|
});
|
|
790
793
|
});
|