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