@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
|
@@ -1,6 +1,5 @@
|
|
|
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
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -12,61 +11,49 @@ var _models = require("../../models");
|
|
|
12
11
|
var _Task = _interopRequireDefault(require("./Task"));
|
|
13
12
|
var _showComponent = _interopRequireDefault(require("../../utils/Component/showComponent"));
|
|
14
13
|
require("./TaskList.scss");
|
|
15
|
-
|
|
14
|
+
const _excluded = ["id", "refTitle", "refNumber", "notes", "incompleteTitle", "showCompletionOverview", "sections", "fieldId", "onTaskAction", "classBlock", "classModifiers", "className", "formData", "annotations"];
|
|
16
15
|
/* eslint-disable import/no-duplicates */
|
|
17
16
|
// Global Imports
|
|
18
17
|
// Local Imports
|
|
19
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
20
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
21
|
-
function _interopRequireDefault(
|
|
22
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
23
|
-
function
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
classModifiers = _ref.classModifiers,
|
|
45
|
-
className = _ref.className,
|
|
46
|
-
formData = _ref.formData,
|
|
47
|
-
annotations = _ref.annotations,
|
|
18
|
+
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); }
|
|
19
|
+
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; }
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
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); }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
const DEFAULT_CLASS = exports.DEFAULT_CLASS = 'hods-task-list';
|
|
25
|
+
const DEFAULT_INCOMPLETE_TITLE = exports.DEFAULT_INCOMPLETE_TITLE = 'Incomplete form';
|
|
26
|
+
const TaskList = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
id,
|
|
29
|
+
refTitle,
|
|
30
|
+
refNumber,
|
|
31
|
+
notes,
|
|
32
|
+
incompleteTitle,
|
|
33
|
+
showCompletionOverview,
|
|
34
|
+
sections,
|
|
35
|
+
fieldId,
|
|
36
|
+
onTaskAction,
|
|
37
|
+
classBlock,
|
|
38
|
+
classModifiers,
|
|
39
|
+
className,
|
|
40
|
+
formData,
|
|
41
|
+
annotations
|
|
42
|
+
} = _ref,
|
|
48
43
|
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
const classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
|
|
45
|
+
const cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
|
|
51
46
|
// TODO state will be retrieved from a document in S3 rather than given in the component definition, covered under COP-9885
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
_sections$filter$redu2 = _slicedToArray(_sections$filter$redu, 2),
|
|
63
|
-
completeSections = _sections$filter$redu2[0],
|
|
64
|
-
totalSections = _sections$filter$redu2[1];
|
|
65
|
-
var notesId = "".concat(id, "Notes");
|
|
66
|
-
var _ref2 = notes && notes || {},
|
|
67
|
-
notesTitle = _ref2.title,
|
|
68
|
-
notesText = _ref2.text;
|
|
69
|
-
var onClick = function onClick(task) {
|
|
47
|
+
const [completeSections, totalSections] = sections.filter(section => !section.skipped).reduce((acc, current) => {
|
|
48
|
+
var _current$tasks$filter, _current$tasks, _current$tasks$filter2, _current$tasks2;
|
|
49
|
+
return [acc[0] + ((_current$tasks$filter = (_current$tasks = current.tasks) === null || _current$tasks === void 0 ? void 0 : _current$tasks.filter(t => t.state === _models.TaskStates.TYPES.COMPLETE).length) !== null && _current$tasks$filter !== void 0 ? _current$tasks$filter : 0), acc[1] + ((_current$tasks$filter2 = (_current$tasks2 = current.tasks) === null || _current$tasks2 === void 0 ? void 0 : _current$tasks2.filter(task => task.state !== _models.TaskStates.TYPES.SKIPPED).length) !== null && _current$tasks$filter2 !== void 0 ? _current$tasks$filter2 : 0)];
|
|
50
|
+
}, [0, 0]);
|
|
51
|
+
const notesId = "".concat(id, "Notes");
|
|
52
|
+
const {
|
|
53
|
+
title: notesTitle,
|
|
54
|
+
text: notesText
|
|
55
|
+
} = notes && notes || {};
|
|
56
|
+
const onClick = task => {
|
|
70
57
|
if (typeof onTaskAction === 'function') {
|
|
71
58
|
onTaskAction(task);
|
|
72
59
|
}
|
|
@@ -80,15 +67,13 @@ var TaskList = function TaskList(_ref) {
|
|
|
80
67
|
className: "tasklist-summary"
|
|
81
68
|
}, "".concat(refTitle))), /*#__PURE__*/_react.default.createElement("p", {
|
|
82
69
|
className: "govuk-body govuk-!-font-weight-regular"
|
|
83
|
-
}, "".concat(refNumber))), annotations.length > 0 && annotations.map(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}, _copReactComponents.Utils.interpolateString(annotation.value, formData)));
|
|
91
|
-
}), showCompletionOverview && totalSections !== completeSections && /*#__PURE__*/_react.default.createElement("p", {
|
|
70
|
+
}, "".concat(refNumber))), annotations.length > 0 && annotations.map(annotation => /*#__PURE__*/_react.default.createElement("div", {
|
|
71
|
+
className: classes('annotation')
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement("p", {
|
|
73
|
+
className: "".concat(classes('annotation-key'), " govuk-body")
|
|
74
|
+
}, _copReactComponents.Utils.interpolateString(annotation.key, formData)), /*#__PURE__*/_react.default.createElement("p", {
|
|
75
|
+
className: "".concat(classes('annotation-value'), " govuk-body")
|
|
76
|
+
}, _copReactComponents.Utils.interpolateString(annotation.value, formData)))), showCompletionOverview && totalSections !== completeSections && /*#__PURE__*/_react.default.createElement("p", {
|
|
92
77
|
className: "govuk-body govuk-!-margin-bottom-0"
|
|
93
78
|
}, /*#__PURE__*/_react.default.createElement("strong", {
|
|
94
79
|
className: "tasklist-summary"
|
|
@@ -103,25 +88,17 @@ var TaskList = function TaskList(_ref) {
|
|
|
103
88
|
fieldId: notesId,
|
|
104
89
|
readOnly: true,
|
|
105
90
|
value: _copReactComponents.Utils.interpolateString(notesText, formData)
|
|
106
|
-
})), sections.filter(
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}).map(function (task) {
|
|
118
|
-
return /*#__PURE__*/_react.default.createElement(_Task.default, {
|
|
119
|
-
key: "".concat(section.name, "-").concat(task.name),
|
|
120
|
-
task: task,
|
|
121
|
-
onClick: onClick
|
|
122
|
-
});
|
|
123
|
-
})));
|
|
124
|
-
}));
|
|
91
|
+
})), sections.filter(section => !section.skipped).map((section, index) => /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
92
|
+
key: "".concat(section.name)
|
|
93
|
+
}, /*#__PURE__*/_react.default.createElement("h2", {
|
|
94
|
+
className: classes('section')
|
|
95
|
+
}, sections.length > 1 ? "".concat(index + 1, ". ") : '', section.name), section.label && /*#__PURE__*/_react.default.createElement(_copReactComponents.Hint, null, section.label), /*#__PURE__*/_react.default.createElement("ol", {
|
|
96
|
+
className: classes('items')
|
|
97
|
+
}, section.tasks.filter(task => task.state !== _models.TaskStates.TYPES.SKIPPED).map(task => /*#__PURE__*/_react.default.createElement(_Task.default, {
|
|
98
|
+
key: "".concat(section.name, "-").concat(task.name),
|
|
99
|
+
task: task,
|
|
100
|
+
onClick: onClick
|
|
101
|
+
}))))));
|
|
125
102
|
};
|
|
126
103
|
TaskList.propTypes = {
|
|
127
104
|
classBlock: _propTypes.default.string,
|
|
@@ -1,25 +1,21 @@
|
|
|
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 _TaskList = _interopRequireWildcard(require("./TaskList"));
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
|
|
13
|
+
describe('components', () => {
|
|
14
|
+
describe('TaskList', () => {
|
|
15
|
+
it('should render a TaskList', () => {
|
|
16
|
+
const COP_REF = '123';
|
|
17
|
+
const REF_TITLE = 'COP reference number';
|
|
18
|
+
const sections = [{
|
|
23
19
|
name: 'These are your tasks',
|
|
24
20
|
label: 'This is the label for your first tasks',
|
|
25
21
|
tasks: [{
|
|
@@ -52,26 +48,19 @@ describe('components', function () {
|
|
|
52
48
|
pages: ['pageSix']
|
|
53
49
|
}]
|
|
54
50
|
}];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
const {
|
|
52
|
+
container
|
|
53
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
54
|
+
refNumber: COP_REF,
|
|
55
|
+
refTitle: REF_TITLE,
|
|
56
|
+
sections: sections
|
|
57
|
+
}));
|
|
58
|
+
const {
|
|
59
|
+
childNodes
|
|
60
|
+
} = container;
|
|
62
61
|
expect(childNodes.length).toEqual(1);
|
|
63
62
|
expect(childNodes[0].childNodes.length).toEqual(10);
|
|
64
|
-
|
|
65
|
-
referenceHeading = _childNodes$0$childNo[0],
|
|
66
|
-
referenceNumber = _childNodes$0$childNo[1],
|
|
67
|
-
incompleteForm = _childNodes$0$childNo[2],
|
|
68
|
-
numComplete = _childNodes$0$childNo[3],
|
|
69
|
-
subSectionOneHeading = _childNodes$0$childNo[4],
|
|
70
|
-
subSectionOneLabel = _childNodes$0$childNo[5],
|
|
71
|
-
subSectionOneList = _childNodes$0$childNo[6],
|
|
72
|
-
subSectionTwoHeading = _childNodes$0$childNo[7],
|
|
73
|
-
subSectionTwoLabel = _childNodes$0$childNo[8],
|
|
74
|
-
subSectionTwoList = _childNodes$0$childNo[9];
|
|
63
|
+
const [referenceHeading, referenceNumber, incompleteForm, numComplete, subSectionOneHeading, subSectionOneLabel, subSectionOneList, subSectionTwoHeading, subSectionTwoLabel, subSectionTwoList] = childNodes[0].childNodes;
|
|
75
64
|
expect(referenceHeading).toMatchObject({
|
|
76
65
|
tagName: 'P',
|
|
77
66
|
textContent: 'COP reference number'
|
|
@@ -101,10 +90,10 @@ describe('components', function () {
|
|
|
101
90
|
expect(subSectionTwoLabel.textContent).toEqual('This is the label for your extra tasks');
|
|
102
91
|
expect(subSectionTwoList.childNodes.length).toEqual(3);
|
|
103
92
|
});
|
|
104
|
-
it('should not render the incomplete title and message when showCompletionOverview is false',
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
it('should not render the incomplete title and message when showCompletionOverview is false', () => {
|
|
94
|
+
const COP_REF = '123';
|
|
95
|
+
const REF_TITLE = 'COP reference number';
|
|
96
|
+
const sections = [{
|
|
108
97
|
name: 'These are your tasks',
|
|
109
98
|
label: 'This is the label for your first tasks',
|
|
110
99
|
tasks: [{
|
|
@@ -137,26 +126,21 @@ describe('components', function () {
|
|
|
137
126
|
pages: ['pageSix']
|
|
138
127
|
}]
|
|
139
128
|
}];
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
129
|
+
const {
|
|
130
|
+
container
|
|
131
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
132
|
+
refNumber: COP_REF,
|
|
133
|
+
refTitle: REF_TITLE,
|
|
134
|
+
sections: sections,
|
|
135
|
+
showCompletionOverview: false
|
|
136
|
+
}));
|
|
137
|
+
const {
|
|
138
|
+
childNodes
|
|
139
|
+
} = container;
|
|
148
140
|
expect(childNodes.length).toEqual(1);
|
|
149
141
|
expect(childNodes[0].childNodes.length).toEqual(8); // Without incomplete heading and message.
|
|
150
142
|
|
|
151
|
-
|
|
152
|
-
referenceHeading = _childNodes$0$childNo2[0],
|
|
153
|
-
referenceNumber = _childNodes$0$childNo2[1],
|
|
154
|
-
subSectionOneHeading = _childNodes$0$childNo2[2],
|
|
155
|
-
subSectionOneLabel = _childNodes$0$childNo2[3],
|
|
156
|
-
subSectionOneList = _childNodes$0$childNo2[4],
|
|
157
|
-
subSectionTwoHeading = _childNodes$0$childNo2[5],
|
|
158
|
-
subSectionTwoLabel = _childNodes$0$childNo2[6],
|
|
159
|
-
subSectionTwoList = _childNodes$0$childNo2[7];
|
|
143
|
+
const [referenceHeading, referenceNumber, subSectionOneHeading, subSectionOneLabel, subSectionOneList, subSectionTwoHeading, subSectionTwoLabel, subSectionTwoList] = childNodes[0].childNodes;
|
|
160
144
|
expect(referenceHeading).toMatchObject({
|
|
161
145
|
tagName: 'P',
|
|
162
146
|
textContent: 'COP reference number'
|
|
@@ -178,10 +162,10 @@ describe('components', function () {
|
|
|
178
162
|
expect(subSectionTwoLabel.textContent).toEqual('This is the label for your extra tasks');
|
|
179
163
|
expect(subSectionTwoList.childNodes.length).toEqual(3);
|
|
180
164
|
});
|
|
181
|
-
it('should render any provided annotations',
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
165
|
+
it('should render any provided annotations', () => {
|
|
166
|
+
const COP_REF = '123';
|
|
167
|
+
const REF_TITLE = 'COP reference number';
|
|
168
|
+
const sections = [{
|
|
185
169
|
name: 'These are your tasks',
|
|
186
170
|
label: 'This is the label for your first tasks',
|
|
187
171
|
tasks: [{
|
|
@@ -214,28 +198,31 @@ describe('components', function () {
|
|
|
214
198
|
pages: ['pageSix']
|
|
215
199
|
}]
|
|
216
200
|
}];
|
|
217
|
-
|
|
201
|
+
const FORM_DATA = {
|
|
218
202
|
port: {
|
|
219
203
|
name: 'Heathrow Airport'
|
|
220
204
|
}
|
|
221
205
|
};
|
|
222
|
-
|
|
206
|
+
const ANNOTATIONS = [{
|
|
223
207
|
key: 'Port',
|
|
224
208
|
// eslint-disable-next-line no-template-curly-in-string
|
|
225
209
|
value: '${port.name}'
|
|
226
210
|
}];
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
211
|
+
const {
|
|
212
|
+
container
|
|
213
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
214
|
+
refNumber: COP_REF,
|
|
215
|
+
refTitle: REF_TITLE,
|
|
216
|
+
sections: sections,
|
|
217
|
+
annotations: ANNOTATIONS,
|
|
218
|
+
formData: FORM_DATA
|
|
219
|
+
}));
|
|
220
|
+
const {
|
|
221
|
+
childNodes
|
|
222
|
+
} = container;
|
|
236
223
|
expect(childNodes.length).toEqual(1);
|
|
237
224
|
expect(childNodes[0].childNodes.length).toEqual(11);
|
|
238
|
-
|
|
225
|
+
const annotation = childNodes[0].childNodes[2];
|
|
239
226
|
expect(annotation.children[0]).toMatchObject({
|
|
240
227
|
tagName: 'P',
|
|
241
228
|
textContent: 'Port'
|
|
@@ -245,10 +232,10 @@ describe('components', function () {
|
|
|
245
232
|
textContent: 'Heathrow Airport'
|
|
246
233
|
});
|
|
247
234
|
});
|
|
248
|
-
it('should not show incomplete title if form is complete',
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
235
|
+
it('should not show incomplete title if form is complete', () => {
|
|
236
|
+
const COP_REF = '123';
|
|
237
|
+
const REF_TITLE = 'COP reference number';
|
|
238
|
+
const sections = [{
|
|
252
239
|
name: 'These are your tasks',
|
|
253
240
|
tasks: [{
|
|
254
241
|
name: 'Nice task',
|
|
@@ -279,18 +266,18 @@ describe('components', function () {
|
|
|
279
266
|
pages: ['pageSix']
|
|
280
267
|
}]
|
|
281
268
|
}];
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
269
|
+
const {
|
|
270
|
+
container
|
|
271
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
272
|
+
refNumber: COP_REF,
|
|
273
|
+
refTitle: REF_TITLE,
|
|
274
|
+
sections: sections
|
|
275
|
+
}));
|
|
276
|
+
const {
|
|
277
|
+
childNodes
|
|
278
|
+
} = container;
|
|
289
279
|
expect(childNodes[0].childNodes.length).toEqual(7);
|
|
290
|
-
|
|
291
|
-
referenceHeading = _childNodes$0$childNo3[0],
|
|
292
|
-
referenceNumber = _childNodes$0$childNo3[1],
|
|
293
|
-
numComplete = _childNodes$0$childNo3[2];
|
|
280
|
+
const [referenceHeading, referenceNumber, numComplete] = childNodes[0].childNodes;
|
|
294
281
|
expect(referenceHeading).toMatchObject({
|
|
295
282
|
tagName: 'P',
|
|
296
283
|
textContent: 'COP reference number'
|
|
@@ -304,10 +291,10 @@ describe('components', function () {
|
|
|
304
291
|
textContent: 'You have completed 6 of 6 sections'
|
|
305
292
|
});
|
|
306
293
|
});
|
|
307
|
-
it('should not show numbers on section headings if there is only one section',
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
294
|
+
it('should not show numbers on section headings if there is only one section', () => {
|
|
295
|
+
const COP_REF = '123';
|
|
296
|
+
const REF_TITLE = 'COP reference number';
|
|
297
|
+
const sections = [{
|
|
311
298
|
name: 'These are your tasks',
|
|
312
299
|
tasks: [{
|
|
313
300
|
name: 'Nice task',
|
|
@@ -323,20 +310,23 @@ describe('components', function () {
|
|
|
323
310
|
pages: ['pageThree']
|
|
324
311
|
}]
|
|
325
312
|
}];
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
313
|
+
const {
|
|
314
|
+
container
|
|
315
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
316
|
+
refNumber: COP_REF,
|
|
317
|
+
refTitle: REF_TITLE,
|
|
318
|
+
sections: sections
|
|
319
|
+
}));
|
|
320
|
+
const {
|
|
321
|
+
childNodes
|
|
322
|
+
} = container;
|
|
323
|
+
const subSectionOne = childNodes[0].childNodes[4];
|
|
334
324
|
expect(subSectionOne.childNodes[0].textContent).toEqual('');
|
|
335
325
|
expect(subSectionOne.childNodes[1].textContent).toEqual('These are your tasks');
|
|
336
326
|
});
|
|
337
|
-
it('should not display the reference if there is no reference title',
|
|
338
|
-
|
|
339
|
-
|
|
327
|
+
it('should not display the reference if there is no reference title', () => {
|
|
328
|
+
const COP_REF = '123';
|
|
329
|
+
const sections = [{
|
|
340
330
|
name: 'These are your tasks',
|
|
341
331
|
tasks: [{
|
|
342
332
|
name: 'Nice task',
|
|
@@ -367,26 +357,29 @@ describe('components', function () {
|
|
|
367
357
|
pages: ['pageSix']
|
|
368
358
|
}]
|
|
369
359
|
}];
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
360
|
+
const {
|
|
361
|
+
container
|
|
362
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
363
|
+
refNumber: COP_REF,
|
|
364
|
+
sections: sections
|
|
365
|
+
}));
|
|
366
|
+
const {
|
|
367
|
+
childNodes
|
|
368
|
+
} = container;
|
|
376
369
|
expect(childNodes.length).toEqual(1);
|
|
377
370
|
expect(childNodes[0].childNodes.length).toEqual(6);
|
|
378
371
|
|
|
379
372
|
// The first child is now the incomplete text.
|
|
380
|
-
|
|
373
|
+
const incompleteForm = childNodes[0].childNodes[0];
|
|
381
374
|
expect(incompleteForm).toMatchObject({
|
|
382
375
|
tagName: 'P',
|
|
383
376
|
textContent: _TaskList.DEFAULT_INCOMPLETE_TITLE
|
|
384
377
|
});
|
|
385
378
|
});
|
|
386
|
-
it('should show the correct incomplete title',
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
379
|
+
it('should show the correct incomplete title', () => {
|
|
380
|
+
const INCOMPLETE_TITLE = 'Alpha Bravo';
|
|
381
|
+
const COP_REF = '123';
|
|
382
|
+
const sections = [{
|
|
390
383
|
name: 'These are your tasks',
|
|
391
384
|
tasks: [{
|
|
392
385
|
name: 'Nice task',
|
|
@@ -417,21 +410,24 @@ describe('components', function () {
|
|
|
417
410
|
pages: ['pageSix']
|
|
418
411
|
}]
|
|
419
412
|
}];
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
413
|
+
const {
|
|
414
|
+
container
|
|
415
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
416
|
+
refNumber: COP_REF,
|
|
417
|
+
sections: sections,
|
|
418
|
+
incompleteTitle: INCOMPLETE_TITLE
|
|
419
|
+
}));
|
|
420
|
+
const {
|
|
421
|
+
childNodes
|
|
422
|
+
} = container;
|
|
427
423
|
// The first child is now the incomplete text.
|
|
428
|
-
|
|
424
|
+
const incompleteForm = childNodes[0].childNodes[0];
|
|
429
425
|
expect(incompleteForm.textContent).toEqual(INCOMPLETE_TITLE);
|
|
430
426
|
});
|
|
431
|
-
it('should not show skipped sections',
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
427
|
+
it('should not show skipped sections', () => {
|
|
428
|
+
const INCOMPLETE_TITLE = 'Alpha Bravo';
|
|
429
|
+
const COP_REF = '123';
|
|
430
|
+
const sections = [{
|
|
435
431
|
name: 'These are your tasks',
|
|
436
432
|
skipped: true,
|
|
437
433
|
tasks: [{
|
|
@@ -463,29 +459,32 @@ describe('components', function () {
|
|
|
463
459
|
pages: ['pageSix']
|
|
464
460
|
}]
|
|
465
461
|
}];
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
462
|
+
const {
|
|
463
|
+
container
|
|
464
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
465
|
+
refNumber: COP_REF,
|
|
466
|
+
sections: sections,
|
|
467
|
+
incompleteTitle: INCOMPLETE_TITLE
|
|
468
|
+
}));
|
|
469
|
+
const {
|
|
470
|
+
childNodes
|
|
471
|
+
} = container;
|
|
473
472
|
expect(childNodes.length).toEqual(1);
|
|
474
|
-
|
|
473
|
+
const children = childNodes[0].childNodes;
|
|
475
474
|
expect(children.length).toEqual(4);
|
|
476
475
|
expect(children[0].textContent).toEqual(INCOMPLETE_TITLE);
|
|
477
476
|
expect(children[1].textContent).toEqual('You have completed 1 of 3 sections');
|
|
478
477
|
expect(children[2].textContent).toEqual("1. ".concat(sections[1].name));
|
|
479
478
|
});
|
|
480
479
|
});
|
|
481
|
-
it('should pass the selected task to the given onTaskAction function',
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
480
|
+
it('should pass the selected task to the given onTaskAction function', () => {
|
|
481
|
+
const COP_REF = '123';
|
|
482
|
+
const REF_TITLE = 'COP reference number';
|
|
483
|
+
const ON_CLICK_CALLS = [];
|
|
484
|
+
const ON_CLICK = value => {
|
|
486
485
|
ON_CLICK_CALLS.push(value);
|
|
487
486
|
};
|
|
488
|
-
|
|
487
|
+
const sections = [{
|
|
489
488
|
name: 'These are your tasks',
|
|
490
489
|
tasks: [{
|
|
491
490
|
name: 'Nice task',
|
|
@@ -501,17 +500,18 @@ describe('components', function () {
|
|
|
501
500
|
pages: ['pageThree']
|
|
502
501
|
}]
|
|
503
502
|
}];
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
503
|
+
const {
|
|
504
|
+
container
|
|
505
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
506
|
+
refNumber: COP_REF,
|
|
507
|
+
refTitle: REF_TITLE,
|
|
508
|
+
sections: sections,
|
|
509
|
+
onTaskAction: ON_CLICK
|
|
510
|
+
}));
|
|
511
|
+
const taskList = container.childNodes[0].childNodes[5].childNodes;
|
|
512
|
+
const firstTask = taskList[0].childNodes[0].childNodes[0];
|
|
513
|
+
const secondTask = taskList[1].childNodes[0].childNodes[0];
|
|
514
|
+
const thirdTask = taskList[2].childNodes[0].childNodes[0];
|
|
515
515
|
_react.fireEvent.click(firstTask.childNodes[0]);
|
|
516
516
|
expect(ON_CLICK_CALLS[0]).toEqual({
|
|
517
517
|
pages: ['pageOne'],
|