@ukhomeoffice/cop-react-form-renderer 6.0.6-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.scss +2 -2
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +463 -769
- package/dist/components/CollectionPage/CollectionPage.js +75 -59
- package/dist/components/CollectionPage/CollectionPage.test.js +316 -366
- package/dist/components/CollectionSummary/BannerStrip.js +15 -14
- package/dist/components/CollectionSummary/BannerStrip.scss +2 -2
- package/dist/components/CollectionSummary/BannerStrip.test.js +98 -59
- package/dist/components/CollectionSummary/CollectionSummary.js +144 -135
- package/dist/components/CollectionSummary/CollectionSummary.scss +1 -1
- package/dist/components/CollectionSummary/CollectionSummary.test.js +167 -197
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.scss +1 -1
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +54 -56
- package/dist/components/CollectionSummary/RenderListView.scss +10 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +89 -78
- package/dist/components/CollectionSummary/SummaryCard.js +135 -145
- package/dist/components/CollectionSummary/SummaryCard.scss +2 -1
- package/dist/components/CollectionSummary/SummaryCard.test.js +943 -932
- package/dist/components/CollectionSummary/SummaryCardDetails.js +120 -62
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +43 -6
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +261 -120
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +38 -33
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +62 -73
- package/dist/components/FormComponent/Collection.js +81 -108
- package/dist/components/FormComponent/Collection.test.js +909 -943
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +80 -71
- 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.scss +1 -1
- package/dist/components/FormPage/FormPage.test.js +127 -163
- package/dist/components/FormRenderer/FormRenderer.js +150 -183
- package/dist/components/FormRenderer/FormRenderer.scss +1 -1
- 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 +50 -48
- package/dist/components/FormRenderer/onPageAction.test.js +241 -217
- 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.scss +2 -2
- 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.scss +1 -1
- 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 +65 -72
- package/dist/context/ValidationContext/ValidationContext.test.js +58 -61
- 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 +27 -40
- 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 -5
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +29 -24
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +3 -4
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +7 -27
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +29 -19
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +66 -22
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getErrorsForCollection.js +55 -0
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +153 -0
- package/dist/utils/CollectionPage/getQuickEditPage.js +37 -23
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +26 -45
- package/dist/utils/CollectionPage/index.js +3 -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 +16 -17
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +38 -20
- 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 +28 -19
- package/dist/utils/Condition/meetsCondition.test.js +476 -376
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +13 -18
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +3 -5
- package/dist/utils/Container/getEditableComponents.test.js +43 -45
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +16 -20
- package/dist/utils/Container/setupNesting.test.js +27 -30
- package/dist/utils/Container/showContainer.js +3 -7
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +38 -48
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +18 -26
- package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +29 -25
- package/dist/utils/Data/getOptions.test.js +93 -20
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +84 -80
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/nestInRefdataOptions.js +42 -0
- package/dist/utils/Data/nestInRefdataOptions.test.js +236 -0
- 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 +16 -19
- package/dist/utils/Validate/validateContainer.test.js +84 -45
- 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 +24 -18
- package/dist/utils/Validate/validatePage.test.js +263 -182
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +11 -18
- package/dist/utils/Validate/validateTime.test.js +16 -16
- package/dist/utils/index.js +7 -9
- package/package.json +5 -5
- 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/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/helpers/clearOutUncompletedRoutes.js +0 -175
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +0 -113
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +0 -20
- 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 radios component', () => {
|
|
14
|
+
const ID = 'test-id';
|
|
15
|
+
const FIELD_ID = 'field-id';
|
|
16
|
+
const LABEL = 'label';
|
|
17
|
+
const OPTIONS = [{
|
|
21
18
|
value: 'a',
|
|
22
19
|
label: 'Alpha'
|
|
23
20
|
}, {
|
|
24
21
|
value: 'b',
|
|
25
22
|
label: 'Bravo'
|
|
26
23
|
}];
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const ON_CHANGE_CALLS = [];
|
|
25
|
+
const ON_CHANGE = e => {
|
|
29
26
|
ON_CHANGE_CALLS.push(e.target);
|
|
30
27
|
};
|
|
31
|
-
|
|
28
|
+
const COMPONENT = {
|
|
32
29
|
type: _models.ComponentTypes.RADIOS,
|
|
33
30
|
id: ID,
|
|
34
31
|
fieldId: FIELD_ID,
|
|
@@ -39,16 +36,14 @@ describe('utils.Component.get', function () {
|
|
|
39
36
|
onChange: ON_CHANGE,
|
|
40
37
|
'data-testid': ID
|
|
41
38
|
};
|
|
42
|
-
|
|
43
|
-
container
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
formGroup = _getAllByTestId2[0],
|
|
47
|
-
radios = _getAllByTestId2[1];
|
|
39
|
+
const {
|
|
40
|
+
container
|
|
41
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
42
|
+
const [formGroup, radios] = (0, _react.getAllByTestId)(container, ID);
|
|
48
43
|
expect(formGroup.tagName).toEqual('DIV');
|
|
49
44
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
50
|
-
|
|
51
|
-
formGroup.childNodes.forEach(
|
|
45
|
+
let label;
|
|
46
|
+
formGroup.childNodes.forEach(node => {
|
|
52
47
|
// Check if it's an element.
|
|
53
48
|
if (node instanceof Element) {
|
|
54
49
|
if (node.tagName === 'LABEL') {
|
|
@@ -62,22 +57,20 @@ describe('utils.Component.get', function () {
|
|
|
62
57
|
expect(radios.tagName).toEqual('DIV');
|
|
63
58
|
expect(radios.classList).toContain('govuk-radios');
|
|
64
59
|
expect(radios.childNodes.length).toEqual(OPTIONS.length);
|
|
65
|
-
|
|
66
|
-
OPTIONS.forEach(
|
|
67
|
-
|
|
60
|
+
const radioItems = [];
|
|
61
|
+
OPTIONS.forEach((_, index) => {
|
|
62
|
+
const radio = radios.childNodes[index];
|
|
68
63
|
expect(radio instanceof Element).toBeTruthy();
|
|
69
64
|
if (radio instanceof Element) {
|
|
70
65
|
radioItems.push(radio);
|
|
71
66
|
}
|
|
72
67
|
});
|
|
73
68
|
expect(radioItems.length).toEqual(OPTIONS.length);
|
|
74
|
-
OPTIONS.forEach(
|
|
75
|
-
|
|
69
|
+
OPTIONS.forEach((option, index) => {
|
|
70
|
+
const radio = radioItems[index];
|
|
76
71
|
expect(radio.tagName).toEqual('DIV');
|
|
77
72
|
expect(radio.classList).toContain('govuk-radios__item');
|
|
78
|
-
|
|
79
|
-
input = _radio$childNodes[0],
|
|
80
|
-
inputLabel = _radio$childNodes[1];
|
|
73
|
+
const [input, inputLabel] = radio.childNodes;
|
|
81
74
|
expect(input.tagName).toEqual('INPUT');
|
|
82
75
|
expect(input.type).toEqual('radio');
|
|
83
76
|
expect(inputLabel.textContent).toEqual(option.label);
|
|
@@ -97,23 +90,22 @@ describe('utils.Component.get', function () {
|
|
|
97
90
|
_react.fireEvent.click(radioItems[1].childNodes[0]); // bravo (already selected, above)
|
|
98
91
|
expect(ON_CHANGE_CALLS.length).toEqual(2); // No change, so no new event should have fired.
|
|
99
92
|
});
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
var OPTIONS = [{
|
|
93
|
+
it('should work correctly with the returnFullData property on the radios component', () => {
|
|
94
|
+
const ID = 'test-id';
|
|
95
|
+
const FIELD_ID = 'field-id';
|
|
96
|
+
const LABEL = 'label';
|
|
97
|
+
const OPTIONS = [{
|
|
106
98
|
value: 'a',
|
|
107
99
|
label: 'Alpha'
|
|
108
100
|
}, {
|
|
109
101
|
value: 'b',
|
|
110
102
|
label: 'Bravo'
|
|
111
103
|
}];
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
const ON_CHANGE_CALLS = [];
|
|
105
|
+
const ON_CHANGE = e => {
|
|
114
106
|
ON_CHANGE_CALLS.push(e.target);
|
|
115
107
|
};
|
|
116
|
-
|
|
108
|
+
const COMPONENT = {
|
|
117
109
|
type: _models.ComponentTypes.RADIOS,
|
|
118
110
|
id: ID,
|
|
119
111
|
fieldId: FIELD_ID,
|
|
@@ -125,16 +117,14 @@ describe('utils.Component.get', function () {
|
|
|
125
117
|
onChange: ON_CHANGE,
|
|
126
118
|
'data-testid': ID
|
|
127
119
|
};
|
|
128
|
-
|
|
129
|
-
container
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
formGroup = _getAllByTestId4[0],
|
|
133
|
-
radios = _getAllByTestId4[1];
|
|
120
|
+
const {
|
|
121
|
+
container
|
|
122
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
123
|
+
const [formGroup, radios] = (0, _react.getAllByTestId)(container, ID);
|
|
134
124
|
expect(formGroup.tagName).toEqual('DIV');
|
|
135
125
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
136
|
-
|
|
137
|
-
formGroup.childNodes.forEach(
|
|
126
|
+
let label;
|
|
127
|
+
formGroup.childNodes.forEach(node => {
|
|
138
128
|
// Check if it's an element.
|
|
139
129
|
if (node instanceof Element) {
|
|
140
130
|
if (node.tagName === 'LABEL') {
|
|
@@ -148,22 +138,20 @@ describe('utils.Component.get', function () {
|
|
|
148
138
|
expect(radios.tagName).toEqual('DIV');
|
|
149
139
|
expect(radios.classList).toContain('govuk-radios');
|
|
150
140
|
expect(radios.childNodes.length).toEqual(OPTIONS.length);
|
|
151
|
-
|
|
152
|
-
OPTIONS.forEach(
|
|
153
|
-
|
|
141
|
+
const radioItems = [];
|
|
142
|
+
OPTIONS.forEach((_, index) => {
|
|
143
|
+
const radio = radios.childNodes[index];
|
|
154
144
|
expect(radio instanceof Element).toBeTruthy();
|
|
155
145
|
if (radio instanceof Element) {
|
|
156
146
|
radioItems.push(radio);
|
|
157
147
|
}
|
|
158
148
|
});
|
|
159
149
|
expect(radioItems.length).toEqual(OPTIONS.length);
|
|
160
|
-
OPTIONS.forEach(
|
|
161
|
-
|
|
150
|
+
OPTIONS.forEach((option, index) => {
|
|
151
|
+
const radio = radioItems[index];
|
|
162
152
|
expect(radio.tagName).toEqual('DIV');
|
|
163
153
|
expect(radio.classList).toContain('govuk-radios__item');
|
|
164
|
-
|
|
165
|
-
input = _radio$childNodes2[0],
|
|
166
|
-
inputLabel = _radio$childNodes2[1];
|
|
154
|
+
const [input, inputLabel] = radio.childNodes;
|
|
167
155
|
expect(input.tagName).toEqual('INPUT');
|
|
168
156
|
expect(input.type).toEqual('radio');
|
|
169
157
|
expect(inputLabel.textContent).toEqual(option.label);
|
|
@@ -183,17 +171,16 @@ describe('utils.Component.get', function () {
|
|
|
183
171
|
_react.fireEvent.click(radioItems[1].childNodes[0]); // bravo (already selected, above)
|
|
184
172
|
expect(ON_CHANGE_CALLS.length).toEqual(2); // No change, so no new event should have fired.
|
|
185
173
|
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
var NESTED = {
|
|
174
|
+
it('should return an appropriately rendered radios component with nested components', () => {
|
|
175
|
+
const ID = 'test-id';
|
|
176
|
+
const FIELD_ID = 'field-id';
|
|
177
|
+
const LABEL = 'label';
|
|
178
|
+
const NESTED = {
|
|
192
179
|
id: 'charle',
|
|
193
180
|
fieldId: 'charle',
|
|
194
181
|
type: 'text'
|
|
195
182
|
};
|
|
196
|
-
|
|
183
|
+
const OPTIONS = [{
|
|
197
184
|
value: 'a',
|
|
198
185
|
label: 'Alpha',
|
|
199
186
|
nested: [NESTED]
|
|
@@ -201,11 +188,11 @@ describe('utils.Component.get', function () {
|
|
|
201
188
|
value: 'b',
|
|
202
189
|
label: 'Bravo'
|
|
203
190
|
}];
|
|
204
|
-
|
|
205
|
-
|
|
191
|
+
const ON_CHANGE_CALLS = [];
|
|
192
|
+
const ON_CHANGE = e => {
|
|
206
193
|
ON_CHANGE_CALLS.push(e.target);
|
|
207
194
|
};
|
|
208
|
-
|
|
195
|
+
const COMPONENT = {
|
|
209
196
|
type: _models.ComponentTypes.RADIOS,
|
|
210
197
|
id: ID,
|
|
211
198
|
fieldId: FIELD_ID,
|
|
@@ -217,12 +204,10 @@ describe('utils.Component.get', function () {
|
|
|
217
204
|
onChange: ON_CHANGE,
|
|
218
205
|
'data-testid': ID
|
|
219
206
|
};
|
|
220
|
-
|
|
221
|
-
container
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
formGroup = _getAllByTestId6[0],
|
|
225
|
-
radios = _getAllByTestId6[1];
|
|
207
|
+
const {
|
|
208
|
+
container
|
|
209
|
+
} = (0, _setupTests.renderWithValidation)((0, _getComponent.default)(COMPONENT));
|
|
210
|
+
const [formGroup, radios] = (0, _react.getAllByTestId)(container, ID);
|
|
226
211
|
expect(formGroup.tagName).toEqual('DIV');
|
|
227
212
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
228
213
|
expect(radios.tagName).toEqual('DIV');
|
|
@@ -4,24 +4,21 @@ var _react = require("@testing-library/react");
|
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
7
|
+
// Global imports
|
|
8
|
+
|
|
13
9
|
// Local imports
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered select component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const NEW_VALUE = 'option2';
|
|
17
|
+
const ON_CHANGE_CALLS = [];
|
|
18
|
+
const ON_CHANGE = e => {
|
|
22
19
|
ON_CHANGE_CALLS.push(e.target);
|
|
23
20
|
};
|
|
24
|
-
|
|
21
|
+
const COMPONENT = {
|
|
25
22
|
type: _models.ComponentTypes.SELECT,
|
|
26
23
|
id: ID,
|
|
27
24
|
fieldId: FIELD_ID,
|
|
@@ -36,15 +33,13 @@ describe('utils.Component.get', function () {
|
|
|
36
33
|
}],
|
|
37
34
|
'data-testid': ID
|
|
38
35
|
};
|
|
39
|
-
|
|
40
|
-
container
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
formGroup = _getAllByTestId2[0],
|
|
44
|
-
select = _getAllByTestId2[1];
|
|
36
|
+
const {
|
|
37
|
+
container
|
|
38
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
39
|
+
const [formGroup, select] = (0, _react.getAllByTestId)(container, ID);
|
|
45
40
|
expect(formGroup.tagName).toEqual('DIV');
|
|
46
41
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
47
|
-
|
|
42
|
+
const label = formGroup.childNodes[0];
|
|
48
43
|
expect(label).toBeDefined();
|
|
49
44
|
expect(label.innerHTML).toContain(LABEL);
|
|
50
45
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
@@ -4,23 +4,20 @@ var _react = require("@testing-library/react");
|
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
7
|
+
// Global imports
|
|
8
|
+
|
|
13
9
|
// Local imports
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered text component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const ON_CHANGE_CALLS = [];
|
|
17
|
+
const ON_CHANGE = e => {
|
|
21
18
|
ON_CHANGE_CALLS.push(e.target);
|
|
22
19
|
};
|
|
23
|
-
|
|
20
|
+
const COMPONENT = {
|
|
24
21
|
type: _models.ComponentTypes.TEXT,
|
|
25
22
|
id: ID,
|
|
26
23
|
fieldId: FIELD_ID,
|
|
@@ -28,16 +25,14 @@ describe('utils.Component.get', function () {
|
|
|
28
25
|
onChange: ON_CHANGE,
|
|
29
26
|
'data-testid': ID
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
container
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
formGroup = _getAllByTestId2[0],
|
|
36
|
-
input = _getAllByTestId2[1];
|
|
28
|
+
const {
|
|
29
|
+
container
|
|
30
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
31
|
+
const [formGroup, input] = (0, _react.getAllByTestId)(container, ID);
|
|
37
32
|
expect(formGroup.tagName).toEqual('DIV');
|
|
38
33
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
39
|
-
|
|
40
|
-
formGroup.childNodes.forEach(
|
|
34
|
+
let label;
|
|
35
|
+
formGroup.childNodes.forEach(node => {
|
|
41
36
|
// Check if it's an element.
|
|
42
37
|
if (node instanceof Element && node.tagName === 'LABEL') {
|
|
43
38
|
label = node;
|
|
@@ -4,24 +4,21 @@ var _react = require("@testing-library/react");
|
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
7
|
+
// Global imports
|
|
8
|
+
|
|
13
9
|
// Local imports
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered textarea component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const ROWS = 13;
|
|
17
|
+
const ON_CHANGE_CALLS = [];
|
|
18
|
+
const ON_CHANGE = e => {
|
|
22
19
|
ON_CHANGE_CALLS.push(e.target);
|
|
23
20
|
};
|
|
24
|
-
|
|
21
|
+
const COMPONENT = {
|
|
25
22
|
type: _models.ComponentTypes.TEXT_AREA,
|
|
26
23
|
id: ID,
|
|
27
24
|
fieldId: FIELD_ID,
|
|
@@ -30,15 +27,13 @@ describe('utils.Component.get', function () {
|
|
|
30
27
|
onChange: ON_CHANGE,
|
|
31
28
|
'data-testid': ID
|
|
32
29
|
};
|
|
33
|
-
|
|
34
|
-
container
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
formGroup = _getAllByTestId2[0],
|
|
38
|
-
textarea = _getAllByTestId2[1];
|
|
30
|
+
const {
|
|
31
|
+
container
|
|
32
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
33
|
+
const [formGroup, textarea] = (0, _react.getAllByTestId)(container, ID);
|
|
39
34
|
expect(formGroup.tagName).toEqual('DIV');
|
|
40
35
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
41
|
-
|
|
36
|
+
const label = formGroup.childNodes[0];
|
|
42
37
|
expect(label.innerHTML).toContain(LABEL);
|
|
43
38
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
44
39
|
expect(textarea.tagName).toEqual('TEXTAREA');
|
|
@@ -57,16 +52,16 @@ describe('utils.Component.get', function () {
|
|
|
57
52
|
value: 'Some text'
|
|
58
53
|
});
|
|
59
54
|
});
|
|
60
|
-
it('should return an appropriately rendered textarea component with a character count',
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
it('should return an appropriately rendered textarea component with a character count', () => {
|
|
56
|
+
const ID = 'test-id';
|
|
57
|
+
const FIELD_ID = 'field-id';
|
|
58
|
+
const LABEL = 'label';
|
|
59
|
+
const ROWS = 13;
|
|
60
|
+
const ON_CHANGE_CALLS = [];
|
|
61
|
+
const ON_CHANGE = e => {
|
|
67
62
|
ON_CHANGE_CALLS.push(e.target);
|
|
68
63
|
};
|
|
69
|
-
|
|
64
|
+
const COMPONENT = {
|
|
70
65
|
type: _models.ComponentTypes.TEXT_AREA,
|
|
71
66
|
id: ID,
|
|
72
67
|
fieldId: FIELD_ID,
|
|
@@ -76,15 +71,13 @@ describe('utils.Component.get', function () {
|
|
|
76
71
|
'data-testid': ID,
|
|
77
72
|
showCharacterCount: true
|
|
78
73
|
};
|
|
79
|
-
|
|
80
|
-
container
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
formGroup = _getAllByTestId4[0],
|
|
84
|
-
textarea = _getAllByTestId4[1];
|
|
74
|
+
const {
|
|
75
|
+
container
|
|
76
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
77
|
+
const [formGroup, textarea] = (0, _react.getAllByTestId)(container, ID);
|
|
85
78
|
expect(formGroup.tagName).toEqual('DIV');
|
|
86
79
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
87
|
-
|
|
80
|
+
const label = formGroup.childNodes[0];
|
|
88
81
|
expect(label.innerHTML).toContain(LABEL);
|
|
89
82
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
90
83
|
expect(textarea.tagName).toEqual('TEXTAREA');
|
|
@@ -102,7 +95,7 @@ describe('utils.Component.get', function () {
|
|
|
102
95
|
name: FIELD_ID,
|
|
103
96
|
value: 'Some text'
|
|
104
97
|
});
|
|
105
|
-
|
|
98
|
+
const characterCount = formGroup.childNodes[2];
|
|
106
99
|
expect(characterCount.tagName).toEqual('DIV');
|
|
107
100
|
expect(characterCount.classList).toContain('govuk-hint');
|
|
108
101
|
expect(characterCount.textContent).toEqual('You have 1000 characters remaining');
|
|
@@ -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 time 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.TIME,
|
|
25
22
|
id: ID,
|
|
26
23
|
fieldId: FIELD_ID,
|
|
@@ -28,24 +25,20 @@ 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
|
-
timeInput = _getAllByTestId2[1];
|
|
28
|
+
const {
|
|
29
|
+
container
|
|
30
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
31
|
+
const [formGroup, timeInput] = (0, _react.getAllByTestId)(container, ID);
|
|
37
32
|
expect(formGroup.tagName).toEqual('DIV');
|
|
38
33
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
39
|
-
|
|
34
|
+
const label = formGroup.childNodes[0];
|
|
40
35
|
expect(label.innerHTML).toContain(LABEL);
|
|
41
36
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
42
37
|
expect(timeInput.tagName).toEqual('DIV');
|
|
43
38
|
expect(timeInput.classList).toContain('govuk-date-input');
|
|
44
39
|
expect(timeInput.id).toEqual(ID);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
hourItem = _timeInput$childNodes[0],
|
|
48
|
-
minuteItem = _timeInput$childNodes[1];
|
|
40
|
+
let onChangeCalls = ON_CHANGE_CALLS.length;
|
|
41
|
+
const [hourItem, minuteItem] = timeInput.childNodes;
|
|
49
42
|
[{
|
|
50
43
|
id: 'hour',
|
|
51
44
|
label: 'Hour',
|
|
@@ -58,12 +51,10 @@ describe('utils.Component.get', function () {
|
|
|
58
51
|
item: minuteItem,
|
|
59
52
|
value: '11',
|
|
60
53
|
expectedValue: '5:11'
|
|
61
|
-
}].forEach(
|
|
54
|
+
}].forEach(part => {
|
|
62
55
|
expect(part.item.tagName).toEqual('DIV');
|
|
63
56
|
expect(part.item.classList).toContain('govuk-date-input__item');
|
|
64
|
-
|
|
65
|
-
inputLabel = _part$item$childNodes[0],
|
|
66
|
-
input = _part$item$childNodes[1];
|
|
57
|
+
const [inputLabel, input] = part.item.childNodes[0].childNodes;
|
|
67
58
|
expect(inputLabel.tagName).toEqual('LABEL');
|
|
68
59
|
expect(inputLabel.classList).toContain('govuk-label');
|
|
69
60
|
expect(inputLabel.textContent).toEqual(part.label);
|
|
@@ -4,8 +4,8 @@ var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
|
4
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
5
|
// Local imports
|
|
6
6
|
|
|
7
|
-
describe('utils.Component.get',
|
|
8
|
-
it('should return null for an unknown type',
|
|
7
|
+
describe('utils.Component.get', () => {
|
|
8
|
+
it('should return null for an unknown type', () => {
|
|
9
9
|
expect((0, _getComponent.default)({
|
|
10
10
|
type: 'unknown'
|
|
11
11
|
})).toBeNull();
|
|
@@ -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 warning-text component',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered warning-text component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const CONTENT = 'Warning Text';
|
|
15
|
+
const COMPONENT = {
|
|
16
16
|
type: _models.ComponentTypes.WARNING,
|
|
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 warningText = (0, _react.getByTestId)(container, ID);
|
|
23
24
|
expect(warningText.innerHTML).toContain(CONTENT);
|
|
24
25
|
expect(warningText.tagName).toEqual('DIV');
|
|
25
26
|
expect(warningText.classList).toContain('govuk-warning-text');
|
|
@@ -6,18 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _models = require("../../models");
|
|
8
8
|
var _getDefaultValueFromConfig = _interopRequireDefault(require("./getDefaultValueFromConfig"));
|
|
9
|
-
var _DEFAULT_VALUES;
|
|
10
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var getDefaultValue = function getDefaultValue(component, formData) {
|
|
10
|
+
const DEFAULT_VALUES = {
|
|
11
|
+
[_models.ComponentTypes.COLLECTION]: [],
|
|
12
|
+
[_models.ComponentTypes.CONTAINER]: {}
|
|
13
|
+
};
|
|
14
|
+
const getDefaultValue = (component, formData) => {
|
|
17
15
|
if (!component) {
|
|
18
16
|
return '';
|
|
19
17
|
}
|
|
20
|
-
|
|
18
|
+
const defaultValue = (0, _getDefaultValueFromConfig.default)(component, formData);
|
|
21
19
|
return defaultValue || DEFAULT_VALUES[component.type] || '';
|
|
22
20
|
};
|
|
23
21
|
var _default = exports.default = getDefaultValue;
|