@ukhomeoffice/cop-react-form-renderer 5.45.1 → 5.45.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/dist/components/CheckYourAnswers/Answer.js +12 -12
- package/dist/components/CheckYourAnswers/Answer.test.js +92 -127
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +101 -131
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +464 -769
- package/dist/components/CollectionPage/CollectionPage.js +66 -58
- package/dist/components/CollectionPage/CollectionPage.test.js +300 -342
- package/dist/components/CollectionSummary/BannerStrip.js +12 -12
- package/dist/components/CollectionSummary/BannerStrip.test.js +63 -59
- package/dist/components/CollectionSummary/CollectionSummary.js +60 -75
- package/dist/components/CollectionSummary/CollectionSummary.test.js +102 -96
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/SummaryCard.js +93 -133
- package/dist/components/CollectionSummary/SummaryCard.test.js +902 -924
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +23 -29
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +61 -73
- package/dist/components/FormComponent/Collection.js +73 -107
- package/dist/components/FormComponent/Collection.test.js +809 -945
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +67 -70
- package/dist/components/FormComponent/FormComponent.test.js +284 -342
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +65 -80
- package/dist/components/FormPage/FormPage.test.js +127 -163
- package/dist/components/FormRenderer/FormRenderer.js +142 -178
- package/dist/components/FormRenderer/FormRenderer.test.js +730 -1115
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +9 -9
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +16 -20
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +17 -22
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +3 -5
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +5 -7
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -24
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +97 -91
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -73
- package/dist/components/FormRenderer/helpers/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +59 -51
- package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
- package/dist/components/FormRenderer/onPageAction.js +43 -39
- package/dist/components/FormRenderer/onPageAction.test.js +223 -206
- package/dist/components/FormRenderer/onTaskAction.js +9 -13
- package/dist/components/FormRenderer/onTaskAction.test.js +93 -88
- package/dist/components/PageActions/ActionButton.js +12 -15
- package/dist/components/PageActions/ActionButton.test.js +56 -78
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +86 -115
- package/dist/components/SummaryList/GroupAction.js +9 -17
- package/dist/components/SummaryList/GroupAction.test.js +37 -33
- package/dist/components/SummaryList/RowAction.js +11 -16
- package/dist/components/SummaryList/RowAction.test.js +37 -33
- package/dist/components/SummaryList/SummaryList.js +21 -26
- package/dist/components/SummaryList/SummaryList.test.js +143 -166
- package/dist/components/SummaryList/SummaryListHeadingRow.js +6 -4
- package/dist/components/SummaryList/SummaryListRow.js +6 -4
- package/dist/components/SummaryList/SummaryListTitleRow.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +19 -29
- package/dist/components/TaskList/Task.test.js +83 -76
- package/dist/components/TaskList/TaskList.js +45 -71
- package/dist/components/TaskList/TaskList.test.js +113 -111
- package/dist/components/TaskList/TaskState.js +7 -5
- package/dist/components/TaskList/TaskState.test.js +52 -45
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +58 -79
- package/dist/context/HooksContext/HooksContext.test.js +26 -35
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +32 -72
- package/dist/context/ValidationContext/ValidationContext.test.js +47 -59
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +9 -10
- package/dist/hooks/useAxios.js +14 -40
- package/dist/hooks/useGetRequest.js +61 -97
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +26 -39
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +13 -14
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +44 -38
- package/dist/models/TaskStates.js +30 -28
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +52 -54
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +15 -25
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +33 -35
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -31
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +42 -44
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +18 -24
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +15 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +33 -36
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +58 -60
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +79 -88
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +146 -124
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +25 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +103 -97
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +13 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +70 -76
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +24 -24
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +1 -1
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +9 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +27 -22
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +12 -16
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +29 -30
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +17 -17
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +17 -17
- package/dist/utils/Component/addShowWhen.js +4 -8
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +27 -32
- package/dist/utils/Component/cleanAttributes.js +10 -13
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +88 -94
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +18 -17
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +46 -59
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +39 -48
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +23 -33
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +20 -18
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +20 -25
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +9 -8
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +22 -26
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +57 -70
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +31 -38
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +20 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +9 -8
- package/dist/utils/Component/getDefaultValue.js +6 -8
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +22 -21
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +27 -29
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +7 -7
- package/dist/utils/Condition/meetsAllConditions.test.js +17 -17
- package/dist/utils/Condition/meetsCondition.js +14 -17
- package/dist/utils/Condition/meetsCondition.test.js +376 -376
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +13 -18
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +3 -5
- package/dist/utils/Container/getEditableComponents.test.js +43 -45
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +16 -20
- package/dist/utils/Container/setupNesting.test.js +27 -30
- package/dist/utils/Container/showContainer.js +3 -7
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +38 -48
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +18 -26
- package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +19 -25
- package/dist/utils/Data/getOptions.test.js +20 -20
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +84 -80
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/refDataToOptions.js +10 -13
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +13 -21
- package/dist/utils/Data/setupFormData.test.js +51 -50
- package/dist/utils/Data/setupRefDataUrlForComponent.js +20 -26
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +5 -9
- package/dist/utils/FormPage/applyConditionalProperties.test.js +15 -18
- package/dist/utils/FormPage/getFormPage.js +15 -16
- package/dist/utils/FormPage/getFormPage.test.js +47 -46
- package/dist/utils/FormPage/getFormPages.js +7 -12
- package/dist/utils/FormPage/getFormPages.test.js +20 -23
- package/dist/utils/FormPage/getPageActions.js +9 -15
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getPageTitle.js +2 -2
- package/dist/utils/FormPage/getPageTitle.test.js +22 -22
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +1 -1
- package/dist/utils/FormPage/showFormPage.js +3 -7
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +21 -28
- package/dist/utils/FormPage/useComponent.test.js +78 -79
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +5 -6
- package/dist/utils/Format/formatDataForComponent.test.js +50 -77
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +13 -15
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -23
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +28 -31
- package/dist/utils/Hub/index.js +1 -1
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +24 -16
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +14 -16
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +68 -34
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -46
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +22 -20
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +35 -36
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +21 -26
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +6 -6
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +7 -11
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -41
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +14 -16
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +28 -26
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +19 -25
- package/dist/utils/Validate/validateCollection.test.js +74 -66
- package/dist/utils/Validate/validateComponent.js +17 -15
- package/dist/utils/Validate/validateComponent.test.js +167 -146
- package/dist/utils/Validate/validateContainer.js +14 -19
- package/dist/utils/Validate/validateContainer.test.js +49 -45
- package/dist/utils/Validate/validateDate.js +11 -17
- package/dist/utils/Validate/validateDate.test.js +28 -29
- package/dist/utils/Validate/validateEmail.js +6 -8
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +17 -18
- package/dist/utils/Validate/validatePage.test.js +185 -182
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +7 -14
- package/dist/utils/Validate/validateTime.test.js +14 -14
- package/dist/utils/index.js +7 -9
- package/package.json +1 -1
|
@@ -1,30 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
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); }
|
|
4
3
|
var _react = require("@testing-library/react");
|
|
5
4
|
var _models = require("../../../models");
|
|
6
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
7
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
-
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; }
|
|
16
|
-
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; }
|
|
17
|
-
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; }
|
|
18
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
|
-
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); }
|
|
20
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
21
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } // Global imports
|
|
7
|
+
// Global imports
|
|
8
|
+
|
|
22
9
|
// Local imports
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
const ID = 'test-id';
|
|
13
|
+
const FIELD_ID = 'field-id';
|
|
14
|
+
const LABEL = 'label';
|
|
15
|
+
const COMPONENT = {
|
|
28
16
|
type: _models.ComponentTypes.CALCULATION,
|
|
29
17
|
id: ID,
|
|
30
18
|
fieldId: FIELD_ID,
|
|
@@ -35,11 +23,11 @@ describe('utils.Component.get', function () {
|
|
|
35
23
|
},
|
|
36
24
|
'data-testid': ID
|
|
37
25
|
};
|
|
38
|
-
|
|
39
|
-
afterAll(
|
|
26
|
+
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
27
|
+
afterAll(() => {
|
|
40
28
|
error.mockReset();
|
|
41
29
|
});
|
|
42
|
-
afterEach(
|
|
30
|
+
afterEach(() => {
|
|
43
31
|
error.mockClear();
|
|
44
32
|
});
|
|
45
33
|
|
|
@@ -127,36 +115,34 @@ describe('utils.Component.get', function () {
|
|
|
127
115
|
}
|
|
128
116
|
},
|
|
129
117
|
result: '266.67'
|
|
130
|
-
}].forEach(
|
|
118
|
+
}].forEach(test => {
|
|
131
119
|
// eslint-disable-next-line no-param-reassign
|
|
132
|
-
test.config.onChange =
|
|
133
|
-
|
|
120
|
+
test.config.onChange = _ref => {
|
|
121
|
+
let {
|
|
122
|
+
target
|
|
123
|
+
} = _ref;
|
|
134
124
|
COMPONENT.formData[target.name] = target.value;
|
|
135
125
|
};
|
|
136
|
-
it("should render 'calculation' component with formula to given calculated value: ".concat(test.result),
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return _context.stop();
|
|
157
|
-
}
|
|
158
|
-
}, _callee);
|
|
159
|
-
})));
|
|
126
|
+
it("should render 'calculation' component with formula to given calculated value: ".concat(test.result), async () => {
|
|
127
|
+
const {
|
|
128
|
+
container
|
|
129
|
+
} = (0, _react.render)((0, _getComponent.default)({
|
|
130
|
+
...COMPONENT,
|
|
131
|
+
...test.config
|
|
132
|
+
}));
|
|
133
|
+
const [formGroup, input] = (0, _react.getAllByTestId)(container, ID);
|
|
134
|
+
expect(formGroup.tagName).toEqual('DIV');
|
|
135
|
+
expect(formGroup.classList).toContain('govuk-form-group');
|
|
136
|
+
const label = formGroup.childNodes[0];
|
|
137
|
+
expect(label.tagName).toEqual('LABEL');
|
|
138
|
+
expect(label.classList).toContain('govuk-label');
|
|
139
|
+
expect(label.textContent).toContain(LABEL);
|
|
140
|
+
expect(formGroup.classList).toContain('govuk-form-group');
|
|
141
|
+
expect(input.tagName).toEqual('DIV');
|
|
142
|
+
expect(input.classList).toContain('hods-readonly');
|
|
143
|
+
expect(input.id).toEqual(ID);
|
|
144
|
+
expect("".concat(COMPONENT.formData[FIELD_ID])).toEqual(test.result);
|
|
145
|
+
});
|
|
160
146
|
});
|
|
161
147
|
|
|
162
148
|
/**
|
|
@@ -242,17 +228,18 @@ describe('utils.Component.get', function () {
|
|
|
242
228
|
}
|
|
243
229
|
},
|
|
244
230
|
error: 'Argument cannot have more than one reference'
|
|
245
|
-
}].forEach(
|
|
246
|
-
it("should return an appropriately rendered calculation component with message ".concat(test.result),
|
|
247
|
-
|
|
248
|
-
container
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
231
|
+
}].forEach(test => {
|
|
232
|
+
it("should return an appropriately rendered calculation component with message ".concat(test.result), () => {
|
|
233
|
+
const {
|
|
234
|
+
container
|
|
235
|
+
} = (0, _react.render)((0, _getComponent.default)({
|
|
236
|
+
...COMPONENT,
|
|
237
|
+
...test.config
|
|
238
|
+
}));
|
|
239
|
+
const [formGroup, input] = (0, _react.getAllByTestId)(container, ID);
|
|
253
240
|
expect(formGroup.tagName).toEqual('DIV');
|
|
254
241
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
255
|
-
|
|
242
|
+
const label = formGroup.childNodes[0];
|
|
256
243
|
expect(label.tagName).toEqual('LABEL');
|
|
257
244
|
expect(label.classList).toContain('govuk-label');
|
|
258
245
|
expect(label.textContent).toContain(LABEL);
|
|
@@ -5,30 +5,27 @@ var _models = require("../../../models");
|
|
|
5
5
|
var _setupTests = require("../../../setupTests");
|
|
6
6
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
8
|
+
// Global imports
|
|
9
|
+
|
|
14
10
|
// Local imports
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
|
|
12
|
+
describe('utils.Component.get', () => {
|
|
13
|
+
it('should return an appropriately rendered checkboxes component', () => {
|
|
14
|
+
const ID = 'test-id';
|
|
15
|
+
const FIELD_ID = 'field-id';
|
|
16
|
+
const LABEL = 'label';
|
|
17
|
+
const OPTIONS = [{
|
|
21
18
|
value: 'a',
|
|
22
19
|
label: 'Alpha'
|
|
23
20
|
}, {
|
|
24
21
|
value: 'b',
|
|
25
22
|
label: 'Bravo'
|
|
26
23
|
}];
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const ON_CHANGE_CALLS = [];
|
|
25
|
+
const ON_CHANGE = e => {
|
|
29
26
|
ON_CHANGE_CALLS.push(e.target);
|
|
30
27
|
};
|
|
31
|
-
|
|
28
|
+
const COMPONENT = {
|
|
32
29
|
type: _models.ComponentTypes.CHECKBOXES,
|
|
33
30
|
id: ID,
|
|
34
31
|
fieldId: FIELD_ID,
|
|
@@ -39,16 +36,14 @@ describe('utils.Component.get', function () {
|
|
|
39
36
|
onChange: ON_CHANGE,
|
|
40
37
|
'data-testid': ID
|
|
41
38
|
};
|
|
42
|
-
|
|
43
|
-
container
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
formGroup = _getAllByTestId2[0],
|
|
47
|
-
checkboxes = _getAllByTestId2[1];
|
|
39
|
+
const {
|
|
40
|
+
container
|
|
41
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
42
|
+
const [formGroup, checkboxes] = (0, _react.getAllByTestId)(container, ID);
|
|
48
43
|
expect(formGroup.tagName).toEqual('DIV');
|
|
49
44
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
50
|
-
|
|
51
|
-
formGroup.childNodes.forEach(
|
|
45
|
+
let label;
|
|
46
|
+
formGroup.childNodes.forEach(node => {
|
|
52
47
|
// Check if it's an element.
|
|
53
48
|
if (node instanceof Element) {
|
|
54
49
|
if (node.tagName === 'LABEL') {
|
|
@@ -62,22 +57,20 @@ describe('utils.Component.get', function () {
|
|
|
62
57
|
expect(checkboxes.tagName).toEqual('DIV');
|
|
63
58
|
expect(checkboxes.classList).toContain('govuk-checkboxes');
|
|
64
59
|
expect(checkboxes.childNodes.length).toEqual(OPTIONS.length);
|
|
65
|
-
|
|
66
|
-
OPTIONS.forEach(
|
|
67
|
-
|
|
60
|
+
const checkboxItems = [];
|
|
61
|
+
OPTIONS.forEach((_, index) => {
|
|
62
|
+
const checkbox = checkboxes.childNodes[index];
|
|
68
63
|
expect(checkbox instanceof Element).toBeTruthy();
|
|
69
64
|
if (checkbox instanceof Element) {
|
|
70
65
|
checkboxItems.push(checkbox);
|
|
71
66
|
}
|
|
72
67
|
});
|
|
73
68
|
expect(checkboxItems.length).toEqual(OPTIONS.length);
|
|
74
|
-
OPTIONS.forEach(
|
|
75
|
-
|
|
69
|
+
OPTIONS.forEach((option, index) => {
|
|
70
|
+
const checkbox = checkboxItems[index];
|
|
76
71
|
expect(checkbox.tagName).toEqual('DIV');
|
|
77
72
|
expect(checkbox.classList).toContain('govuk-checkboxes__item');
|
|
78
|
-
|
|
79
|
-
input = _checkbox$childNodes[0],
|
|
80
|
-
inputLabel = _checkbox$childNodes[1];
|
|
73
|
+
const [input, inputLabel] = checkbox.childNodes;
|
|
81
74
|
expect(input.tagName).toEqual('INPUT');
|
|
82
75
|
expect(input.type).toEqual('checkbox');
|
|
83
76
|
expect(inputLabel.textContent).toEqual(option.label);
|
|
@@ -101,16 +94,16 @@ describe('utils.Component.get', function () {
|
|
|
101
94
|
value: [OPTIONS[1].value]
|
|
102
95
|
});
|
|
103
96
|
});
|
|
104
|
-
it('should return an appropriately rendered checkboxes component with a nested component',
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
97
|
+
it('should return an appropriately rendered checkboxes component with a nested component', () => {
|
|
98
|
+
const ID = 'test-id';
|
|
99
|
+
const FIELD_ID = 'field-id';
|
|
100
|
+
const LABEL = 'label';
|
|
101
|
+
const NESTED = {
|
|
109
102
|
id: 'charle',
|
|
110
103
|
fieldId: 'charle',
|
|
111
104
|
type: 'text'
|
|
112
105
|
};
|
|
113
|
-
|
|
106
|
+
const OPTIONS = [{
|
|
114
107
|
value: 'a',
|
|
115
108
|
label: 'Alpha',
|
|
116
109
|
nested: [NESTED]
|
|
@@ -118,11 +111,11 @@ describe('utils.Component.get', function () {
|
|
|
118
111
|
value: 'b',
|
|
119
112
|
label: 'Bravo'
|
|
120
113
|
}];
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
const ON_CHANGE_CALLS = [];
|
|
115
|
+
const ON_CHANGE = e => {
|
|
123
116
|
ON_CHANGE_CALLS.push(e.target);
|
|
124
117
|
};
|
|
125
|
-
|
|
118
|
+
const COMPONENT = {
|
|
126
119
|
type: _models.ComponentTypes.CHECKBOXES,
|
|
127
120
|
id: ID,
|
|
128
121
|
fieldId: FIELD_ID,
|
|
@@ -134,16 +127,14 @@ describe('utils.Component.get', function () {
|
|
|
134
127
|
onChange: ON_CHANGE,
|
|
135
128
|
'data-testid': ID
|
|
136
129
|
};
|
|
137
|
-
|
|
138
|
-
container
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
formGroup = _getAllByTestId4[0],
|
|
142
|
-
checkboxes = _getAllByTestId4[1];
|
|
130
|
+
const {
|
|
131
|
+
container
|
|
132
|
+
} = (0, _setupTests.renderWithValidation)((0, _getComponent.default)(COMPONENT));
|
|
133
|
+
const [formGroup, checkboxes] = (0, _react.getAllByTestId)(container, ID);
|
|
143
134
|
expect(formGroup.tagName).toEqual('DIV');
|
|
144
135
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
145
|
-
|
|
146
|
-
formGroup.childNodes.forEach(
|
|
136
|
+
let label;
|
|
137
|
+
formGroup.childNodes.forEach(node => {
|
|
147
138
|
// Check if it's an element.
|
|
148
139
|
if (node instanceof Element) {
|
|
149
140
|
if (node.tagName === 'LABEL') {
|
|
@@ -4,23 +4,20 @@ var _react = require("@testing-library/react");
|
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
7
|
+
// Global imports
|
|
8
|
+
|
|
13
9
|
// Local imports
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered date component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const ON_CHANGE_CALLS = [];
|
|
17
|
+
const ON_CHANGE = e => {
|
|
21
18
|
ON_CHANGE_CALLS.push(e.target);
|
|
22
19
|
};
|
|
23
|
-
|
|
20
|
+
const COMPONENT = {
|
|
24
21
|
type: _models.ComponentTypes.DATE,
|
|
25
22
|
id: ID,
|
|
26
23
|
fieldId: FIELD_ID,
|
|
@@ -28,13 +25,11 @@ describe('utils.Component.get', function () {
|
|
|
28
25
|
onChange: ON_CHANGE,
|
|
29
26
|
'data-testid': ID
|
|
30
27
|
};
|
|
31
|
-
|
|
28
|
+
const checkDateField = (node, option) => {
|
|
32
29
|
expect(node.tagName).toEqual('DIV');
|
|
33
30
|
expect(node.classList).toContain('govuk-date-input__item');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
label = _group$childNodes[0],
|
|
37
|
-
input = _group$childNodes[1];
|
|
31
|
+
const group = node.childNodes[0]; // form group
|
|
32
|
+
const [label, input] = group.childNodes;
|
|
38
33
|
expect(label.tagName).toEqual('LABEL');
|
|
39
34
|
expect(label.classList).toContain('govuk-label');
|
|
40
35
|
expect(label.textContent).toEqual(option.label);
|
|
@@ -42,33 +37,28 @@ describe('utils.Component.get', function () {
|
|
|
42
37
|
expect(input.id).toEqual(option.id);
|
|
43
38
|
return input;
|
|
44
39
|
};
|
|
45
|
-
|
|
46
|
-
container
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
formGroup = _getAllByTestId2[0],
|
|
50
|
-
dateInput = _getAllByTestId2[1];
|
|
40
|
+
const {
|
|
41
|
+
container
|
|
42
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
43
|
+
const [formGroup, dateInput] = (0, _react.getAllByTestId)(container, ID);
|
|
51
44
|
expect(formGroup.tagName).toEqual('DIV');
|
|
52
45
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
53
|
-
|
|
46
|
+
const label = formGroup.childNodes[0];
|
|
54
47
|
expect(label.innerHTML).toContain(LABEL);
|
|
55
48
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
56
49
|
expect(dateInput.tagName).toEqual('DIV');
|
|
57
50
|
expect(dateInput.classList).toContain('govuk-date-input');
|
|
58
51
|
expect(dateInput.id).toEqual(ID);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
monthItem = _dateInput$childNodes[1],
|
|
62
|
-
yearItem = _dateInput$childNodes[2];
|
|
63
|
-
var dayInput = checkDateField(dayItem, {
|
|
52
|
+
const [dayItem, monthItem, yearItem] = dateInput.childNodes;
|
|
53
|
+
const dayInput = checkDateField(dayItem, {
|
|
64
54
|
id: "".concat(ID, "-day"),
|
|
65
55
|
label: 'Day'
|
|
66
56
|
});
|
|
67
|
-
|
|
57
|
+
const monthInput = checkDateField(monthItem, {
|
|
68
58
|
id: "".concat(ID, "-month"),
|
|
69
59
|
label: 'Month'
|
|
70
60
|
});
|
|
71
|
-
|
|
61
|
+
const yearInput = checkDateField(yearItem, {
|
|
72
62
|
id: "".concat(ID, "-year"),
|
|
73
63
|
label: 'Year'
|
|
74
64
|
});
|
|
@@ -8,40 +8,42 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
8
8
|
|
|
9
9
|
// Local imports
|
|
10
10
|
|
|
11
|
-
describe('utils.Component.get',
|
|
12
|
-
it('should return a details component containing basic text',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return a details component containing basic text', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const CONTENT = 'Details content';
|
|
15
|
+
const SUMMARY = 'Details Summary';
|
|
16
|
+
const COMPONENT = {
|
|
17
17
|
type: _models.ComponentTypes.DETAILS,
|
|
18
18
|
content: CONTENT,
|
|
19
19
|
summary: SUMMARY,
|
|
20
20
|
'data-testid': ID
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
container
|
|
24
|
-
|
|
22
|
+
const {
|
|
23
|
+
container
|
|
24
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
25
|
+
const details = container.querySelector('details');
|
|
25
26
|
expect(details.classList).toContain('hods-details');
|
|
26
27
|
expect(details.childNodes[0].textContent).toEqual(SUMMARY);
|
|
27
28
|
expect(details.childNodes[1].textContent).toEqual(CONTENT);
|
|
28
29
|
});
|
|
29
|
-
it('should return a details component containing multiple html components',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
it('should return a details component containing multiple html components', () => {
|
|
31
|
+
const ID = 'test-id';
|
|
32
|
+
const CONTENT = '<p>this is the content</p><ol><li>one</li><li>two</li></ol><p>second section of content</p>';
|
|
33
|
+
const SUMMARY = 'Details Summary';
|
|
34
|
+
const COMPONENT = {
|
|
34
35
|
type: _models.ComponentTypes.DETAILS,
|
|
35
36
|
content: CONTENT,
|
|
36
37
|
summary: SUMMARY,
|
|
37
38
|
tagName: 'div',
|
|
38
39
|
'data-testid': ID
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
-
container
|
|
42
|
-
|
|
41
|
+
const {
|
|
42
|
+
container
|
|
43
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
44
|
+
const details = container.querySelector('details');
|
|
43
45
|
expect(details.classList).toContain('hods-details');
|
|
44
|
-
|
|
46
|
+
const content = details.childNodes[1].childNodes[0].childNodes;
|
|
45
47
|
expect(content[0].textContent).toEqual('this is the content');
|
|
46
48
|
expect(content[0].tagName).toEqual('P');
|
|
47
49
|
expect(content[1].childNodes[0].textContent).toEqual('one');
|
|
@@ -4,23 +4,20 @@ var _react = require("@testing-library/react");
|
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
7
|
+
// Global imports
|
|
8
|
+
|
|
13
9
|
// Local imports
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered email component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const ON_CHANGE_CALLS = [];
|
|
17
|
+
const ON_CHANGE = e => {
|
|
21
18
|
ON_CHANGE_CALLS.push(e.target);
|
|
22
19
|
};
|
|
23
|
-
|
|
20
|
+
const COMPONENT = {
|
|
24
21
|
type: _models.ComponentTypes.EMAIL,
|
|
25
22
|
id: ID,
|
|
26
23
|
fieldId: FIELD_ID,
|
|
@@ -28,16 +25,14 @@ describe('utils.Component.get', function () {
|
|
|
28
25
|
onChange: ON_CHANGE,
|
|
29
26
|
'data-testid': ID
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
container
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
formGroup = _getAllByTestId2[0],
|
|
36
|
-
input = _getAllByTestId2[1];
|
|
28
|
+
const {
|
|
29
|
+
container
|
|
30
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
31
|
+
const [formGroup, input] = (0, _react.getAllByTestId)(container, ID);
|
|
37
32
|
expect(formGroup.tagName).toEqual('DIV');
|
|
38
33
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
39
|
-
|
|
40
|
-
formGroup.childNodes.forEach(
|
|
34
|
+
let label;
|
|
35
|
+
formGroup.childNodes.forEach(node => {
|
|
41
36
|
// Check if it's an element.
|
|
42
37
|
if (node instanceof Element && node.tagName === 'LABEL') {
|
|
43
38
|
label = node;
|
|
@@ -5,23 +5,20 @@ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
|
5
5
|
var _models = require("../../../models");
|
|
6
6
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
8
|
+
// Global imports
|
|
9
|
+
|
|
14
10
|
// Local imports
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
|
|
12
|
+
describe('utils.Component.get', () => {
|
|
13
|
+
it('should return an appropriately rendered file component', () => {
|
|
14
|
+
const ID = 'test-id';
|
|
15
|
+
const FIELD_ID = 'field-id';
|
|
16
|
+
const LABEL = 'label';
|
|
17
|
+
const ON_CHANGE_CALLS = [];
|
|
18
|
+
const ON_CHANGE = e => {
|
|
22
19
|
ON_CHANGE_CALLS.push(e.target);
|
|
23
20
|
};
|
|
24
|
-
|
|
21
|
+
const COMPONENT = {
|
|
25
22
|
type: _models.ComponentTypes.FILE,
|
|
26
23
|
id: ID,
|
|
27
24
|
fieldId: FIELD_ID,
|
|
@@ -29,16 +26,14 @@ describe('utils.Component.get', function () {
|
|
|
29
26
|
onChange: ON_CHANGE,
|
|
30
27
|
'data-testid': ID
|
|
31
28
|
};
|
|
32
|
-
|
|
33
|
-
container
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
formGroup = _getAllByTestId2[0],
|
|
37
|
-
input = _getAllByTestId2[1];
|
|
29
|
+
const {
|
|
30
|
+
container
|
|
31
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
32
|
+
const [formGroup, input] = (0, _react.getAllByTestId)(container, ID);
|
|
38
33
|
expect(formGroup.tagName).toEqual('DIV');
|
|
39
34
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
40
|
-
|
|
41
|
-
formGroup.childNodes.forEach(
|
|
35
|
+
let label;
|
|
36
|
+
formGroup.childNodes.forEach(node => {
|
|
42
37
|
// Check if it's an element.
|
|
43
38
|
if (node instanceof Element && node.tagName === 'LABEL') {
|
|
44
39
|
label = node;
|
|
@@ -50,11 +45,11 @@ describe('utils.Component.get', function () {
|
|
|
50
45
|
expect(input.tagName).toEqual('INPUT');
|
|
51
46
|
expect(input.classList).toContain('hods-file-upload__select');
|
|
52
47
|
expect(input.id).toEqual("".concat(ID, "-select"));
|
|
53
|
-
|
|
48
|
+
const str = JSON.stringify({
|
|
54
49
|
alpha: 'bravo'
|
|
55
50
|
});
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const blob = new Blob([str]);
|
|
52
|
+
const FILE = new File([blob], 'test.json', {
|
|
58
53
|
type: 'application/JSON'
|
|
59
54
|
});
|
|
60
55
|
_userEvent.default.upload(input, FILE);
|