@ukhomeoffice/cop-react-form-renderer 5.45.2-alpha → 5.48.1-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 +127 -92
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +131 -101
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +769 -464
- package/dist/components/CollectionPage/CollectionPage.js +58 -66
- package/dist/components/CollectionPage/CollectionPage.test.js +342 -300
- package/dist/components/CollectionSummary/BannerStrip.js +12 -12
- package/dist/components/CollectionSummary/BannerStrip.test.js +59 -63
- package/dist/components/CollectionSummary/CollectionSummary.js +88 -61
- package/dist/components/CollectionSummary/CollectionSummary.test.js +96 -102
- package/dist/components/CollectionSummary/Confirmation.js +12 -14
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/SummaryCard.js +148 -109
- package/dist/components/CollectionSummary/SummaryCard.scss +1 -1
- package/dist/components/CollectionSummary/SummaryCard.test.js +927 -905
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +29 -23
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +73 -61
- package/dist/components/FormComponent/Collection.js +107 -73
- package/dist/components/FormComponent/Collection.test.js +945 -809
- package/dist/components/FormComponent/Container.js +38 -40
- package/dist/components/FormComponent/Container.test.js +345 -314
- package/dist/components/FormComponent/FormComponent.js +70 -67
- package/dist/components/FormComponent/FormComponent.test.js +342 -284
- package/dist/components/FormComponent/helpers/addLabel.js +7 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +5 -3
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +4 -3
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +80 -65
- package/dist/components/FormPage/FormPage.test.js +163 -127
- package/dist/components/FormRenderer/FormRenderer.js +181 -144
- package/dist/components/FormRenderer/FormRenderer.test.js +1115 -730
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +3 -1
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +5 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +47 -11
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +3 -1
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +20 -16
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -17
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +5 -3
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +24 -13
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +4 -2
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -7
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +91 -97
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +73 -71
- package/dist/components/FormRenderer/helpers/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +51 -59
- package/dist/components/FormRenderer/onCYAAction.test.js +152 -164
- package/dist/components/FormRenderer/onPageAction.js +40 -44
- package/dist/components/FormRenderer/onPageAction.test.js +206 -223
- package/dist/components/FormRenderer/onTaskAction.js +13 -9
- package/dist/components/FormRenderer/onTaskAction.test.js +88 -93
- package/dist/components/PageActions/ActionButton.js +15 -12
- package/dist/components/PageActions/ActionButton.test.js +78 -56
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +115 -86
- package/dist/components/SummaryList/GroupAction.js +17 -9
- package/dist/components/SummaryList/GroupAction.test.js +33 -37
- package/dist/components/SummaryList/RowAction.js +16 -11
- package/dist/components/SummaryList/RowAction.test.js +33 -37
- package/dist/components/SummaryList/SummaryList.js +26 -21
- package/dist/components/SummaryList/SummaryList.test.js +166 -143
- package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
- package/dist/components/SummaryList/SummaryListRow.js +4 -6
- package/dist/components/SummaryList/SummaryListTitleRow.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +29 -19
- package/dist/components/TaskList/Task.test.js +76 -83
- package/dist/components/TaskList/TaskList.js +71 -45
- package/dist/components/TaskList/TaskList.test.js +111 -113
- package/dist/components/TaskList/TaskState.js +5 -7
- package/dist/components/TaskList/TaskState.test.js +45 -52
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +79 -58
- package/dist/context/HooksContext/HooksContext.test.js +35 -26
- package/dist/context/HooksContext/index.js +4 -3
- package/dist/context/ValidationContext/ValidationContext.js +72 -32
- package/dist/context/ValidationContext/ValidationContext.test.js +59 -47
- package/dist/context/ValidationContext/index.js +4 -3
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +10 -9
- package/dist/hooks/useAxios.js +40 -14
- package/dist/hooks/useGetRequest.js +97 -61
- package/dist/hooks/useHooks.js +3 -1
- package/dist/hooks/useRefData.js +39 -26
- package/dist/hooks/useValidation.js +3 -1
- package/dist/index.js +14 -13
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +38 -44
- package/dist/models/TaskStates.js +28 -30
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +31 -30
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +54 -52
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +25 -15
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +35 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +31 -17
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +44 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +24 -18
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +36 -33
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +60 -58
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +88 -79
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +124 -146
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +20 -25
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +97 -103
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +18 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +76 -70
- package/dist/utils/CheckYourAnswers/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 +18 -9
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +22 -27
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +11 -7
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +16 -12
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +30 -29
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +17 -17
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +17 -17
- package/dist/utils/Component/addShowWhen.js +8 -4
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +32 -27
- package/dist/utils/Component/cleanAttributes.js +13 -10
- package/dist/utils/Component/cleanAttributes.test.js +18 -17
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +94 -88
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +17 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +59 -46
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +48 -39
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -23
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +18 -20
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +25 -20
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +9 -10
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +8 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +26 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +175 -155
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +70 -57
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +38 -31
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +29 -20
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +8 -9
- package/dist/utils/Component/getDefaultValue.js +8 -6
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +21 -22
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +4 -2
- package/dist/utils/Component/isEditable.test.js +15 -14
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +29 -27
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +7 -7
- package/dist/utils/Condition/meetsAllConditions.test.js +17 -17
- package/dist/utils/Condition/meetsCondition.js +17 -14
- 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 +18 -13
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +5 -3
- package/dist/utils/Container/getEditableComponents.test.js +45 -43
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +20 -16
- package/dist/utils/Container/setupNesting.test.js +30 -27
- package/dist/utils/Container/showContainer.js +7 -3
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +48 -38
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +26 -18
- package/dist/utils/Data/getAutocompleteSource.test.js +86 -80
- package/dist/utils/Data/getDataPath.js +28 -18
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +25 -19
- package/dist/utils/Data/getOptions.test.js +20 -20
- package/dist/utils/Data/getSourceData.js +19 -6
- package/dist/utils/Data/getSourceData.test.js +80 -84
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/refDataToOptions.js +13 -10
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +8 -7
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +21 -13
- package/dist/utils/Data/setupFormData.test.js +50 -51
- package/dist/utils/Data/setupRefDataUrlForComponent.js +26 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +9 -5
- package/dist/utils/FormPage/applyConditionalProperties.test.js +18 -15
- package/dist/utils/FormPage/getFormPage.js +16 -15
- package/dist/utils/FormPage/getFormPage.test.js +46 -47
- package/dist/utils/FormPage/getFormPages.js +12 -7
- package/dist/utils/FormPage/getFormPages.test.js +23 -20
- package/dist/utils/FormPage/getPageActions.js +15 -9
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getPageTitle.js +2 -2
- package/dist/utils/FormPage/getPageTitle.test.js +22 -22
- package/dist/utils/FormPage/getParagraphFromText.js +7 -5
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +1 -1
- package/dist/utils/FormPage/showFormPage.js +7 -3
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +28 -21
- package/dist/utils/FormPage/useComponent.test.js +79 -78
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +6 -5
- package/dist/utils/Format/formatDataForComponent.test.js +77 -50
- package/dist/utils/Format/formatDataForForm.js +8 -6
- package/dist/utils/Format/formatDataForForm.test.js +15 -13
- package/dist/utils/Format/formatDataForPage.js +5 -4
- package/dist/utils/Format/formatDataForPage.test.js +23 -20
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +31 -28
- package/dist/utils/Hub/index.js +1 -1
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +16 -24
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -14
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +34 -68
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +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 +20 -22
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +36 -35
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +26 -21
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +10 -8
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +11 -7
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +41 -37
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +35 -0
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +127 -0
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +16 -14
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +4 -3
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +26 -28
- package/dist/utils/Validate/additional/utils.js +22 -9
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +25 -19
- package/dist/utils/Validate/validateCollection.test.js +66 -74
- package/dist/utils/Validate/validateComponent.js +16 -18
- package/dist/utils/Validate/validateComponent.test.js +146 -167
- package/dist/utils/Validate/validateContainer.js +19 -14
- package/dist/utils/Validate/validateContainer.test.js +45 -49
- package/dist/utils/Validate/validateDate.js +17 -11
- package/dist/utils/Validate/validateDate.test.js +29 -28
- package/dist/utils/Validate/validateEmail.js +8 -6
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +7 -5
- package/dist/utils/Validate/validateMultifile.test.js +18 -17
- package/dist/utils/Validate/validatePage.js +18 -17
- package/dist/utils/Validate/validatePage.test.js +182 -185
- package/dist/utils/Validate/validateRegex.js +5 -3
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +6 -4
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +6 -4
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +14 -7
- package/dist/utils/Validate/validateTime.test.js +14 -14
- package/dist/utils/index.js +9 -7
- package/package.json +2 -2
|
@@ -8,36 +8,34 @@ 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', function () {
|
|
12
|
+
it('should return a p tag and correct className for a paragraph component', function () {
|
|
13
|
+
var ID = 'test-id';
|
|
14
|
+
var CONTENT = 'paragraph content';
|
|
15
|
+
var COMPONENT = {
|
|
16
16
|
type: _models.ComponentTypes.PARAGRAPH,
|
|
17
17
|
content: CONTENT,
|
|
18
18
|
'data-testid': ID
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
container
|
|
22
|
-
|
|
23
|
-
const p = (0, _react.getByTestId)(container, ID);
|
|
20
|
+
var _render = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
21
|
+
container = _render.container;
|
|
22
|
+
var p = (0, _react.getByTestId)(container, ID);
|
|
24
23
|
expect(p.innerHTML).toContain(CONTENT);
|
|
25
24
|
expect(p.tagName).toEqual('P');
|
|
26
25
|
expect(p.className).toEqual('govuk-body');
|
|
27
26
|
});
|
|
28
|
-
it('should override default className for a paragraph component', ()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
it('should override default className for a paragraph component', function () {
|
|
28
|
+
var ID = 'test-id';
|
|
29
|
+
var CONTENT = 'paragraph content';
|
|
30
|
+
var COMPONENT = {
|
|
32
31
|
type: _models.ComponentTypes.PARAGRAPH,
|
|
33
32
|
content: CONTENT,
|
|
34
33
|
'data-testid': ID,
|
|
35
34
|
className: 'govuk-body highlight'
|
|
36
35
|
};
|
|
37
|
-
|
|
38
|
-
container
|
|
39
|
-
|
|
40
|
-
const p = (0, _react.getByTestId)(container, ID);
|
|
36
|
+
var _render2 = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
37
|
+
container = _render2.container;
|
|
38
|
+
var p = (0, _react.getByTestId)(container, ID);
|
|
41
39
|
expect(p.innerHTML).toContain(CONTENT);
|
|
42
40
|
expect(p.tagName).toEqual('P');
|
|
43
41
|
expect(p.className).toEqual('govuk-body highlight');
|
|
@@ -4,20 +4,23 @@ 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
|
-
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
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
|
|
9
13
|
// Local imports
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const ON_CHANGE = e => {
|
|
14
|
+
describe('utils.Component.get', function () {
|
|
15
|
+
it('should return an appropriately rendered phone-number component', function () {
|
|
16
|
+
var ID = 'test-id';
|
|
17
|
+
var FIELD_ID = 'field-id';
|
|
18
|
+
var LABEL = 'label';
|
|
19
|
+
var ON_CHANGE_CALLS = [];
|
|
20
|
+
var ON_CHANGE = function ON_CHANGE(e) {
|
|
18
21
|
ON_CHANGE_CALLS.push(e.target);
|
|
19
22
|
};
|
|
20
|
-
|
|
23
|
+
var COMPONENT = {
|
|
21
24
|
type: _models.ComponentTypes.PHONE_NUMBER,
|
|
22
25
|
id: ID,
|
|
23
26
|
fieldId: FIELD_ID,
|
|
@@ -25,14 +28,16 @@ describe('utils.Component.get', () => {
|
|
|
25
28
|
onChange: ON_CHANGE,
|
|
26
29
|
'data-testid': ID
|
|
27
30
|
};
|
|
28
|
-
|
|
29
|
-
container
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
var _render = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
32
|
+
container = _render.container;
|
|
33
|
+
var _getAllByTestId = (0, _react.getAllByTestId)(container, ID),
|
|
34
|
+
_getAllByTestId2 = _slicedToArray(_getAllByTestId, 2),
|
|
35
|
+
formGroup = _getAllByTestId2[0],
|
|
36
|
+
input = _getAllByTestId2[1];
|
|
32
37
|
expect(formGroup.tagName).toEqual('DIV');
|
|
33
38
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
34
|
-
|
|
35
|
-
formGroup.childNodes.forEach(node
|
|
39
|
+
var label;
|
|
40
|
+
formGroup.childNodes.forEach(function (node) {
|
|
36
41
|
// Check if it's an element.
|
|
37
42
|
if (node instanceof Element && node.tagName === 'LABEL') {
|
|
38
43
|
label = node;
|
|
@@ -5,27 +5,30 @@ 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
|
-
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
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."); }
|
|
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
|
|
10
14
|
// Local imports
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const OPTIONS = [{
|
|
15
|
+
describe('utils.Component.get', function () {
|
|
16
|
+
it('should return an appropriately rendered radios component', function () {
|
|
17
|
+
var ID = 'test-id';
|
|
18
|
+
var FIELD_ID = 'field-id';
|
|
19
|
+
var LABEL = 'label';
|
|
20
|
+
var OPTIONS = [{
|
|
18
21
|
value: 'a',
|
|
19
22
|
label: 'Alpha'
|
|
20
23
|
}, {
|
|
21
24
|
value: 'b',
|
|
22
25
|
label: 'Bravo'
|
|
23
26
|
}];
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
var ON_CHANGE_CALLS = [];
|
|
28
|
+
var ON_CHANGE = function ON_CHANGE(e) {
|
|
26
29
|
ON_CHANGE_CALLS.push(e.target);
|
|
27
30
|
};
|
|
28
|
-
|
|
31
|
+
var COMPONENT = {
|
|
29
32
|
type: _models.ComponentTypes.RADIOS,
|
|
30
33
|
id: ID,
|
|
31
34
|
fieldId: FIELD_ID,
|
|
@@ -36,14 +39,16 @@ describe('utils.Component.get', () => {
|
|
|
36
39
|
onChange: ON_CHANGE,
|
|
37
40
|
'data-testid': ID
|
|
38
41
|
};
|
|
39
|
-
|
|
40
|
-
container
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
var _render = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
43
|
+
container = _render.container;
|
|
44
|
+
var _getAllByTestId = (0, _react.getAllByTestId)(container, ID),
|
|
45
|
+
_getAllByTestId2 = _slicedToArray(_getAllByTestId, 2),
|
|
46
|
+
formGroup = _getAllByTestId2[0],
|
|
47
|
+
radios = _getAllByTestId2[1];
|
|
43
48
|
expect(formGroup.tagName).toEqual('DIV');
|
|
44
49
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
45
|
-
|
|
46
|
-
formGroup.childNodes.forEach(node
|
|
50
|
+
var label;
|
|
51
|
+
formGroup.childNodes.forEach(function (node) {
|
|
47
52
|
// Check if it's an element.
|
|
48
53
|
if (node instanceof Element) {
|
|
49
54
|
if (node.tagName === 'LABEL') {
|
|
@@ -57,20 +62,22 @@ describe('utils.Component.get', () => {
|
|
|
57
62
|
expect(radios.tagName).toEqual('DIV');
|
|
58
63
|
expect(radios.classList).toContain('govuk-radios');
|
|
59
64
|
expect(radios.childNodes.length).toEqual(OPTIONS.length);
|
|
60
|
-
|
|
61
|
-
OPTIONS.forEach((_, index)
|
|
62
|
-
|
|
65
|
+
var radioItems = [];
|
|
66
|
+
OPTIONS.forEach(function (_, index) {
|
|
67
|
+
var radio = radios.childNodes[index];
|
|
63
68
|
expect(radio instanceof Element).toBeTruthy();
|
|
64
69
|
if (radio instanceof Element) {
|
|
65
70
|
radioItems.push(radio);
|
|
66
71
|
}
|
|
67
72
|
});
|
|
68
73
|
expect(radioItems.length).toEqual(OPTIONS.length);
|
|
69
|
-
OPTIONS.forEach((option, index)
|
|
70
|
-
|
|
74
|
+
OPTIONS.forEach(function (option, index) {
|
|
75
|
+
var radio = radioItems[index];
|
|
71
76
|
expect(radio.tagName).toEqual('DIV');
|
|
72
77
|
expect(radio.classList).toContain('govuk-radios__item');
|
|
73
|
-
|
|
78
|
+
var _radio$childNodes = _slicedToArray(radio.childNodes, 2),
|
|
79
|
+
input = _radio$childNodes[0],
|
|
80
|
+
inputLabel = _radio$childNodes[1];
|
|
74
81
|
expect(input.tagName).toEqual('INPUT');
|
|
75
82
|
expect(input.type).toEqual('radio');
|
|
76
83
|
expect(inputLabel.textContent).toEqual(option.label);
|
|
@@ -91,22 +98,22 @@ describe('utils.Component.get', () => {
|
|
|
91
98
|
expect(ON_CHANGE_CALLS.length).toEqual(2); // No change, so no new event should have fired.
|
|
92
99
|
});
|
|
93
100
|
|
|
94
|
-
it('should work correctly with the returnFullData property on the radios component', ()
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
it('should work correctly with the returnFullData property on the radios component', function () {
|
|
102
|
+
var ID = 'test-id';
|
|
103
|
+
var FIELD_ID = 'field-id';
|
|
104
|
+
var LABEL = 'label';
|
|
105
|
+
var OPTIONS = [{
|
|
99
106
|
value: 'a',
|
|
100
107
|
label: 'Alpha'
|
|
101
108
|
}, {
|
|
102
109
|
value: 'b',
|
|
103
110
|
label: 'Bravo'
|
|
104
111
|
}];
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
var ON_CHANGE_CALLS = [];
|
|
113
|
+
var ON_CHANGE = function ON_CHANGE(e) {
|
|
107
114
|
ON_CHANGE_CALLS.push(e.target);
|
|
108
115
|
};
|
|
109
|
-
|
|
116
|
+
var COMPONENT = {
|
|
110
117
|
type: _models.ComponentTypes.RADIOS,
|
|
111
118
|
id: ID,
|
|
112
119
|
fieldId: FIELD_ID,
|
|
@@ -118,14 +125,16 @@ describe('utils.Component.get', () => {
|
|
|
118
125
|
onChange: ON_CHANGE,
|
|
119
126
|
'data-testid': ID
|
|
120
127
|
};
|
|
121
|
-
|
|
122
|
-
container
|
|
123
|
-
|
|
124
|
-
|
|
128
|
+
var _render2 = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
129
|
+
container = _render2.container;
|
|
130
|
+
var _getAllByTestId3 = (0, _react.getAllByTestId)(container, ID),
|
|
131
|
+
_getAllByTestId4 = _slicedToArray(_getAllByTestId3, 2),
|
|
132
|
+
formGroup = _getAllByTestId4[0],
|
|
133
|
+
radios = _getAllByTestId4[1];
|
|
125
134
|
expect(formGroup.tagName).toEqual('DIV');
|
|
126
135
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
127
|
-
|
|
128
|
-
formGroup.childNodes.forEach(node
|
|
136
|
+
var label;
|
|
137
|
+
formGroup.childNodes.forEach(function (node) {
|
|
129
138
|
// Check if it's an element.
|
|
130
139
|
if (node instanceof Element) {
|
|
131
140
|
if (node.tagName === 'LABEL') {
|
|
@@ -139,20 +148,22 @@ describe('utils.Component.get', () => {
|
|
|
139
148
|
expect(radios.tagName).toEqual('DIV');
|
|
140
149
|
expect(radios.classList).toContain('govuk-radios');
|
|
141
150
|
expect(radios.childNodes.length).toEqual(OPTIONS.length);
|
|
142
|
-
|
|
143
|
-
OPTIONS.forEach((_, index)
|
|
144
|
-
|
|
151
|
+
var radioItems = [];
|
|
152
|
+
OPTIONS.forEach(function (_, index) {
|
|
153
|
+
var radio = radios.childNodes[index];
|
|
145
154
|
expect(radio instanceof Element).toBeTruthy();
|
|
146
155
|
if (radio instanceof Element) {
|
|
147
156
|
radioItems.push(radio);
|
|
148
157
|
}
|
|
149
158
|
});
|
|
150
159
|
expect(radioItems.length).toEqual(OPTIONS.length);
|
|
151
|
-
OPTIONS.forEach((option, index)
|
|
152
|
-
|
|
160
|
+
OPTIONS.forEach(function (option, index) {
|
|
161
|
+
var radio = radioItems[index];
|
|
153
162
|
expect(radio.tagName).toEqual('DIV');
|
|
154
163
|
expect(radio.classList).toContain('govuk-radios__item');
|
|
155
|
-
|
|
164
|
+
var _radio$childNodes2 = _slicedToArray(radio.childNodes, 2),
|
|
165
|
+
input = _radio$childNodes2[0],
|
|
166
|
+
inputLabel = _radio$childNodes2[1];
|
|
156
167
|
expect(input.tagName).toEqual('INPUT');
|
|
157
168
|
expect(input.type).toEqual('radio');
|
|
158
169
|
expect(inputLabel.textContent).toEqual(option.label);
|
|
@@ -173,16 +184,16 @@ describe('utils.Component.get', () => {
|
|
|
173
184
|
expect(ON_CHANGE_CALLS.length).toEqual(2); // No change, so no new event should have fired.
|
|
174
185
|
});
|
|
175
186
|
|
|
176
|
-
it('should return an appropriately rendered radios component with nested components', ()
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
187
|
+
it('should return an appropriately rendered radios component with nested components', function () {
|
|
188
|
+
var ID = 'test-id';
|
|
189
|
+
var FIELD_ID = 'field-id';
|
|
190
|
+
var LABEL = 'label';
|
|
191
|
+
var NESTED = {
|
|
181
192
|
id: 'charle',
|
|
182
193
|
fieldId: 'charle',
|
|
183
194
|
type: 'text'
|
|
184
195
|
};
|
|
185
|
-
|
|
196
|
+
var OPTIONS = [{
|
|
186
197
|
value: 'a',
|
|
187
198
|
label: 'Alpha',
|
|
188
199
|
nested: [NESTED]
|
|
@@ -190,11 +201,11 @@ describe('utils.Component.get', () => {
|
|
|
190
201
|
value: 'b',
|
|
191
202
|
label: 'Bravo'
|
|
192
203
|
}];
|
|
193
|
-
|
|
194
|
-
|
|
204
|
+
var ON_CHANGE_CALLS = [];
|
|
205
|
+
var ON_CHANGE = function ON_CHANGE(e) {
|
|
195
206
|
ON_CHANGE_CALLS.push(e.target);
|
|
196
207
|
};
|
|
197
|
-
|
|
208
|
+
var COMPONENT = {
|
|
198
209
|
type: _models.ComponentTypes.RADIOS,
|
|
199
210
|
id: ID,
|
|
200
211
|
fieldId: FIELD_ID,
|
|
@@ -206,10 +217,12 @@ describe('utils.Component.get', () => {
|
|
|
206
217
|
onChange: ON_CHANGE,
|
|
207
218
|
'data-testid': ID
|
|
208
219
|
};
|
|
209
|
-
|
|
210
|
-
container
|
|
211
|
-
|
|
212
|
-
|
|
220
|
+
var _renderWithValidation = (0, _setupTests.renderWithValidation)((0, _getComponent.default)(COMPONENT)),
|
|
221
|
+
container = _renderWithValidation.container;
|
|
222
|
+
var _getAllByTestId5 = (0, _react.getAllByTestId)(container, ID),
|
|
223
|
+
_getAllByTestId6 = _slicedToArray(_getAllByTestId5, 2),
|
|
224
|
+
formGroup = _getAllByTestId6[0],
|
|
225
|
+
radios = _getAllByTestId6[1];
|
|
213
226
|
expect(formGroup.tagName).toEqual('DIV');
|
|
214
227
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
215
228
|
expect(radios.tagName).toEqual('DIV');
|
|
@@ -4,21 +4,24 @@ 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
|
-
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
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
|
|
9
13
|
// Local imports
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const ON_CHANGE = e => {
|
|
14
|
+
describe('utils.Component.get', function () {
|
|
15
|
+
it('should return an appropriately rendered select component', function () {
|
|
16
|
+
var ID = 'test-id';
|
|
17
|
+
var FIELD_ID = 'field-id';
|
|
18
|
+
var LABEL = 'label';
|
|
19
|
+
var NEW_VALUE = 'option2';
|
|
20
|
+
var ON_CHANGE_CALLS = [];
|
|
21
|
+
var ON_CHANGE = function ON_CHANGE(e) {
|
|
19
22
|
ON_CHANGE_CALLS.push(e.target);
|
|
20
23
|
};
|
|
21
|
-
|
|
24
|
+
var COMPONENT = {
|
|
22
25
|
type: _models.ComponentTypes.SELECT,
|
|
23
26
|
id: ID,
|
|
24
27
|
fieldId: FIELD_ID,
|
|
@@ -33,13 +36,15 @@ describe('utils.Component.get', () => {
|
|
|
33
36
|
}],
|
|
34
37
|
'data-testid': ID
|
|
35
38
|
};
|
|
36
|
-
|
|
37
|
-
container
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
var _render = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
40
|
+
container = _render.container;
|
|
41
|
+
var _getAllByTestId = (0, _react.getAllByTestId)(container, ID),
|
|
42
|
+
_getAllByTestId2 = _slicedToArray(_getAllByTestId, 2),
|
|
43
|
+
formGroup = _getAllByTestId2[0],
|
|
44
|
+
select = _getAllByTestId2[1];
|
|
40
45
|
expect(formGroup.tagName).toEqual('DIV');
|
|
41
46
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
42
|
-
|
|
47
|
+
var label = formGroup.childNodes[0];
|
|
43
48
|
expect(label).toBeDefined();
|
|
44
49
|
expect(label.innerHTML).toContain(LABEL);
|
|
45
50
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
@@ -4,20 +4,23 @@ 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
|
-
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
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
|
|
9
13
|
// Local imports
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const ON_CHANGE = e => {
|
|
14
|
+
describe('utils.Component.get', function () {
|
|
15
|
+
it('should return an appropriately rendered text component', function () {
|
|
16
|
+
var ID = 'test-id';
|
|
17
|
+
var FIELD_ID = 'field-id';
|
|
18
|
+
var LABEL = 'label';
|
|
19
|
+
var ON_CHANGE_CALLS = [];
|
|
20
|
+
var ON_CHANGE = function ON_CHANGE(e) {
|
|
18
21
|
ON_CHANGE_CALLS.push(e.target);
|
|
19
22
|
};
|
|
20
|
-
|
|
23
|
+
var COMPONENT = {
|
|
21
24
|
type: _models.ComponentTypes.TEXT,
|
|
22
25
|
id: ID,
|
|
23
26
|
fieldId: FIELD_ID,
|
|
@@ -25,14 +28,16 @@ describe('utils.Component.get', () => {
|
|
|
25
28
|
onChange: ON_CHANGE,
|
|
26
29
|
'data-testid': ID
|
|
27
30
|
};
|
|
28
|
-
|
|
29
|
-
container
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
var _render = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
32
|
+
container = _render.container;
|
|
33
|
+
var _getAllByTestId = (0, _react.getAllByTestId)(container, ID),
|
|
34
|
+
_getAllByTestId2 = _slicedToArray(_getAllByTestId, 2),
|
|
35
|
+
formGroup = _getAllByTestId2[0],
|
|
36
|
+
input = _getAllByTestId2[1];
|
|
32
37
|
expect(formGroup.tagName).toEqual('DIV');
|
|
33
38
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
34
|
-
|
|
35
|
-
formGroup.childNodes.forEach(node
|
|
39
|
+
var label;
|
|
40
|
+
formGroup.childNodes.forEach(function (node) {
|
|
36
41
|
// Check if it's an element.
|
|
37
42
|
if (node instanceof Element && node.tagName === 'LABEL') {
|
|
38
43
|
label = node;
|
|
@@ -4,21 +4,24 @@ 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
|
-
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
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
|
|
9
13
|
// Local imports
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const ON_CHANGE = e => {
|
|
14
|
+
describe('utils.Component.get', function () {
|
|
15
|
+
it('should return an appropriately rendered textarea component', function () {
|
|
16
|
+
var ID = 'test-id';
|
|
17
|
+
var FIELD_ID = 'field-id';
|
|
18
|
+
var LABEL = 'label';
|
|
19
|
+
var ROWS = 13;
|
|
20
|
+
var ON_CHANGE_CALLS = [];
|
|
21
|
+
var ON_CHANGE = function ON_CHANGE(e) {
|
|
19
22
|
ON_CHANGE_CALLS.push(e.target);
|
|
20
23
|
};
|
|
21
|
-
|
|
24
|
+
var COMPONENT = {
|
|
22
25
|
type: _models.ComponentTypes.TEXT_AREA,
|
|
23
26
|
id: ID,
|
|
24
27
|
fieldId: FIELD_ID,
|
|
@@ -27,13 +30,15 @@ describe('utils.Component.get', () => {
|
|
|
27
30
|
onChange: ON_CHANGE,
|
|
28
31
|
'data-testid': ID
|
|
29
32
|
};
|
|
30
|
-
|
|
31
|
-
container
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
var _render = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
34
|
+
container = _render.container;
|
|
35
|
+
var _getAllByTestId = (0, _react.getAllByTestId)(container, ID),
|
|
36
|
+
_getAllByTestId2 = _slicedToArray(_getAllByTestId, 2),
|
|
37
|
+
formGroup = _getAllByTestId2[0],
|
|
38
|
+
textarea = _getAllByTestId2[1];
|
|
34
39
|
expect(formGroup.tagName).toEqual('DIV');
|
|
35
40
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
36
|
-
|
|
41
|
+
var label = formGroup.childNodes[0];
|
|
37
42
|
expect(label.innerHTML).toContain(LABEL);
|
|
38
43
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
39
44
|
expect(textarea.tagName).toEqual('TEXTAREA');
|
|
@@ -52,16 +57,16 @@ describe('utils.Component.get', () => {
|
|
|
52
57
|
value: 'Some text'
|
|
53
58
|
});
|
|
54
59
|
});
|
|
55
|
-
it('should return an appropriately rendered textarea component with a character count', ()
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
it('should return an appropriately rendered textarea component with a character count', function () {
|
|
61
|
+
var ID = 'test-id';
|
|
62
|
+
var FIELD_ID = 'field-id';
|
|
63
|
+
var LABEL = 'label';
|
|
64
|
+
var ROWS = 13;
|
|
65
|
+
var ON_CHANGE_CALLS = [];
|
|
66
|
+
var ON_CHANGE = function ON_CHANGE(e) {
|
|
62
67
|
ON_CHANGE_CALLS.push(e.target);
|
|
63
68
|
};
|
|
64
|
-
|
|
69
|
+
var COMPONENT = {
|
|
65
70
|
type: _models.ComponentTypes.TEXT_AREA,
|
|
66
71
|
id: ID,
|
|
67
72
|
fieldId: FIELD_ID,
|
|
@@ -71,13 +76,15 @@ describe('utils.Component.get', () => {
|
|
|
71
76
|
'data-testid': ID,
|
|
72
77
|
showCharacterCount: true
|
|
73
78
|
};
|
|
74
|
-
|
|
75
|
-
container
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
var _render2 = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
80
|
+
container = _render2.container;
|
|
81
|
+
var _getAllByTestId3 = (0, _react.getAllByTestId)(container, ID),
|
|
82
|
+
_getAllByTestId4 = _slicedToArray(_getAllByTestId3, 2),
|
|
83
|
+
formGroup = _getAllByTestId4[0],
|
|
84
|
+
textarea = _getAllByTestId4[1];
|
|
78
85
|
expect(formGroup.tagName).toEqual('DIV');
|
|
79
86
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
80
|
-
|
|
87
|
+
var label = formGroup.childNodes[0];
|
|
81
88
|
expect(label.innerHTML).toContain(LABEL);
|
|
82
89
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
83
90
|
expect(textarea.tagName).toEqual('TEXTAREA');
|
|
@@ -95,7 +102,7 @@ describe('utils.Component.get', () => {
|
|
|
95
102
|
name: FIELD_ID,
|
|
96
103
|
value: 'Some text'
|
|
97
104
|
});
|
|
98
|
-
|
|
105
|
+
var characterCount = formGroup.childNodes[2];
|
|
99
106
|
expect(characterCount.tagName).toEqual('DIV');
|
|
100
107
|
expect(characterCount.classList).toContain('govuk-hint');
|
|
101
108
|
expect(characterCount.textContent).toEqual('You have 1000 characters remaining');
|