@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
|
@@ -8,34 +8,36 @@ 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 p tag and correct className for a paragraph component',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return a p tag and correct className for a paragraph component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const CONTENT = 'paragraph content';
|
|
15
|
+
const COMPONENT = {
|
|
16
16
|
type: _models.ComponentTypes.PARAGRAPH,
|
|
17
17
|
content: CONTENT,
|
|
18
18
|
'data-testid': ID
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
container
|
|
22
|
-
|
|
20
|
+
const {
|
|
21
|
+
container
|
|
22
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
23
|
+
const p = (0, _react.getByTestId)(container, ID);
|
|
23
24
|
expect(p.innerHTML).toContain(CONTENT);
|
|
24
25
|
expect(p.tagName).toEqual('P');
|
|
25
26
|
expect(p.className).toEqual('govuk-body');
|
|
26
27
|
});
|
|
27
|
-
it('should override default className for a paragraph component',
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
it('should override default className for a paragraph component', () => {
|
|
29
|
+
const ID = 'test-id';
|
|
30
|
+
const CONTENT = 'paragraph content';
|
|
31
|
+
const COMPONENT = {
|
|
31
32
|
type: _models.ComponentTypes.PARAGRAPH,
|
|
32
33
|
content: CONTENT,
|
|
33
34
|
'data-testid': ID,
|
|
34
35
|
className: 'govuk-body highlight'
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
-
container
|
|
38
|
-
|
|
37
|
+
const {
|
|
38
|
+
container
|
|
39
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
40
|
+
const p = (0, _react.getByTestId)(container, ID);
|
|
39
41
|
expect(p.innerHTML).toContain(CONTENT);
|
|
40
42
|
expect(p.tagName).toEqual('P');
|
|
41
43
|
expect(p.className).toEqual('govuk-body highlight');
|
|
@@ -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 phone-number 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.PHONE_NUMBER,
|
|
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,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 radios 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.RADIOS,
|
|
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
|
-
radios = _getAllByTestId2[1];
|
|
39
|
+
const {
|
|
40
|
+
container
|
|
41
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
42
|
+
const [formGroup, radios] = (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(radios.tagName).toEqual('DIV');
|
|
63
58
|
expect(radios.classList).toContain('govuk-radios');
|
|
64
59
|
expect(radios.childNodes.length).toEqual(OPTIONS.length);
|
|
65
|
-
|
|
66
|
-
OPTIONS.forEach(
|
|
67
|
-
|
|
60
|
+
const radioItems = [];
|
|
61
|
+
OPTIONS.forEach((_, index) => {
|
|
62
|
+
const radio = radios.childNodes[index];
|
|
68
63
|
expect(radio instanceof Element).toBeTruthy();
|
|
69
64
|
if (radio instanceof Element) {
|
|
70
65
|
radioItems.push(radio);
|
|
71
66
|
}
|
|
72
67
|
});
|
|
73
68
|
expect(radioItems.length).toEqual(OPTIONS.length);
|
|
74
|
-
OPTIONS.forEach(
|
|
75
|
-
|
|
69
|
+
OPTIONS.forEach((option, index) => {
|
|
70
|
+
const radio = radioItems[index];
|
|
76
71
|
expect(radio.tagName).toEqual('DIV');
|
|
77
72
|
expect(radio.classList).toContain('govuk-radios__item');
|
|
78
|
-
|
|
79
|
-
input = _radio$childNodes[0],
|
|
80
|
-
inputLabel = _radio$childNodes[1];
|
|
73
|
+
const [input, inputLabel] = radio.childNodes;
|
|
81
74
|
expect(input.tagName).toEqual('INPUT');
|
|
82
75
|
expect(input.type).toEqual('radio');
|
|
83
76
|
expect(inputLabel.textContent).toEqual(option.label);
|
|
@@ -98,22 +91,22 @@ describe('utils.Component.get', function () {
|
|
|
98
91
|
expect(ON_CHANGE_CALLS.length).toEqual(2); // No change, so no new event should have fired.
|
|
99
92
|
});
|
|
100
93
|
|
|
101
|
-
it('should work correctly with the returnFullData property on the radios component',
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
it('should work correctly with the returnFullData property on the radios component', () => {
|
|
95
|
+
const ID = 'test-id';
|
|
96
|
+
const FIELD_ID = 'field-id';
|
|
97
|
+
const LABEL = 'label';
|
|
98
|
+
const OPTIONS = [{
|
|
106
99
|
value: 'a',
|
|
107
100
|
label: 'Alpha'
|
|
108
101
|
}, {
|
|
109
102
|
value: 'b',
|
|
110
103
|
label: 'Bravo'
|
|
111
104
|
}];
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
const ON_CHANGE_CALLS = [];
|
|
106
|
+
const ON_CHANGE = e => {
|
|
114
107
|
ON_CHANGE_CALLS.push(e.target);
|
|
115
108
|
};
|
|
116
|
-
|
|
109
|
+
const COMPONENT = {
|
|
117
110
|
type: _models.ComponentTypes.RADIOS,
|
|
118
111
|
id: ID,
|
|
119
112
|
fieldId: FIELD_ID,
|
|
@@ -125,16 +118,14 @@ describe('utils.Component.get', function () {
|
|
|
125
118
|
onChange: ON_CHANGE,
|
|
126
119
|
'data-testid': ID
|
|
127
120
|
};
|
|
128
|
-
|
|
129
|
-
container
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
formGroup = _getAllByTestId4[0],
|
|
133
|
-
radios = _getAllByTestId4[1];
|
|
121
|
+
const {
|
|
122
|
+
container
|
|
123
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
124
|
+
const [formGroup, radios] = (0, _react.getAllByTestId)(container, ID);
|
|
134
125
|
expect(formGroup.tagName).toEqual('DIV');
|
|
135
126
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
136
|
-
|
|
137
|
-
formGroup.childNodes.forEach(
|
|
127
|
+
let label;
|
|
128
|
+
formGroup.childNodes.forEach(node => {
|
|
138
129
|
// Check if it's an element.
|
|
139
130
|
if (node instanceof Element) {
|
|
140
131
|
if (node.tagName === 'LABEL') {
|
|
@@ -148,22 +139,20 @@ describe('utils.Component.get', function () {
|
|
|
148
139
|
expect(radios.tagName).toEqual('DIV');
|
|
149
140
|
expect(radios.classList).toContain('govuk-radios');
|
|
150
141
|
expect(radios.childNodes.length).toEqual(OPTIONS.length);
|
|
151
|
-
|
|
152
|
-
OPTIONS.forEach(
|
|
153
|
-
|
|
142
|
+
const radioItems = [];
|
|
143
|
+
OPTIONS.forEach((_, index) => {
|
|
144
|
+
const radio = radios.childNodes[index];
|
|
154
145
|
expect(radio instanceof Element).toBeTruthy();
|
|
155
146
|
if (radio instanceof Element) {
|
|
156
147
|
radioItems.push(radio);
|
|
157
148
|
}
|
|
158
149
|
});
|
|
159
150
|
expect(radioItems.length).toEqual(OPTIONS.length);
|
|
160
|
-
OPTIONS.forEach(
|
|
161
|
-
|
|
151
|
+
OPTIONS.forEach((option, index) => {
|
|
152
|
+
const radio = radioItems[index];
|
|
162
153
|
expect(radio.tagName).toEqual('DIV');
|
|
163
154
|
expect(radio.classList).toContain('govuk-radios__item');
|
|
164
|
-
|
|
165
|
-
input = _radio$childNodes2[0],
|
|
166
|
-
inputLabel = _radio$childNodes2[1];
|
|
155
|
+
const [input, inputLabel] = radio.childNodes;
|
|
167
156
|
expect(input.tagName).toEqual('INPUT');
|
|
168
157
|
expect(input.type).toEqual('radio');
|
|
169
158
|
expect(inputLabel.textContent).toEqual(option.label);
|
|
@@ -184,16 +173,16 @@ describe('utils.Component.get', function () {
|
|
|
184
173
|
expect(ON_CHANGE_CALLS.length).toEqual(2); // No change, so no new event should have fired.
|
|
185
174
|
});
|
|
186
175
|
|
|
187
|
-
it('should return an appropriately rendered radios component with nested components',
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
176
|
+
it('should return an appropriately rendered radios component with nested components', () => {
|
|
177
|
+
const ID = 'test-id';
|
|
178
|
+
const FIELD_ID = 'field-id';
|
|
179
|
+
const LABEL = 'label';
|
|
180
|
+
const NESTED = {
|
|
192
181
|
id: 'charle',
|
|
193
182
|
fieldId: 'charle',
|
|
194
183
|
type: 'text'
|
|
195
184
|
};
|
|
196
|
-
|
|
185
|
+
const OPTIONS = [{
|
|
197
186
|
value: 'a',
|
|
198
187
|
label: 'Alpha',
|
|
199
188
|
nested: [NESTED]
|
|
@@ -201,11 +190,11 @@ describe('utils.Component.get', function () {
|
|
|
201
190
|
value: 'b',
|
|
202
191
|
label: 'Bravo'
|
|
203
192
|
}];
|
|
204
|
-
|
|
205
|
-
|
|
193
|
+
const ON_CHANGE_CALLS = [];
|
|
194
|
+
const ON_CHANGE = e => {
|
|
206
195
|
ON_CHANGE_CALLS.push(e.target);
|
|
207
196
|
};
|
|
208
|
-
|
|
197
|
+
const COMPONENT = {
|
|
209
198
|
type: _models.ComponentTypes.RADIOS,
|
|
210
199
|
id: ID,
|
|
211
200
|
fieldId: FIELD_ID,
|
|
@@ -217,12 +206,10 @@ describe('utils.Component.get', function () {
|
|
|
217
206
|
onChange: ON_CHANGE,
|
|
218
207
|
'data-testid': ID
|
|
219
208
|
};
|
|
220
|
-
|
|
221
|
-
container
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
formGroup = _getAllByTestId6[0],
|
|
225
|
-
radios = _getAllByTestId6[1];
|
|
209
|
+
const {
|
|
210
|
+
container
|
|
211
|
+
} = (0, _setupTests.renderWithValidation)((0, _getComponent.default)(COMPONENT));
|
|
212
|
+
const [formGroup, radios] = (0, _react.getAllByTestId)(container, ID);
|
|
226
213
|
expect(formGroup.tagName).toEqual('DIV');
|
|
227
214
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
228
215
|
expect(radios.tagName).toEqual('DIV');
|
|
@@ -4,24 +4,21 @@ 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
|
-
|
|
21
|
-
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered select component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const NEW_VALUE = 'option2';
|
|
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.SELECT,
|
|
26
23
|
id: ID,
|
|
27
24
|
fieldId: FIELD_ID,
|
|
@@ -36,15 +33,13 @@ describe('utils.Component.get', function () {
|
|
|
36
33
|
}],
|
|
37
34
|
'data-testid': ID
|
|
38
35
|
};
|
|
39
|
-
|
|
40
|
-
container
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
formGroup = _getAllByTestId2[0],
|
|
44
|
-
select = _getAllByTestId2[1];
|
|
36
|
+
const {
|
|
37
|
+
container
|
|
38
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
39
|
+
const [formGroup, select] = (0, _react.getAllByTestId)(container, ID);
|
|
45
40
|
expect(formGroup.tagName).toEqual('DIV');
|
|
46
41
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
47
|
-
|
|
42
|
+
const label = formGroup.childNodes[0];
|
|
48
43
|
expect(label).toBeDefined();
|
|
49
44
|
expect(label.innerHTML).toContain(LABEL);
|
|
50
45
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
@@ -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 text 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.TEXT,
|
|
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;
|
|
@@ -4,24 +4,21 @@ 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
|
-
|
|
21
|
-
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered textarea component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const ROWS = 13;
|
|
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.TEXT_AREA,
|
|
26
23
|
id: ID,
|
|
27
24
|
fieldId: FIELD_ID,
|
|
@@ -30,15 +27,13 @@ describe('utils.Component.get', function () {
|
|
|
30
27
|
onChange: ON_CHANGE,
|
|
31
28
|
'data-testid': ID
|
|
32
29
|
};
|
|
33
|
-
|
|
34
|
-
container
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
formGroup = _getAllByTestId2[0],
|
|
38
|
-
textarea = _getAllByTestId2[1];
|
|
30
|
+
const {
|
|
31
|
+
container
|
|
32
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
33
|
+
const [formGroup, textarea] = (0, _react.getAllByTestId)(container, ID);
|
|
39
34
|
expect(formGroup.tagName).toEqual('DIV');
|
|
40
35
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
41
|
-
|
|
36
|
+
const label = formGroup.childNodes[0];
|
|
42
37
|
expect(label.innerHTML).toContain(LABEL);
|
|
43
38
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
44
39
|
expect(textarea.tagName).toEqual('TEXTAREA');
|
|
@@ -57,16 +52,16 @@ describe('utils.Component.get', function () {
|
|
|
57
52
|
value: 'Some text'
|
|
58
53
|
});
|
|
59
54
|
});
|
|
60
|
-
it('should return an appropriately rendered textarea component with a character count',
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
it('should return an appropriately rendered textarea component with a character count', () => {
|
|
56
|
+
const ID = 'test-id';
|
|
57
|
+
const FIELD_ID = 'field-id';
|
|
58
|
+
const LABEL = 'label';
|
|
59
|
+
const ROWS = 13;
|
|
60
|
+
const ON_CHANGE_CALLS = [];
|
|
61
|
+
const ON_CHANGE = e => {
|
|
67
62
|
ON_CHANGE_CALLS.push(e.target);
|
|
68
63
|
};
|
|
69
|
-
|
|
64
|
+
const COMPONENT = {
|
|
70
65
|
type: _models.ComponentTypes.TEXT_AREA,
|
|
71
66
|
id: ID,
|
|
72
67
|
fieldId: FIELD_ID,
|
|
@@ -76,15 +71,13 @@ describe('utils.Component.get', function () {
|
|
|
76
71
|
'data-testid': ID,
|
|
77
72
|
showCharacterCount: true
|
|
78
73
|
};
|
|
79
|
-
|
|
80
|
-
container
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
formGroup = _getAllByTestId4[0],
|
|
84
|
-
textarea = _getAllByTestId4[1];
|
|
74
|
+
const {
|
|
75
|
+
container
|
|
76
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
77
|
+
const [formGroup, textarea] = (0, _react.getAllByTestId)(container, ID);
|
|
85
78
|
expect(formGroup.tagName).toEqual('DIV');
|
|
86
79
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
87
|
-
|
|
80
|
+
const label = formGroup.childNodes[0];
|
|
88
81
|
expect(label.innerHTML).toContain(LABEL);
|
|
89
82
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
90
83
|
expect(textarea.tagName).toEqual('TEXTAREA');
|
|
@@ -102,7 +95,7 @@ describe('utils.Component.get', function () {
|
|
|
102
95
|
name: FIELD_ID,
|
|
103
96
|
value: 'Some text'
|
|
104
97
|
});
|
|
105
|
-
|
|
98
|
+
const characterCount = formGroup.childNodes[2];
|
|
106
99
|
expect(characterCount.tagName).toEqual('DIV');
|
|
107
100
|
expect(characterCount.classList).toContain('govuk-hint');
|
|
108
101
|
expect(characterCount.textContent).toEqual('You have 1000 characters remaining');
|