@ukhomeoffice/cop-react-form-renderer 6.14.0 → 6.14.2-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/components/CheckYourAnswers/Answer.js +12 -11
- package/dist/components/CheckYourAnswers/Answer.test.js +132 -181
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +98 -133
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +544 -939
- package/dist/components/CheckYourAnswers/index.js +1 -1
- package/dist/components/CollectionPage/CollectionPage.js +62 -60
- package/dist/components/CollectionPage/CollectionPage.test.js +315 -365
- package/dist/components/CollectionPage/index.js +1 -1
- package/dist/components/CollectionSummary/BannerStrip.js +14 -14
- package/dist/components/CollectionSummary/BannerStrip.test.js +79 -74
- package/dist/components/CollectionSummary/CollectionSummary.js +75 -97
- package/dist/components/CollectionSummary/CollectionSummary.test.js +182 -166
- package/dist/components/CollectionSummary/Confirmation.js +15 -13
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +34 -47
- package/dist/components/CollectionSummary/RenderListView.test.js +113 -111
- package/dist/components/CollectionSummary/SummaryCard.js +101 -133
- package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
- package/dist/components/CollectionSummary/SummaryCardButtons.js +25 -30
- package/dist/components/CollectionSummary/SummaryCardButtons.test.js +30 -28
- package/dist/components/CollectionSummary/SummaryCardDetails.js +59 -76
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +170 -180
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +63 -75
- package/dist/components/CollectionSummary/index.js +1 -1
- package/dist/components/FormComponent/Collection.js +63 -100
- package/dist/components/FormComponent/Collection.test.js +907 -1080
- package/dist/components/FormComponent/Container.js +35 -29
- package/dist/components/FormComponent/Container.test.js +378 -409
- package/dist/components/FormComponent/FormComponent.js +59 -63
- package/dist/components/FormComponent/FormComponent.test.js +354 -415
- 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 +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
- package/dist/components/FormComponent/helpers/index.js +5 -5
- package/dist/components/FormComponent/index.js +1 -1
- package/dist/components/FormPage/FormPage.js +70 -93
- package/dist/components/FormPage/FormPage.test.js +150 -202
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +131 -173
- package/dist/components/FormRenderer/FormRenderer.test.js +732 -1114
- package/dist/components/FormRenderer/handlers/cyaAction.js +3 -3
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
- package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
- package/dist/components/FormRenderer/handlers/index.js +2 -2
- package/dist/components/FormRenderer/handlers/navigate.js +4 -4
- 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 +16 -16
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -25
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
- package/dist/components/FormRenderer/helpers/getCYA.js +4 -6
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +6 -8
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +14 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +6 -6
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +104 -98
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +44 -51
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +68 -74
- package/dist/components/FormRenderer/helpers/index.js +2 -2
- package/dist/components/FormRenderer/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +43 -44
- package/dist/components/FormRenderer/onCYAAction.test.js +126 -133
- package/dist/components/FormRenderer/onPageAction.js +26 -35
- package/dist/components/FormRenderer/onPageAction.test.js +177 -186
- package/dist/components/FormRenderer/onTaskAction.js +11 -12
- package/dist/components/FormRenderer/onTaskAction.test.js +63 -68
- package/dist/components/PageActions/ActionButton.js +14 -14
- package/dist/components/PageActions/ActionButton.test.js +57 -79
- package/dist/components/PageActions/PageActions.js +11 -11
- package/dist/components/PageActions/PageActions.test.js +87 -116
- package/dist/components/PageActions/index.js +1 -1
- package/dist/components/SummaryList/GroupAction.js +10 -18
- package/dist/components/SummaryList/GroupAction.test.js +38 -34
- package/dist/components/SummaryList/RowAction.js +12 -17
- package/dist/components/SummaryList/RowAction.test.js +38 -34
- package/dist/components/SummaryList/SummaryList.js +23 -25
- package/dist/components/SummaryList/SummaryList.test.js +162 -189
- package/dist/components/SummaryList/SummaryListHeadingRow.js +7 -5
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
- package/dist/components/SummaryList/SummaryListRow.js +7 -5
- package/dist/components/SummaryList/SummaryListTitleRow.js +6 -4
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +23 -23
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +23 -23
- package/dist/components/SummaryList/helpers/index.js +2 -2
- package/dist/components/SummaryList/index.js +1 -1
- package/dist/components/TaskList/Task.js +20 -30
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +56 -79
- package/dist/components/TaskList/TaskList.test.js +149 -149
- package/dist/components/TaskList/TaskState.js +8 -6
- package/dist/components/TaskList/TaskState.test.js +53 -46
- package/dist/components/TaskList/index.js +1 -1
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +56 -79
- package/dist/context/HooksContext/HooksContext.test.js +27 -36
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +44 -95
- package/dist/context/ValidationContext/ValidationContext.test.js +57 -69
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +15 -41
- package/dist/hooks/useGetRequest.js +62 -98
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +25 -37
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +14 -15
- 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 +10 -10
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +12 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +32 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +15 -28
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +41 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +7 -7
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +27 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +48 -52
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +76 -93
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +14 -19
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +69 -73
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +7 -8
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +15 -16
- package/dist/utils/CheckYourAnswers/index.js +2 -2
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +5 -5
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -19
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +48 -39
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
- package/dist/utils/CollectionPage/getErrorsForCollection.js +20 -21
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
- package/dist/utils/CollectionPage/getQuickEditPage.js +22 -23
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +17 -18
- package/dist/utils/CollectionPage/index.js +2 -2
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +18 -18
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
- package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +25 -25
- package/dist/utils/Component/addShowWhen.js +5 -6
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +12 -15
- package/dist/utils/Component/applyToComponentTree.test.js +28 -31
- package/dist/utils/Component/cleanAttributes.js +12 -11
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +6 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
- package/dist/utils/Component/getComponent.js +79 -85
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +41 -58
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +24 -34
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +21 -26
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +11 -10
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +201 -226
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +58 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +32 -39
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +21 -30
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
- package/dist/utils/Component/getDefaultValue.js +7 -9
- package/dist/utils/Component/getDefaultValue.test.js +13 -13
- package/dist/utils/Component/getDefaultValueFromConfig.js +16 -20
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +32 -32
- package/dist/utils/Component/index.js +2 -2
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -4
- package/dist/utils/Component/optionIsSelected.test.js +12 -12
- package/dist/utils/Component/setupContainerComponentsPath.js +23 -28
- package/dist/utils/Component/setupContainerComponentsPath.test.js +12 -12
- package/dist/utils/Component/showComponent.js +2 -2
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +4 -4
- package/dist/utils/Condition/index.js +2 -2
- package/dist/utils/Condition/meetsAllConditions.js +9 -9
- package/dist/utils/Condition/meetsAllConditions.test.js +21 -21
- package/dist/utils/Condition/meetsCondition.js +17 -26
- package/dist/utils/Condition/meetsCondition.test.js +403 -403
- package/dist/utils/Condition/meetsOneCondition.js +6 -6
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +12 -15
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +4 -6
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +2 -2
- package/dist/utils/Container/setupNesting.js +14 -15
- package/dist/utils/Container/setupNesting.test.js +20 -23
- package/dist/utils/Container/showContainer.js +4 -8
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +30 -44
- package/dist/utils/Data/applyFormula.test.js +21 -21
- package/dist/utils/Data/deleteValues.js +4 -8
- package/dist/utils/Data/deleteValues.test.js +11 -11
- package/dist/utils/Data/getAutocompleteSource.js +72 -63
- package/dist/utils/Data/getAutocompleteSource.test.js +106 -98
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +13 -13
- package/dist/utils/Data/getOptions.js +35 -42
- package/dist/utils/Data/getOptions.test.js +37 -38
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +2 -2
- package/dist/utils/Data/nestInRefdataOptions.js +9 -12
- package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
- package/dist/utils/Data/refDataToOptions.js +9 -10
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +13 -20
- package/dist/utils/Data/setupFormData.test.js +48 -47
- package/dist/utils/Data/setupRefDataUrlForComponent.js +11 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +25 -25
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -8
- package/dist/utils/FormPage/applyConditionalProperties.test.js +14 -15
- package/dist/utils/FormPage/getConditionalText.js +4 -4
- package/dist/utils/FormPage/getConditionalText.test.js +30 -30
- package/dist/utils/FormPage/getFormPage.js +12 -15
- package/dist/utils/FormPage/getFormPage.test.js +23 -24
- package/dist/utils/FormPage/getFormPages.js +8 -11
- package/dist/utils/FormPage/getFormPages.test.js +15 -16
- package/dist/utils/FormPage/getPageActions.js +10 -13
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -5
- package/dist/utils/FormPage/showFormPage.js +4 -8
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +2 -2
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +15 -23
- package/dist/utils/FormPage/useComponent.test.js +49 -50
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -7
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +5 -6
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +2 -2
- package/dist/utils/Hub/getFormHub.js +2 -2
- package/dist/utils/Hub/getFormHub.test.js +23 -24
- package/dist/utils/Hub/index.js +2 -2
- 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 +25 -17
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +12 -13
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +70 -33
- package/dist/utils/Meta/index.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.js +3 -3
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/deleteValueInFormData.js +2 -2
- package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
- package/dist/utils/Operate/getFirstOf.js +6 -6
- package/dist/utils/Operate/getFirstOf.test.js +32 -32
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +11 -11
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/getLength.js +9 -9
- package/dist/utils/Operate/getLength.test.js +19 -19
- package/dist/utils/Operate/index.js +2 -2
- package/dist/utils/Operate/persistValueInFormData.js +4 -4
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +8 -8
- package/dist/utils/Operate/runPageOperations.test.js +24 -25
- package/dist/utils/Operate/setValueInFormData.js +3 -3
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +7 -7
- package/dist/utils/Operate/shouldRun.test.js +22 -24
- package/dist/utils/Validate/additional/conditionallyPermittedChange.js +1 -1
- package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +15 -15
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -8
- package/dist/utils/Validate/additional/index.test.js +22 -22
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -3
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -3
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -12
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -38
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -3
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +4 -4
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeOneOf.js +1 -1
- package/dist/utils/Validate/additional/mustBeOneOf.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +5 -5
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +35 -36
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +15 -15
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +2 -2
- package/dist/utils/Validate/validateCollection.js +18 -23
- package/dist/utils/Validate/validateCollection.test.js +75 -67
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +179 -154
- package/dist/utils/Validate/validateContainer.js +14 -17
- package/dist/utils/Validate/validateContainer.test.js +59 -53
- package/dist/utils/Validate/validateDate.js +16 -22
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +7 -9
- package/dist/utils/Validate/validateEmail.test.js +27 -27
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +13 -18
- package/dist/utils/Validate/validatePage.test.js +198 -195
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +15 -15
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +12 -19
- package/dist/utils/Validate/validateTime.test.js +27 -27
- package/dist/utils/index.js +5 -6
- package/package.json +2 -4
|
@@ -13,38 +13,38 @@ var _SummaryListHeadingRow = _interopRequireDefault(require("./SummaryListHeadin
|
|
|
13
13
|
var _SummaryListHeadingRowWithAction = _interopRequireDefault(require("./SummaryListHeadingRowWithAction"));
|
|
14
14
|
var _SummaryListTitleRow = _interopRequireDefault(require("./SummaryListTitleRow"));
|
|
15
15
|
require("./SummaryList.scss");
|
|
16
|
-
|
|
16
|
+
const _excluded = ["rows", "noChangeAction", "noGroupAction", "isGroup", "classBlock", "classModifiers", "className"]; // Global imports
|
|
17
17
|
// Local imports
|
|
18
18
|
// Styles
|
|
19
|
-
function _interopRequireDefault(
|
|
20
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
21
|
-
function _objectWithoutProperties(
|
|
22
|
-
function _objectWithoutPropertiesLoose(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
21
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
22
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
23
|
+
const DEFAULT_CLASS = exports.DEFAULT_CLASS = 'govuk-summary-list';
|
|
24
|
+
const SummaryList = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
rows,
|
|
27
|
+
noChangeAction,
|
|
28
|
+
noGroupAction,
|
|
29
|
+
isGroup,
|
|
30
|
+
classBlock,
|
|
31
|
+
classModifiers,
|
|
32
|
+
className
|
|
33
|
+
} = _ref,
|
|
32
34
|
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
const classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
|
|
36
|
+
const cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
|
|
37
|
+
let groupActionRow = null;
|
|
36
38
|
if (isGroup) {
|
|
37
|
-
|
|
38
|
-
return !!r.action;
|
|
39
|
-
});
|
|
39
|
+
const rowActions = rows.filter(r => !!r.action);
|
|
40
40
|
groupActionRow = rowActions !== null && rowActions !== void 0 && rowActions.length ? rowActions[0] : null;
|
|
41
41
|
}
|
|
42
42
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
43
43
|
className: "group-of-rows"
|
|
44
44
|
}, /*#__PURE__*/_react.default.createElement("dl", _extends({}, cleanedHtmlAttrs, {
|
|
45
45
|
className: classes()
|
|
46
|
-
}), rows.map(
|
|
47
|
-
|
|
46
|
+
}), rows.map(row => {
|
|
47
|
+
const key = "".concat(row.pageId, "_").concat(row.full_path || row.fieldId);
|
|
48
48
|
if (row.type === 'title') {
|
|
49
49
|
return /*#__PURE__*/_react.default.createElement(_SummaryListTitleRow.default, {
|
|
50
50
|
key: key,
|
|
@@ -80,9 +80,7 @@ var SummaryList = function SummaryList(_ref) {
|
|
|
80
80
|
classes: classes,
|
|
81
81
|
showAction: !noChangeAction
|
|
82
82
|
});
|
|
83
|
-
}).filter(
|
|
84
|
-
return !!r;
|
|
85
|
-
}), isGroup && !noGroupAction && /*#__PURE__*/_react.default.createElement("div", {
|
|
83
|
+
}).filter(r => !!r), isGroup && !noGroupAction && /*#__PURE__*/_react.default.createElement("div", {
|
|
86
84
|
className: "change-group-button"
|
|
87
85
|
}, /*#__PURE__*/_react.default.createElement(_GroupAction.default, {
|
|
88
86
|
group: groupActionRow
|
|
@@ -1,53 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
var _react = require("@testing-library/react");
|
|
5
4
|
var _react2 = _interopRequireDefault(require("react"));
|
|
6
5
|
var _SummaryList = _interopRequireWildcard(require("./SummaryList"));
|
|
7
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
8
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
9
|
-
function _interopRequireDefault(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
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); }
|
|
13
|
-
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; }
|
|
14
|
-
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; } }
|
|
15
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
6
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
7
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
// Global imports
|
|
10
|
+
|
|
16
11
|
// Local imports
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
|
|
13
|
+
describe('components', () => {
|
|
14
|
+
describe('SummaryList', () => {
|
|
15
|
+
const checkSummaryList = (container, id) => {
|
|
16
|
+
const summaryList = (0, _react.getByTestId)(container, id);
|
|
21
17
|
expect(summaryList.tagName).toEqual('DL');
|
|
22
18
|
expect(summaryList.classList).toContain(_SummaryList.DEFAULT_CLASS);
|
|
23
19
|
return summaryList;
|
|
24
20
|
};
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
const checkTitleRow = (summaryList, index) => {
|
|
22
|
+
const row = summaryList.childNodes[index];
|
|
27
23
|
expect(row.tagName).toEqual('DIV');
|
|
28
24
|
expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
|
|
29
25
|
expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__title"));
|
|
30
|
-
|
|
31
|
-
heading = _row$childNodes[0];
|
|
26
|
+
const [heading] = row.childNodes;
|
|
32
27
|
expect(heading.tagName).toEqual('H3');
|
|
33
28
|
expect(heading.classList).toContain('govuk-heading-s');
|
|
34
29
|
return heading;
|
|
35
30
|
};
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const checkActionRow = (summaryList, index) => {
|
|
32
|
+
const row = summaryList.childNodes[index];
|
|
38
33
|
expect(row.tagName).toEqual('DIV');
|
|
39
34
|
expect(row.childNodes.length).toEqual(1);
|
|
40
|
-
|
|
35
|
+
const link = row.childNodes[0];
|
|
41
36
|
return link;
|
|
42
37
|
};
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
const checkRow = (summaryList, index) => {
|
|
39
|
+
const row = summaryList.childNodes[index];
|
|
45
40
|
expect(row.tagName).toEqual('DIV');
|
|
46
41
|
expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
|
|
47
|
-
|
|
48
|
-
key = _row$childNodes2[0],
|
|
49
|
-
value = _row$childNodes2[1],
|
|
50
|
-
actions = _row$childNodes2[2];
|
|
42
|
+
const [key, value, actions] = row.childNodes;
|
|
51
43
|
expect(key.tagName).toEqual('DT');
|
|
52
44
|
expect(key.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__key"));
|
|
53
45
|
expect(value.tagName).toEqual('DD');
|
|
@@ -56,26 +48,22 @@ describe('components', function () {
|
|
|
56
48
|
expect(actions.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__actions"));
|
|
57
49
|
return [key, value, actions];
|
|
58
50
|
};
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
const checkHeadingRowWithAction = (summaryList, index) => {
|
|
52
|
+
const row = summaryList.childNodes[index];
|
|
61
53
|
expect(row.tagName).toEqual('DIV');
|
|
62
54
|
expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__headingWithAction"));
|
|
63
|
-
|
|
64
|
-
key = _row$childNodes3[0],
|
|
65
|
-
action = _row$childNodes3[1];
|
|
55
|
+
const [key, action] = row.childNodes;
|
|
66
56
|
expect(key.tagName).toEqual('TD');
|
|
67
57
|
expect(key.classList).toContain('heading-text');
|
|
68
58
|
expect(action.tagName).toEqual('TD');
|
|
69
59
|
expect(action.classList).toContain('heading-action');
|
|
70
60
|
return [key, action];
|
|
71
61
|
};
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
const checkRowNoChangeActions = (summaryList, index) => {
|
|
63
|
+
const row = summaryList.childNodes[index];
|
|
74
64
|
expect(row.tagName).toEqual('DIV');
|
|
75
65
|
expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
|
|
76
|
-
|
|
77
|
-
key = _row$childNodes4[0],
|
|
78
|
-
value = _row$childNodes4[1];
|
|
66
|
+
const [key, value] = row.childNodes;
|
|
79
67
|
expect(key.tagName).toEqual('DT');
|
|
80
68
|
expect(key.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__key"));
|
|
81
69
|
expect(value.tagName).toEqual('DD');
|
|
@@ -83,20 +71,21 @@ describe('components', function () {
|
|
|
83
71
|
expect(row.childNodes.length).toEqual(2);
|
|
84
72
|
return [key, value];
|
|
85
73
|
};
|
|
86
|
-
it('should handle an empty rows array',
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
74
|
+
it('should handle an empty rows array', () => {
|
|
75
|
+
const ID = 'test-id';
|
|
76
|
+
const ROWS = [];
|
|
77
|
+
const {
|
|
78
|
+
container
|
|
79
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
80
|
+
"data-testid": ID,
|
|
81
|
+
rows: ROWS
|
|
82
|
+
}));
|
|
83
|
+
const summaryList = checkSummaryList(container, ID);
|
|
95
84
|
expect(summaryList.childNodes.length).toEqual(0);
|
|
96
85
|
});
|
|
97
|
-
it('should handle rows with no actions and string values',
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
it('should handle rows with no actions and string values', () => {
|
|
87
|
+
const ID = 'test-id';
|
|
88
|
+
const ROWS = [{
|
|
100
89
|
key: 'a',
|
|
101
90
|
pageId: 'p1',
|
|
102
91
|
fieldId: 'a',
|
|
@@ -107,28 +96,25 @@ describe('components', function () {
|
|
|
107
96
|
fieldId: 'b',
|
|
108
97
|
value: 'Bravo value'
|
|
109
98
|
}];
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
const {
|
|
100
|
+
container
|
|
101
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
102
|
+
"data-testid": ID,
|
|
103
|
+
rows: ROWS,
|
|
104
|
+
noGroupAction: true
|
|
105
|
+
}));
|
|
106
|
+
const summaryList = checkSummaryList(container, ID);
|
|
117
107
|
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
118
|
-
ROWS.forEach(
|
|
119
|
-
|
|
120
|
-
_checkRow2 = _slicedToArray(_checkRow, 3),
|
|
121
|
-
key = _checkRow2[0],
|
|
122
|
-
value = _checkRow2[1],
|
|
123
|
-
actions = _checkRow2[2];
|
|
108
|
+
ROWS.forEach((row, index) => {
|
|
109
|
+
const [key, value, actions] = checkRow(summaryList, index);
|
|
124
110
|
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
125
111
|
expect(value.textContent).toEqual(row.value);
|
|
126
112
|
expect(actions.childNodes.length).toEqual(0);
|
|
127
113
|
});
|
|
128
114
|
});
|
|
129
|
-
it('should handle title rows',
|
|
130
|
-
|
|
131
|
-
|
|
115
|
+
it('should handle title rows', () => {
|
|
116
|
+
const ID = 'test-id';
|
|
117
|
+
const ROWS = [{
|
|
132
118
|
key: 'Title',
|
|
133
119
|
pageId: 'p1',
|
|
134
120
|
fieldId: 'a',
|
|
@@ -144,28 +130,25 @@ describe('components', function () {
|
|
|
144
130
|
fieldId: 'c',
|
|
145
131
|
value: 'Bravo value'
|
|
146
132
|
}];
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
133
|
+
const {
|
|
134
|
+
container
|
|
135
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
136
|
+
"data-testid": ID,
|
|
137
|
+
rows: ROWS
|
|
138
|
+
}));
|
|
139
|
+
const summaryList = checkSummaryList(container, ID);
|
|
153
140
|
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
154
|
-
|
|
155
|
-
|
|
141
|
+
const assessTitleRow = (row, index) => {
|
|
142
|
+
const heading = checkTitleRow(summaryList, index);
|
|
156
143
|
expect(heading.textContent).toEqual(row.key);
|
|
157
144
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
_checkRow4 = _slicedToArray(_checkRow3, 3),
|
|
161
|
-
key = _checkRow4[0],
|
|
162
|
-
value = _checkRow4[1],
|
|
163
|
-
actions = _checkRow4[2];
|
|
145
|
+
const assessRow = (row, index) => {
|
|
146
|
+
const [key, value, actions] = checkRow(summaryList, index);
|
|
164
147
|
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
165
148
|
expect(value.textContent).toEqual(row.value);
|
|
166
149
|
expect(actions.childNodes.length).toEqual(0);
|
|
167
150
|
};
|
|
168
|
-
ROWS.forEach(
|
|
151
|
+
ROWS.forEach((row, index) => {
|
|
169
152
|
if (row.type === 'title') {
|
|
170
153
|
assessTitleRow(row, index);
|
|
171
154
|
} else {
|
|
@@ -173,9 +156,9 @@ describe('components', function () {
|
|
|
173
156
|
}
|
|
174
157
|
});
|
|
175
158
|
});
|
|
176
|
-
it('should handle action rows',
|
|
177
|
-
|
|
178
|
-
|
|
159
|
+
it('should handle action rows', () => {
|
|
160
|
+
const ID = 'test-id';
|
|
161
|
+
const ROWS = [{
|
|
179
162
|
key: 'a',
|
|
180
163
|
pageId: 'p1',
|
|
181
164
|
fieldId: 'a',
|
|
@@ -200,24 +183,25 @@ describe('components', function () {
|
|
|
200
183
|
label: 'Do action'
|
|
201
184
|
}
|
|
202
185
|
}];
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
186
|
+
const {
|
|
187
|
+
container
|
|
188
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
189
|
+
"data-testid": ID,
|
|
190
|
+
rows: ROWS
|
|
191
|
+
}));
|
|
192
|
+
const summaryList = checkSummaryList(container, ID);
|
|
209
193
|
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
210
|
-
|
|
211
|
-
|
|
194
|
+
const assessActionRow = (row, index) => {
|
|
195
|
+
const link = checkActionRow(summaryList, index);
|
|
212
196
|
expect(link.textContent).toEqual(row.action.label);
|
|
213
197
|
};
|
|
214
|
-
ROWS.forEach(
|
|
198
|
+
ROWS.forEach((row, index) => {
|
|
215
199
|
assessActionRow(row, index);
|
|
216
200
|
});
|
|
217
201
|
});
|
|
218
|
-
it('should hide actions rows if flag is given',
|
|
219
|
-
|
|
220
|
-
|
|
202
|
+
it('should hide actions rows if flag is given', () => {
|
|
203
|
+
const ID = 'test-id';
|
|
204
|
+
const ROWS = [{
|
|
221
205
|
key: 'a',
|
|
222
206
|
pageId: 'p1',
|
|
223
207
|
fieldId: 'a',
|
|
@@ -242,19 +226,20 @@ describe('components', function () {
|
|
|
242
226
|
label: 'Do action'
|
|
243
227
|
}
|
|
244
228
|
}];
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
229
|
+
const {
|
|
230
|
+
container
|
|
231
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
232
|
+
"data-testid": ID,
|
|
233
|
+
rows: ROWS,
|
|
234
|
+
noChangeAction: true
|
|
235
|
+
}));
|
|
236
|
+
const summaryList = checkSummaryList(container, ID);
|
|
252
237
|
expect(summaryList.childNodes.length).toEqual(0);
|
|
253
238
|
});
|
|
254
|
-
it('should handle rows with no actions and component values',
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
239
|
+
it('should handle rows with no actions and component values', () => {
|
|
240
|
+
const ID = 'test-id';
|
|
241
|
+
const VALUES = ['Alpha component value', 'Bravo component value'];
|
|
242
|
+
const ROWS = [{
|
|
258
243
|
key: 'a',
|
|
259
244
|
pageId: 'p1',
|
|
260
245
|
fieldId: 'a',
|
|
@@ -265,34 +250,31 @@ describe('components', function () {
|
|
|
265
250
|
fieldId: 'b',
|
|
266
251
|
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[1])
|
|
267
252
|
}];
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
253
|
+
const {
|
|
254
|
+
container
|
|
255
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
256
|
+
"data-testid": ID,
|
|
257
|
+
rows: ROWS
|
|
258
|
+
}));
|
|
259
|
+
const summaryList = checkSummaryList(container, ID);
|
|
274
260
|
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
275
|
-
ROWS.forEach(
|
|
276
|
-
|
|
277
|
-
_checkRow6 = _slicedToArray(_checkRow5, 3),
|
|
278
|
-
key = _checkRow6[0],
|
|
279
|
-
value = _checkRow6[1],
|
|
280
|
-
actions = _checkRow6[2];
|
|
261
|
+
ROWS.forEach((row, index) => {
|
|
262
|
+
const [key, value, actions] = checkRow(summaryList, index);
|
|
281
263
|
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
282
264
|
expect(value.childNodes.length).toEqual(1);
|
|
283
|
-
|
|
265
|
+
const valueDiv = value.childNodes[0];
|
|
284
266
|
expect(valueDiv.tagName).toEqual('DIV');
|
|
285
267
|
expect(valueDiv.textContent).toEqual(VALUES[index]);
|
|
286
268
|
expect(actions.childNodes.length).toEqual(0);
|
|
287
269
|
});
|
|
288
270
|
});
|
|
289
|
-
it('should handle rows with actions',
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
271
|
+
it('should handle rows with actions', () => {
|
|
272
|
+
const ID = 'test-id';
|
|
273
|
+
const ON_ACTION_CALLS = [];
|
|
274
|
+
const ON_ACTION = row => {
|
|
293
275
|
ON_ACTION_CALLS.push(row);
|
|
294
276
|
};
|
|
295
|
-
|
|
277
|
+
const ROWS = [{
|
|
296
278
|
key: 'a',
|
|
297
279
|
pageId: 'p1',
|
|
298
280
|
fieldId: 'a',
|
|
@@ -311,35 +293,32 @@ describe('components', function () {
|
|
|
311
293
|
onAction: ON_ACTION
|
|
312
294
|
}
|
|
313
295
|
}];
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
296
|
+
const {
|
|
297
|
+
container
|
|
298
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
299
|
+
"data-testid": ID,
|
|
300
|
+
rows: ROWS
|
|
301
|
+
}));
|
|
302
|
+
const summaryList = checkSummaryList(container, ID);
|
|
320
303
|
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
321
|
-
ROWS.forEach(
|
|
322
|
-
|
|
323
|
-
_checkRow8 = _slicedToArray(_checkRow7, 3),
|
|
324
|
-
key = _checkRow8[0],
|
|
325
|
-
value = _checkRow8[1],
|
|
326
|
-
actions = _checkRow8[2];
|
|
304
|
+
ROWS.forEach((row, index) => {
|
|
305
|
+
const [key, value, actions] = checkRow(summaryList, index);
|
|
327
306
|
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
328
307
|
expect(value.textContent).toEqual(row.value);
|
|
329
|
-
|
|
308
|
+
const a = actions.childNodes[0];
|
|
330
309
|
expect(a.textContent).toEqual(row.action.label);
|
|
331
310
|
_react.fireEvent.click(a, {});
|
|
332
311
|
expect(ON_ACTION_CALLS.length).toEqual(index + 1);
|
|
333
312
|
expect(ON_ACTION_CALLS[index]).toEqual(row);
|
|
334
313
|
});
|
|
335
314
|
});
|
|
336
|
-
it('should handle heading rows with actions',
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
315
|
+
it('should handle heading rows with actions', () => {
|
|
316
|
+
const ID = 'test-id';
|
|
317
|
+
const ON_ACTION_CALLS = [];
|
|
318
|
+
const ON_ACTION = row => {
|
|
340
319
|
ON_ACTION_CALLS.push(row);
|
|
341
320
|
};
|
|
342
|
-
|
|
321
|
+
const ROWS = [{
|
|
343
322
|
key: 'a',
|
|
344
323
|
pageId: 'p1',
|
|
345
324
|
type: 'headingWithAction',
|
|
@@ -358,20 +337,18 @@ describe('components', function () {
|
|
|
358
337
|
onAction: ON_ACTION
|
|
359
338
|
}
|
|
360
339
|
}];
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
340
|
+
const {
|
|
341
|
+
container
|
|
342
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
343
|
+
"data-testid": ID,
|
|
344
|
+
rows: ROWS
|
|
345
|
+
}));
|
|
346
|
+
const summaryList = checkSummaryList(container, ID);
|
|
367
347
|
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
368
|
-
ROWS.forEach(
|
|
369
|
-
|
|
370
|
-
_checkHeadingRowWithA2 = _slicedToArray(_checkHeadingRowWithA, 2),
|
|
371
|
-
key = _checkHeadingRowWithA2[0],
|
|
372
|
-
actions = _checkHeadingRowWithA2[1];
|
|
348
|
+
ROWS.forEach((row, index) => {
|
|
349
|
+
const [key, actions] = checkHeadingRowWithAction(summaryList, index);
|
|
373
350
|
expect(key.textContent).toEqual("".concat(row.key));
|
|
374
|
-
|
|
351
|
+
const a = actions.childNodes[0];
|
|
375
352
|
expect(a.textContent).toEqual(row.action.label);
|
|
376
353
|
_react.fireEvent.click(a, {});
|
|
377
354
|
expect(ON_ACTION_CALLS.length).toEqual(index + 1);
|
|
@@ -380,10 +357,10 @@ describe('components', function () {
|
|
|
380
357
|
});
|
|
381
358
|
});
|
|
382
359
|
});
|
|
383
|
-
it('should handle rows with component values and actions set to hidden',
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
360
|
+
it('should handle rows with component values and actions set to hidden', () => {
|
|
361
|
+
const ID = 'test-id';
|
|
362
|
+
const VALUES = ['Alpha component value', 'Bravo component value'];
|
|
363
|
+
const ROWS = [{
|
|
387
364
|
key: 'a',
|
|
388
365
|
pageId: 'p1',
|
|
389
366
|
fieldId: 'a',
|
|
@@ -394,31 +371,29 @@ describe('components', function () {
|
|
|
394
371
|
fieldId: 'b',
|
|
395
372
|
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[1])
|
|
396
373
|
}];
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
374
|
+
const {
|
|
375
|
+
container
|
|
376
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
377
|
+
"data-testid": ID,
|
|
378
|
+
rows: ROWS,
|
|
379
|
+
noChangeAction: true
|
|
380
|
+
}));
|
|
381
|
+
const summaryList = checkSummaryList(container, ID);
|
|
404
382
|
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
405
|
-
ROWS.forEach(
|
|
406
|
-
|
|
407
|
-
_checkRowNoChangeActi2 = _slicedToArray(_checkRowNoChangeActi, 2),
|
|
408
|
-
key = _checkRowNoChangeActi2[0],
|
|
409
|
-
value = _checkRowNoChangeActi2[1];
|
|
383
|
+
ROWS.forEach((row, index) => {
|
|
384
|
+
const [key, value] = checkRowNoChangeActions(summaryList, index);
|
|
410
385
|
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
411
386
|
expect(value.childNodes.length).toEqual(1);
|
|
412
|
-
|
|
387
|
+
const valueDiv = value.childNodes[0];
|
|
413
388
|
expect(valueDiv.tagName).toEqual('DIV');
|
|
414
389
|
expect(valueDiv.textContent).toEqual(VALUES[index]);
|
|
415
390
|
});
|
|
416
391
|
});
|
|
417
|
-
it('should render groups of rows correctly',
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
392
|
+
it('should render groups of rows correctly', () => {
|
|
393
|
+
const ID = 'test-id';
|
|
394
|
+
const VALUES = ['Alpha component value', 'Bravo component value', 'Charlie component value'];
|
|
395
|
+
const ISGROUP = true;
|
|
396
|
+
const ROWS = [{
|
|
422
397
|
key: 'a',
|
|
423
398
|
pageId: 'p1',
|
|
424
399
|
fieldId: 'a',
|
|
@@ -437,22 +412,20 @@ describe('components', function () {
|
|
|
437
412
|
fieldId: 'c',
|
|
438
413
|
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[2])
|
|
439
414
|
}];
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
415
|
+
const {
|
|
416
|
+
container
|
|
417
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
418
|
+
"data-testid": ID,
|
|
419
|
+
rows: ROWS,
|
|
420
|
+
isGroup: ISGROUP
|
|
421
|
+
}));
|
|
422
|
+
const summaryList = checkSummaryList(container, ID);
|
|
447
423
|
expect(summaryList.childNodes.length).toEqual(ROWS.length + 1);
|
|
448
|
-
ROWS.forEach(
|
|
449
|
-
|
|
450
|
-
_checkRow10 = _slicedToArray(_checkRow9, 2),
|
|
451
|
-
key = _checkRow10[0],
|
|
452
|
-
value = _checkRow10[1];
|
|
424
|
+
ROWS.forEach((row, index) => {
|
|
425
|
+
const [key, value] = checkRow(summaryList, index);
|
|
453
426
|
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
454
427
|
expect(value.childNodes.length).toEqual(1);
|
|
455
|
-
|
|
428
|
+
const valueDiv = value.childNodes[0];
|
|
456
429
|
expect(valueDiv.tagName).toEqual('DIV');
|
|
457
430
|
expect(valueDiv.textContent).toEqual(VALUES[index]);
|
|
458
431
|
});
|
|
@@ -7,13 +7,15 @@ exports.default = void 0;
|
|
|
7
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
function _interopRequireDefault(
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
// Global imports
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const SummaryListHeadingRow = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
title,
|
|
16
|
+
size,
|
|
17
|
+
classes
|
|
18
|
+
} = _ref;
|
|
17
19
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
18
20
|
className: "".concat(classes('heading'))
|
|
19
21
|
}, size === 's' && /*#__PURE__*/_react.default.createElement(_copReactComponents.SmallHeading, null, title), size === 'm' && /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, title));
|