@ukhomeoffice/cop-react-form-renderer 6.5.1-peter → 6.7.0-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 +463 -769
- package/dist/components/CollectionPage/CollectionPage.js +73 -63
- package/dist/components/CollectionPage/CollectionPage.test.js +316 -366
- package/dist/components/CollectionSummary/BannerStrip.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.test.js +80 -76
- package/dist/components/CollectionSummary/CollectionSummary.js +97 -107
- package/dist/components/CollectionSummary/CollectionSummary.test.js +152 -142
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +45 -51
- package/dist/components/CollectionSummary/RenderListView.test.js +78 -77
- package/dist/components/CollectionSummary/SummaryCard.js +104 -135
- package/dist/components/CollectionSummary/SummaryCard.test.js +930 -962
- package/dist/components/CollectionSummary/SummaryCardDetails.js +72 -71
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +128 -135
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +30 -35
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +62 -74
- package/dist/components/FormComponent/Collection.js +74 -108
- package/dist/components/FormComponent/Collection.test.js +909 -1081
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +69 -72
- package/dist/components/FormComponent/FormComponent.test.js +353 -414
- 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 +143 -179
- 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 +15 -15
- 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 +103 -97
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -78
- package/dist/components/FormRenderer/helpers/index.js +2 -4
- package/dist/components/FormRenderer/onCYAAction.js +59 -51
- package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
- package/dist/components/FormRenderer/onPageAction.js +44 -47
- package/dist/components/FormRenderer/onPageAction.test.js +223 -213
- 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 +57 -80
- package/dist/context/HooksContext/HooksContext.test.js +26 -35
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +43 -94
- package/dist/context/ValidationContext/ValidationContext.test.js +56 -68
- 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 +29 -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 -61
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +83 -89
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +164 -138
- 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/getComponentRowForCYA.js +11 -11
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +7 -7
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +18 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +55 -26
- 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/getErrorsForCollection.js +24 -24
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +20 -22
- package/dist/utils/CollectionPage/getQuickEditPage.js +36 -28
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +26 -45
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +31 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +20 -20
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
- 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 -72
- 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 +8 -8
- package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
- package/dist/utils/Condition/meetsCondition.js +16 -25
- package/dist/utils/Condition/meetsCondition.test.js +402 -402
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +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 +24 -30
- package/dist/utils/Data/getOptions.test.js +27 -27
- 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/nestInRefdataOptions.js +9 -16
- package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
- 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/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- 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/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +2 -4
- 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 +77 -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 -78
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +13 -16
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- 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 -52
- 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 -27
- 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/mustBeUniqueInCollection.js +8 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +64 -32
- 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 +15 -20
- package/dist/utils/Validate/validateContainer.test.js +58 -52
- package/dist/utils/Validate/validateDate.js +15 -21
- package/dist/utils/Validate/validateDate.test.js +31 -32
- 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 +19 -22
- package/dist/utils/Validate/validatePage.test.js +215 -203
- 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 +11 -18
- package/dist/utils/Validate/validateTime.test.js +16 -16
- package/dist/utils/index.js +7 -9
- package/package.json +2 -2
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-data.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-form.json +0 -61
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-after.json +0 -429
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-before.json +0 -449
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-form.json +0 -15219
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-after.json +0 -516
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-before.json +0 -593
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab2-form.json +0 -15219
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-after.json +0 -84
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-before.json +0 -98
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-form.json +0 -9158
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collection-data-removed.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collections.json +0 -8
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components.json +0 -5
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-entire-collection-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-component-removed.json +0 -10
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-components.json +0 -11
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-for-nested-components.json +0 -96
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections-delete-entire.json +0 -47
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections.json +0 -46
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-components.json +0 -48
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test.json +0 -1605
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test2.json +0 -205
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +0 -206
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +0 -143
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +0 -26
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.test.js +0 -56
|
@@ -5,30 +5,27 @@ var _models = require("../../../models");
|
|
|
5
5
|
var _setupTests = require("../../../setupTests");
|
|
6
6
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
8
|
+
// Global imports
|
|
9
|
+
|
|
14
10
|
// Local imports
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
|
|
12
|
+
describe('utils.Component.get', () => {
|
|
13
|
+
it('should return an appropriately rendered checkboxes component', () => {
|
|
14
|
+
const ID = 'test-id';
|
|
15
|
+
const FIELD_ID = 'field-id';
|
|
16
|
+
const LABEL = 'label';
|
|
17
|
+
const OPTIONS = [{
|
|
21
18
|
value: 'a',
|
|
22
19
|
label: 'Alpha'
|
|
23
20
|
}, {
|
|
24
21
|
value: 'b',
|
|
25
22
|
label: 'Bravo'
|
|
26
23
|
}];
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const ON_CHANGE_CALLS = [];
|
|
25
|
+
const ON_CHANGE = e => {
|
|
29
26
|
ON_CHANGE_CALLS.push(e.target);
|
|
30
27
|
};
|
|
31
|
-
|
|
28
|
+
const COMPONENT = {
|
|
32
29
|
type: _models.ComponentTypes.CHECKBOXES,
|
|
33
30
|
id: ID,
|
|
34
31
|
fieldId: FIELD_ID,
|
|
@@ -39,16 +36,14 @@ describe('utils.Component.get', function () {
|
|
|
39
36
|
onChange: ON_CHANGE,
|
|
40
37
|
'data-testid': ID
|
|
41
38
|
};
|
|
42
|
-
|
|
43
|
-
container
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
formGroup = _getAllByTestId2[0],
|
|
47
|
-
checkboxes = _getAllByTestId2[1];
|
|
39
|
+
const {
|
|
40
|
+
container
|
|
41
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
42
|
+
const [formGroup, checkboxes] = (0, _react.getAllByTestId)(container, ID);
|
|
48
43
|
expect(formGroup.tagName).toEqual('DIV');
|
|
49
44
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
50
|
-
|
|
51
|
-
formGroup.childNodes.forEach(
|
|
45
|
+
let label;
|
|
46
|
+
formGroup.childNodes.forEach(node => {
|
|
52
47
|
// Check if it's an element.
|
|
53
48
|
if (node instanceof Element) {
|
|
54
49
|
if (node.tagName === 'LABEL') {
|
|
@@ -62,22 +57,20 @@ describe('utils.Component.get', function () {
|
|
|
62
57
|
expect(checkboxes.tagName).toEqual('DIV');
|
|
63
58
|
expect(checkboxes.classList).toContain('govuk-checkboxes');
|
|
64
59
|
expect(checkboxes.childNodes.length).toEqual(OPTIONS.length);
|
|
65
|
-
|
|
66
|
-
OPTIONS.forEach(
|
|
67
|
-
|
|
60
|
+
const checkboxItems = [];
|
|
61
|
+
OPTIONS.forEach((_, index) => {
|
|
62
|
+
const checkbox = checkboxes.childNodes[index];
|
|
68
63
|
expect(checkbox instanceof Element).toBeTruthy();
|
|
69
64
|
if (checkbox instanceof Element) {
|
|
70
65
|
checkboxItems.push(checkbox);
|
|
71
66
|
}
|
|
72
67
|
});
|
|
73
68
|
expect(checkboxItems.length).toEqual(OPTIONS.length);
|
|
74
|
-
OPTIONS.forEach(
|
|
75
|
-
|
|
69
|
+
OPTIONS.forEach((option, index) => {
|
|
70
|
+
const checkbox = checkboxItems[index];
|
|
76
71
|
expect(checkbox.tagName).toEqual('DIV');
|
|
77
72
|
expect(checkbox.classList).toContain('govuk-checkboxes__item');
|
|
78
|
-
|
|
79
|
-
input = _checkbox$childNodes[0],
|
|
80
|
-
inputLabel = _checkbox$childNodes[1];
|
|
73
|
+
const [input, inputLabel] = checkbox.childNodes;
|
|
81
74
|
expect(input.tagName).toEqual('INPUT');
|
|
82
75
|
expect(input.type).toEqual('checkbox');
|
|
83
76
|
expect(inputLabel.textContent).toEqual(option.label);
|
|
@@ -101,16 +94,16 @@ describe('utils.Component.get', function () {
|
|
|
101
94
|
value: [OPTIONS[1].value]
|
|
102
95
|
});
|
|
103
96
|
});
|
|
104
|
-
it('should return an appropriately rendered checkboxes component with a nested component',
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
97
|
+
it('should return an appropriately rendered checkboxes component with a nested component', () => {
|
|
98
|
+
const ID = 'test-id';
|
|
99
|
+
const FIELD_ID = 'field-id';
|
|
100
|
+
const LABEL = 'label';
|
|
101
|
+
const NESTED = {
|
|
109
102
|
id: 'charle',
|
|
110
103
|
fieldId: 'charle',
|
|
111
104
|
type: 'text'
|
|
112
105
|
};
|
|
113
|
-
|
|
106
|
+
const OPTIONS = [{
|
|
114
107
|
value: 'a',
|
|
115
108
|
label: 'Alpha',
|
|
116
109
|
nested: [NESTED]
|
|
@@ -118,11 +111,11 @@ describe('utils.Component.get', function () {
|
|
|
118
111
|
value: 'b',
|
|
119
112
|
label: 'Bravo'
|
|
120
113
|
}];
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
const ON_CHANGE_CALLS = [];
|
|
115
|
+
const ON_CHANGE = e => {
|
|
123
116
|
ON_CHANGE_CALLS.push(e.target);
|
|
124
117
|
};
|
|
125
|
-
|
|
118
|
+
const COMPONENT = {
|
|
126
119
|
type: _models.ComponentTypes.CHECKBOXES,
|
|
127
120
|
id: ID,
|
|
128
121
|
fieldId: FIELD_ID,
|
|
@@ -134,16 +127,14 @@ describe('utils.Component.get', function () {
|
|
|
134
127
|
onChange: ON_CHANGE,
|
|
135
128
|
'data-testid': ID
|
|
136
129
|
};
|
|
137
|
-
|
|
138
|
-
container
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
formGroup = _getAllByTestId4[0],
|
|
142
|
-
checkboxes = _getAllByTestId4[1];
|
|
130
|
+
const {
|
|
131
|
+
container
|
|
132
|
+
} = (0, _setupTests.renderWithValidation)((0, _getComponent.default)(COMPONENT));
|
|
133
|
+
const [formGroup, checkboxes] = (0, _react.getAllByTestId)(container, ID);
|
|
143
134
|
expect(formGroup.tagName).toEqual('DIV');
|
|
144
135
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
145
|
-
|
|
146
|
-
formGroup.childNodes.forEach(
|
|
136
|
+
let label;
|
|
137
|
+
formGroup.childNodes.forEach(node => {
|
|
147
138
|
// Check if it's an element.
|
|
148
139
|
if (node instanceof Element) {
|
|
149
140
|
if (node.tagName === 'LABEL') {
|
|
@@ -4,23 +4,20 @@ var _react = require("@testing-library/react");
|
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
7
|
+
// Global imports
|
|
8
|
+
|
|
13
9
|
// Local imports
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered date component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const ON_CHANGE_CALLS = [];
|
|
17
|
+
const ON_CHANGE = e => {
|
|
21
18
|
ON_CHANGE_CALLS.push(e.target);
|
|
22
19
|
};
|
|
23
|
-
|
|
20
|
+
const COMPONENT = {
|
|
24
21
|
type: _models.ComponentTypes.DATE,
|
|
25
22
|
id: ID,
|
|
26
23
|
fieldId: FIELD_ID,
|
|
@@ -28,13 +25,11 @@ describe('utils.Component.get', function () {
|
|
|
28
25
|
onChange: ON_CHANGE,
|
|
29
26
|
'data-testid': ID
|
|
30
27
|
};
|
|
31
|
-
|
|
28
|
+
const checkDateField = (node, option) => {
|
|
32
29
|
expect(node.tagName).toEqual('DIV');
|
|
33
30
|
expect(node.classList).toContain('govuk-date-input__item');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
label = _group$childNodes[0],
|
|
37
|
-
input = _group$childNodes[1];
|
|
31
|
+
const group = node.childNodes[0]; // form group
|
|
32
|
+
const [label, input] = group.childNodes;
|
|
38
33
|
expect(label.tagName).toEqual('LABEL');
|
|
39
34
|
expect(label.classList).toContain('govuk-label');
|
|
40
35
|
expect(label.textContent).toEqual(option.label);
|
|
@@ -42,33 +37,28 @@ describe('utils.Component.get', function () {
|
|
|
42
37
|
expect(input.id).toEqual(option.id);
|
|
43
38
|
return input;
|
|
44
39
|
};
|
|
45
|
-
|
|
46
|
-
container
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
formGroup = _getAllByTestId2[0],
|
|
50
|
-
dateInput = _getAllByTestId2[1];
|
|
40
|
+
const {
|
|
41
|
+
container
|
|
42
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
43
|
+
const [formGroup, dateInput] = (0, _react.getAllByTestId)(container, ID);
|
|
51
44
|
expect(formGroup.tagName).toEqual('DIV');
|
|
52
45
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
53
|
-
|
|
46
|
+
const label = formGroup.childNodes[0];
|
|
54
47
|
expect(label.innerHTML).toContain(LABEL);
|
|
55
48
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
56
49
|
expect(dateInput.tagName).toEqual('DIV');
|
|
57
50
|
expect(dateInput.classList).toContain('govuk-date-input');
|
|
58
51
|
expect(dateInput.id).toEqual(ID);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
monthItem = _dateInput$childNodes[1],
|
|
62
|
-
yearItem = _dateInput$childNodes[2];
|
|
63
|
-
var dayInput = checkDateField(dayItem, {
|
|
52
|
+
const [dayItem, monthItem, yearItem] = dateInput.childNodes;
|
|
53
|
+
const dayInput = checkDateField(dayItem, {
|
|
64
54
|
id: "".concat(ID, "-day"),
|
|
65
55
|
label: 'Day'
|
|
66
56
|
});
|
|
67
|
-
|
|
57
|
+
const monthInput = checkDateField(monthItem, {
|
|
68
58
|
id: "".concat(ID, "-month"),
|
|
69
59
|
label: 'Month'
|
|
70
60
|
});
|
|
71
|
-
|
|
61
|
+
const yearInput = checkDateField(yearItem, {
|
|
72
62
|
id: "".concat(ID, "-year"),
|
|
73
63
|
label: 'Year'
|
|
74
64
|
});
|
|
@@ -8,40 +8,42 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
8
8
|
|
|
9
9
|
// Local imports
|
|
10
10
|
|
|
11
|
-
describe('utils.Component.get',
|
|
12
|
-
it('should return a details component containing basic text',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return a details component containing basic text', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const CONTENT = 'Details content';
|
|
15
|
+
const SUMMARY = 'Details Summary';
|
|
16
|
+
const COMPONENT = {
|
|
17
17
|
type: _models.ComponentTypes.DETAILS,
|
|
18
18
|
content: CONTENT,
|
|
19
19
|
summary: SUMMARY,
|
|
20
20
|
'data-testid': ID
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
container
|
|
24
|
-
|
|
22
|
+
const {
|
|
23
|
+
container
|
|
24
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
25
|
+
const details = container.querySelector('details');
|
|
25
26
|
expect(details.classList).toContain('hods-details');
|
|
26
27
|
expect(details.childNodes[0].textContent).toEqual(SUMMARY);
|
|
27
28
|
expect(details.childNodes[1].textContent).toEqual(CONTENT);
|
|
28
29
|
});
|
|
29
|
-
it('should return a details component containing multiple html components',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
it('should return a details component containing multiple html components', () => {
|
|
31
|
+
const ID = 'test-id';
|
|
32
|
+
const CONTENT = '<p>this is the content</p><ol><li>one</li><li>two</li></ol><p>second section of content</p>';
|
|
33
|
+
const SUMMARY = 'Details Summary';
|
|
34
|
+
const COMPONENT = {
|
|
34
35
|
type: _models.ComponentTypes.DETAILS,
|
|
35
36
|
content: CONTENT,
|
|
36
37
|
summary: SUMMARY,
|
|
37
38
|
tagName: 'div',
|
|
38
39
|
'data-testid': ID
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
-
container
|
|
42
|
-
|
|
41
|
+
const {
|
|
42
|
+
container
|
|
43
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
44
|
+
const details = container.querySelector('details');
|
|
43
45
|
expect(details.classList).toContain('hods-details');
|
|
44
|
-
|
|
46
|
+
const content = details.childNodes[1].childNodes[0].childNodes;
|
|
45
47
|
expect(content[0].textContent).toEqual('this is the content');
|
|
46
48
|
expect(content[0].tagName).toEqual('P');
|
|
47
49
|
expect(content[1].childNodes[0].textContent).toEqual('one');
|
|
@@ -4,23 +4,20 @@ var _react = require("@testing-library/react");
|
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
7
|
+
// Global imports
|
|
8
|
+
|
|
13
9
|
// Local imports
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered email component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const ON_CHANGE_CALLS = [];
|
|
17
|
+
const ON_CHANGE = e => {
|
|
21
18
|
ON_CHANGE_CALLS.push(e.target);
|
|
22
19
|
};
|
|
23
|
-
|
|
20
|
+
const COMPONENT = {
|
|
24
21
|
type: _models.ComponentTypes.EMAIL,
|
|
25
22
|
id: ID,
|
|
26
23
|
fieldId: FIELD_ID,
|
|
@@ -28,16 +25,14 @@ describe('utils.Component.get', function () {
|
|
|
28
25
|
onChange: ON_CHANGE,
|
|
29
26
|
'data-testid': ID
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
container
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
formGroup = _getAllByTestId2[0],
|
|
36
|
-
input = _getAllByTestId2[1];
|
|
28
|
+
const {
|
|
29
|
+
container
|
|
30
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
31
|
+
const [formGroup, input] = (0, _react.getAllByTestId)(container, ID);
|
|
37
32
|
expect(formGroup.tagName).toEqual('DIV');
|
|
38
33
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
39
|
-
|
|
40
|
-
formGroup.childNodes.forEach(
|
|
34
|
+
let label;
|
|
35
|
+
formGroup.childNodes.forEach(node => {
|
|
41
36
|
// Check if it's an element.
|
|
42
37
|
if (node instanceof Element && node.tagName === 'LABEL') {
|
|
43
38
|
label = node;
|
|
@@ -5,23 +5,20 @@ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
|
5
5
|
var _models = require("../../../models");
|
|
6
6
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
8
|
+
// Global imports
|
|
9
|
+
|
|
14
10
|
// Local imports
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
|
|
12
|
+
describe('utils.Component.get', () => {
|
|
13
|
+
it('should return an appropriately rendered file component', () => {
|
|
14
|
+
const ID = 'test-id';
|
|
15
|
+
const FIELD_ID = 'field-id';
|
|
16
|
+
const LABEL = 'label';
|
|
17
|
+
const ON_CHANGE_CALLS = [];
|
|
18
|
+
const ON_CHANGE = e => {
|
|
22
19
|
ON_CHANGE_CALLS.push(e.target);
|
|
23
20
|
};
|
|
24
|
-
|
|
21
|
+
const COMPONENT = {
|
|
25
22
|
type: _models.ComponentTypes.FILE,
|
|
26
23
|
id: ID,
|
|
27
24
|
fieldId: FIELD_ID,
|
|
@@ -29,16 +26,14 @@ describe('utils.Component.get', function () {
|
|
|
29
26
|
onChange: ON_CHANGE,
|
|
30
27
|
'data-testid': ID
|
|
31
28
|
};
|
|
32
|
-
|
|
33
|
-
container
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
formGroup = _getAllByTestId2[0],
|
|
37
|
-
input = _getAllByTestId2[1];
|
|
29
|
+
const {
|
|
30
|
+
container
|
|
31
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
32
|
+
const [formGroup, input] = (0, _react.getAllByTestId)(container, ID);
|
|
38
33
|
expect(formGroup.tagName).toEqual('DIV');
|
|
39
34
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
40
|
-
|
|
41
|
-
formGroup.childNodes.forEach(
|
|
35
|
+
let label;
|
|
36
|
+
formGroup.childNodes.forEach(node => {
|
|
42
37
|
// Check if it's an element.
|
|
43
38
|
if (node instanceof Element && node.tagName === 'LABEL') {
|
|
44
39
|
label = node;
|
|
@@ -50,11 +45,11 @@ describe('utils.Component.get', function () {
|
|
|
50
45
|
expect(input.tagName).toEqual('INPUT');
|
|
51
46
|
expect(input.classList).toContain('hods-file-upload__select');
|
|
52
47
|
expect(input.id).toEqual("".concat(ID, "-select"));
|
|
53
|
-
|
|
48
|
+
const str = JSON.stringify({
|
|
54
49
|
alpha: 'bravo'
|
|
55
50
|
});
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const blob = new Blob([str]);
|
|
52
|
+
const FILE = new File([blob], 'test.json', {
|
|
58
53
|
type: 'application/JSON'
|
|
59
54
|
});
|
|
60
55
|
_userEvent.default.upload(input, FILE);
|
|
@@ -8,20 +8,21 @@ 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 an appropriately rendered heading component',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered heading component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const SIZE = 'm';
|
|
15
|
+
const CONTENT = 'Heading text';
|
|
16
|
+
const COMPONENT = {
|
|
17
17
|
type: _models.ComponentTypes.HEADING,
|
|
18
18
|
size: SIZE,
|
|
19
19
|
content: CONTENT,
|
|
20
20
|
'data-testid': ID
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
container
|
|
24
|
-
|
|
22
|
+
const {
|
|
23
|
+
container
|
|
24
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
25
|
+
const heading = (0, _react.getByTestId)(container, ID);
|
|
25
26
|
expect(heading.innerHTML).toContain(CONTENT);
|
|
26
27
|
expect(heading.tagName).toEqual('H2');
|
|
27
28
|
expect(heading.classList).toContain("govuk-heading-".concat(SIZE));
|
|
@@ -8,32 +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 by default for an HTML component',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return a p tag by default for an HTML component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const CONTENT = 'HTML content';
|
|
15
|
+
const COMPONENT = {
|
|
16
16
|
type: _models.ComponentTypes.HTML,
|
|
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
|
});
|
|
26
|
-
it('should return an appropriate tag for an HTML component',
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
it('should return an appropriate tag for an HTML component', () => {
|
|
28
|
+
const ID = 'test-id';
|
|
29
|
+
const TAG_NAME = 'hr';
|
|
30
|
+
const COMPONENT = {
|
|
30
31
|
type: _models.ComponentTypes.HTML,
|
|
31
32
|
tagName: TAG_NAME,
|
|
32
33
|
'data-testid': ID
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
-
container
|
|
36
|
-
|
|
35
|
+
const {
|
|
36
|
+
container
|
|
37
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
38
|
+
const hr = (0, _react.getByTestId)(container, ID);
|
|
37
39
|
expect(hr.tagName).toEqual('HR');
|
|
38
40
|
});
|
|
39
41
|
});
|
|
@@ -8,18 +8,19 @@ 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 an appropriately rendered inset-text component',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered inset-text component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const CONTENT = 'Inset text';
|
|
15
|
+
const COMPONENT = {
|
|
16
16
|
type: _models.ComponentTypes.INSET_TEXT,
|
|
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 insetText = (0, _react.getByTestId)(container, ID);
|
|
23
24
|
expect(insetText.innerHTML).toContain(CONTENT);
|
|
24
25
|
expect(insetText.tagName).toEqual('DIV');
|
|
25
26
|
expect(insetText.classList).toContain('govuk-inset-text');
|
|
@@ -8,35 +8,37 @@ 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 ul tag and correct className for an unordered list component',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return a ul tag and correct className for an unordered list component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const ITEMS = ['paragraph content1', 'paragraph content2'];
|
|
15
|
+
const COMPONENT = {
|
|
16
16
|
type: _models.ComponentTypes.LIST,
|
|
17
17
|
ordered: false,
|
|
18
18
|
items: ITEMS,
|
|
19
19
|
'data-testid': ID
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
container
|
|
23
|
-
|
|
21
|
+
const {
|
|
22
|
+
container
|
|
23
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
24
|
+
const ul = (0, _react.getByTestId)(container, ID);
|
|
24
25
|
expect(ul.innerHTML).toContain('<li>paragraph content1</li><li>paragraph content2</li>');
|
|
25
26
|
expect(ul.tagName).toEqual('UL');
|
|
26
27
|
expect(ul.className).toEqual('govuk-list govuk-list--bullet');
|
|
27
28
|
});
|
|
28
|
-
it('should return a ol tag and correct className for an ordered list component',
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
it('should return a ol tag and correct className for an ordered list component', () => {
|
|
30
|
+
const ID = 'test-id';
|
|
31
|
+
const ITEMS = ['paragraph content1', 'paragraph content2'];
|
|
32
|
+
const COMPONENT = {
|
|
32
33
|
type: _models.ComponentTypes.LIST,
|
|
33
34
|
ordered: true,
|
|
34
35
|
items: ITEMS,
|
|
35
36
|
'data-testid': ID
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
container
|
|
39
|
-
|
|
38
|
+
const {
|
|
39
|
+
container
|
|
40
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
41
|
+
const ol = (0, _react.getByTestId)(container, ID);
|
|
40
42
|
expect(ol.innerHTML).toContain('<li>paragraph content1</li><li>paragraph content2</li>');
|
|
41
43
|
expect(ol.tagName).toEqual('OL');
|
|
42
44
|
expect(ol.className).toEqual('govuk-list govuk-list--number');
|