@ukhomeoffice/cop-react-form-renderer 5.14.2 → 5.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +15 -15
- package/dist/components/CheckYourAnswers/Answer.test.js +94 -128
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +99 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +291 -501
- package/dist/components/CheckYourAnswers/index.js +2 -3
- package/dist/components/CollectionPage/CollectionPage.js +64 -58
- package/dist/components/CollectionPage/CollectionPage.test.js +212 -238
- package/dist/components/CollectionPage/index.js +2 -3
- package/dist/components/FormComponent/Collection.js +77 -113
- package/dist/components/FormComponent/Collection.test.js +688 -787
- package/dist/components/FormComponent/Container.js +44 -43
- package/dist/components/FormComponent/Container.test.js +316 -346
- package/dist/components/FormComponent/FormComponent.js +58 -64
- package/dist/components/FormComponent/FormComponent.test.js +180 -219
- package/dist/components/FormComponent/helpers/addLabel.js +5 -9
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +2 -3
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +2 -2
- 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 +2 -3
- package/dist/components/FormPage/FormPage.js +65 -79
- package/dist/components/FormPage/FormPage.test.js +134 -170
- package/dist/components/FormPage/index.js +2 -3
- package/dist/components/FormRenderer/FormRenderer.js +151 -193
- package/dist/components/FormRenderer/FormRenderer.test.js +598 -920
- package/dist/components/FormRenderer/handlers/cyaAction.js +4 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +2 -5
- 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 +3 -4
- package/dist/components/FormRenderer/handlers/navigate.js +5 -6
- package/dist/components/FormRenderer/handlers/submissionError.js +2 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.js +2 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +10 -10
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +2 -5
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +19 -27
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +17 -17
- package/dist/components/FormRenderer/helpers/getCYA.js +6 -9
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -10
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +19 -34
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +3 -6
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -13
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +12 -13
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +98 -92
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +66 -66
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +72 -79
- package/dist/components/FormRenderer/helpers/index.js +3 -4
- package/dist/components/FormRenderer/index.js +2 -3
- package/dist/components/FormRenderer/onCYAAction.js +52 -62
- package/dist/components/FormRenderer/onCYAAction.test.js +146 -138
- package/dist/components/FormRenderer/onPageAction.js +48 -47
- package/dist/components/FormRenderer/onPageAction.test.js +219 -205
- package/dist/components/FormRenderer/onTaskAction.js +12 -17
- package/dist/components/FormRenderer/onTaskAction.test.js +94 -89
- package/dist/components/PageActions/ActionButton.js +15 -19
- package/dist/components/PageActions/ActionButton.test.js +58 -79
- package/dist/components/PageActions/PageActions.js +12 -13
- package/dist/components/PageActions/PageActions.test.js +88 -116
- package/dist/components/PageActions/index.js +2 -3
- package/dist/components/SummaryList/GroupAction.js +15 -23
- package/dist/components/SummaryList/GroupAction.test.js +41 -37
- package/dist/components/SummaryList/RowAction.js +14 -19
- package/dist/components/SummaryList/RowAction.test.js +41 -37
- package/dist/components/SummaryList/SummaryList.js +25 -30
- package/dist/components/SummaryList/SummaryList.test.js +160 -182
- package/dist/components/SummaryList/SummaryListHeadingRow.js +9 -8
- package/dist/components/SummaryList/SummaryListRow.js +9 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +8 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -8
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -8
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/index.js +2 -2
- package/dist/components/SummaryList/index.js +2 -3
- package/dist/components/TaskList/Task.js +22 -33
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +46 -75
- package/dist/components/TaskList/TaskList.test.js +118 -113
- package/dist/components/TaskList/TaskState.js +9 -9
- package/dist/components/TaskList/TaskState.test.js +56 -49
- package/dist/components/TaskList/index.js +2 -3
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +59 -85
- package/dist/context/HooksContext/HooksContext.test.js +28 -36
- package/dist/context/HooksContext/index.js +4 -6
- package/dist/context/ValidationContext/ValidationContext.js +35 -76
- package/dist/context/ValidationContext/ValidationContext.test.js +50 -61
- package/dist/context/ValidationContext/index.js +4 -6
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +17 -43
- package/dist/hooks/useGetRequest.js +61 -106
- package/dist/hooks/useHooks.js +2 -5
- package/dist/hooks/useRefData.js +29 -45
- package/dist/hooks/useValidation.js +2 -5
- package/dist/index.js +15 -17
- package/dist/models/CollectionLabels.js +2 -3
- package/dist/models/ComponentTypes.js +25 -26
- package/dist/models/EventTypes.js +5 -6
- package/dist/models/FormPages.js +5 -6
- package/dist/models/FormTypes.js +9 -10
- package/dist/models/HubFormats.js +4 -5
- package/dist/models/PageAction.js +45 -42
- package/dist/models/TaskStates.js +30 -31
- package/dist/models/index.js +11 -12
- package/dist/setupTests.js +20 -24
- package/dist/utils/CheckYourAnswers/getCYAAction.js +6 -7
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +18 -20
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +21 -23
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +18 -20
- package/dist/utils/CheckYourAnswers/getCYARow.js +8 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +72 -72
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +20 -27
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +41 -47
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +72 -75
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +71 -78
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +133 -114
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +27 -23
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +16 -23
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +77 -83
- package/dist/utils/CheckYourAnswers/index.js +3 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +7 -9
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +9 -16
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +19 -20
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +4 -8
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +15 -15
- package/dist/utils/CollectionPage/index.js +3 -4
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -29
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +15 -15
- package/dist/utils/Component/addShowWhen.js +5 -10
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +20 -22
- package/dist/utils/Component/applyToComponentTree.test.js +28 -33
- package/dist/utils/Component/cleanAttributes.js +11 -16
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +7 -9
- package/dist/utils/Component/elevateNestedComponents.test.js +19 -19
- package/dist/utils/Component/getComponent.js +91 -99
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +51 -63
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +41 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -37
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +12 -11
- 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 +24 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +59 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +35 -41
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +24 -32
- 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 +14 -14
- package/dist/utils/Component/index.js +3 -4
- package/dist/utils/Component/isEditable.js +3 -7
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -3
- package/dist/utils/Component/optionIsSelected.test.js +10 -10
- package/dist/utils/Component/setupContainerComponentsPath.js +30 -33
- package/dist/utils/Component/setupContainerComponentsPath.test.js +16 -16
- package/dist/utils/Component/showComponent.js +4 -6
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +6 -6
- package/dist/utils/Condition/index.js +3 -4
- package/dist/utils/Condition/meetsAllConditions.js +9 -10
- package/dist/utils/Condition/meetsAllConditions.test.js +18 -18
- package/dist/utils/Condition/meetsCondition.js +19 -27
- package/dist/utils/Condition/meetsCondition.test.js +377 -377
- package/dist/utils/Condition/meetsOneCondition.js +7 -8
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +15 -21
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +5 -8
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +3 -4
- package/dist/utils/Container/setupNesting.js +17 -24
- package/dist/utils/Container/setupNesting.test.js +28 -31
- package/dist/utils/Container/showContainer.js +5 -10
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +41 -52
- package/dist/utils/Data/applyFormula.test.js +26 -26
- package/dist/utils/Data/getAutocompleteSource.js +11 -14
- package/dist/utils/Data/getAutocompleteSource.test.js +59 -59
- package/dist/utils/Data/getDataPath.js +21 -32
- package/dist/utils/Data/getDataPath.test.js +20 -20
- package/dist/utils/Data/getOptions.js +22 -28
- package/dist/utils/Data/getOptions.test.js +21 -21
- package/dist/utils/Data/getSourceData.js +7 -21
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +3 -4
- package/dist/utils/Data/refDataToOptions.js +12 -17
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +8 -10
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +32 -48
- package/dist/utils/Data/setupFormData.test.js +99 -98
- package/dist/utils/Data/setupRefDataUrlForComponent.js +22 -30
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +28 -28
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -12
- package/dist/utils/FormPage/applyConditionalProperties.test.js +16 -19
- package/dist/utils/FormPage/getFormPage.js +17 -19
- package/dist/utils/FormPage/getFormPage.test.js +49 -48
- package/dist/utils/FormPage/getFormPages.js +9 -15
- package/dist/utils/FormPage/getFormPages.test.js +22 -25
- package/dist/utils/FormPage/getPageActions.js +11 -19
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +6 -9
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -4
- package/dist/utils/FormPage/showFormPage.js +5 -10
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +4 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +21 -29
- package/dist/utils/FormPage/useComponent.test.js +71 -73
- package/dist/utils/Format/formatData.js +2 -3
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -9
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +7 -10
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -7
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +3 -4
- package/dist/utils/Hub/getFormHub.js +3 -4
- package/dist/utils/Hub/getFormHub.test.js +29 -32
- package/dist/utils/Hub/index.js +3 -4
- package/dist/utils/Meta/constants.js +2 -4
- package/dist/utils/Meta/documents/getDocuments.js +2 -6
- package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
- package/dist/utils/Meta/documents/index.js +3 -4
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -19
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +69 -35
- package/dist/utils/Meta/index.js +3 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +5 -6
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/getFirstOf.js +9 -10
- package/dist/utils/Operate/getFirstOf.test.js +33 -33
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +13 -14
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/index.js +3 -4
- package/dist/utils/Operate/persistValueInFormData.js +7 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +10 -11
- package/dist/utils/Operate/runPageOperations.test.js +36 -37
- package/dist/utils/Operate/setValueInFormData.js +6 -7
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +9 -10
- package/dist/utils/Operate/shouldRun.test.js +22 -28
- package/dist/utils/Validate/additional/conditionallyRequired.js +5 -7
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -9
- package/dist/utils/Validate/additional/index.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeAfter.js +4 -5
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +4 -5
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -14
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +34 -38
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +3 -4
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +5 -6
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +6 -7
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +3 -4
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +2 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +3 -4
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeShorterThan.js +2 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +4 -7
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +2 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +4 -7
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -25
- package/dist/utils/Validate/index.js +3 -4
- package/dist/utils/Validate/validateCollection.js +22 -29
- package/dist/utils/Validate/validateCollection.test.js +85 -77
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +169 -147
- package/dist/utils/Validate/validateContainer.js +16 -22
- package/dist/utils/Validate/validateContainer.test.js +52 -48
- package/dist/utils/Validate/validateDate.js +14 -21
- package/dist/utils/Validate/validateDate.test.js +28 -29
- package/dist/utils/Validate/validateEmail.js +8 -11
- package/dist/utils/Validate/validateEmail.test.js +26 -26
- package/dist/utils/Validate/validateMultifile.js +6 -10
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +20 -22
- package/dist/utils/Validate/validatePage.test.js +146 -143
- package/dist/utils/Validate/validateRegex.js +6 -10
- package/dist/utils/Validate/validateRegex.test.js +17 -17
- package/dist/utils/Validate/validateRequired.js +6 -9
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +6 -9
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +8 -16
- package/dist/utils/Validate/validateTime.test.js +15 -15
- package/dist/utils/index.js +10 -12
- package/package.json +9 -6
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -13,58 +12,39 @@ var _models = require("../../models");
|
|
|
13
12
|
var _Task = _interopRequireDefault(require("./Task"));
|
|
14
13
|
var _showComponent = _interopRequireDefault(require("../../utils/Component/showComponent"));
|
|
15
14
|
require("./TaskList.scss");
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
function
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
fieldId = _ref.fieldId,
|
|
41
|
-
onTaskAction = _ref.onTaskAction,
|
|
42
|
-
classBlock = _ref.classBlock,
|
|
43
|
-
classModifiers = _ref.classModifiers,
|
|
44
|
-
className = _ref.className,
|
|
45
|
-
formData = _ref.formData,
|
|
46
|
-
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
47
|
-
var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
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); } /* eslint-disable import/no-duplicates */ // Global Imports
|
|
19
|
+
// Local Imports
|
|
20
|
+
const DEFAULT_CLASS = exports.DEFAULT_CLASS = 'hods-task-list';
|
|
21
|
+
const DEFAULT_INCOMPLETE_TITLE = exports.DEFAULT_INCOMPLETE_TITLE = 'Incomplete form';
|
|
22
|
+
const TaskList = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
id,
|
|
25
|
+
refTitle,
|
|
26
|
+
refNumber,
|
|
27
|
+
notes,
|
|
28
|
+
incompleteTitle,
|
|
29
|
+
sections,
|
|
30
|
+
fieldId,
|
|
31
|
+
onTaskAction,
|
|
32
|
+
classBlock,
|
|
33
|
+
classModifiers,
|
|
34
|
+
className,
|
|
35
|
+
formData,
|
|
36
|
+
...attrs
|
|
37
|
+
} = _ref;
|
|
38
|
+
const classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
|
|
48
39
|
|
|
49
40
|
// TODO state will be retrieved from a document in S3 rather than given in the component definition, covered under COP-9885
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return task.state !== _models.TaskStates.TYPES.SKIPPED;
|
|
58
|
-
}).length) !== null && _current$tasks$filter2 !== void 0 ? _current$tasks$filter2 : 0)];
|
|
59
|
-
}, [0, 0]),
|
|
60
|
-
_sections$filter$redu2 = _slicedToArray(_sections$filter$redu, 2),
|
|
61
|
-
completeSections = _sections$filter$redu2[0],
|
|
62
|
-
totalSections = _sections$filter$redu2[1];
|
|
63
|
-
var notesId = "".concat(id, "Notes");
|
|
64
|
-
var _ref2 = notes && notes || {},
|
|
65
|
-
notesTitle = _ref2.title,
|
|
66
|
-
notesText = _ref2.text;
|
|
67
|
-
var onClick = function onClick(task) {
|
|
41
|
+
const [completeSections, totalSections] = sections.filter(section => !section.skipped).reduce((acc, current) => [acc[0] + (current.tasks?.filter(t => t.state === _models.TaskStates.TYPES.COMPLETE).length ?? 0), acc[1] + (current.tasks?.filter(task => task.state !== _models.TaskStates.TYPES.SKIPPED).length ?? 0)], [0, 0]);
|
|
42
|
+
const notesId = `${id}Notes`;
|
|
43
|
+
const {
|
|
44
|
+
title: notesTitle,
|
|
45
|
+
text: notesText
|
|
46
|
+
} = notes && notes || {};
|
|
47
|
+
const onClick = task => {
|
|
68
48
|
if (typeof onTaskAction === 'function') {
|
|
69
49
|
onTaskAction(task);
|
|
70
50
|
}
|
|
@@ -77,15 +57,15 @@ var TaskList = function TaskList(_ref) {
|
|
|
77
57
|
className: "govuk-body govuk-!-margin-bottom-0"
|
|
78
58
|
}, /*#__PURE__*/_react.default.createElement("strong", {
|
|
79
59
|
className: "tasklist-summary"
|
|
80
|
-
},
|
|
60
|
+
}, `${refTitle}`)), /*#__PURE__*/_react.default.createElement("p", {
|
|
81
61
|
className: "govuk-body govuk-!-font-weight-regular"
|
|
82
|
-
},
|
|
62
|
+
}, `${refNumber}`)), totalSections !== completeSections && /*#__PURE__*/_react.default.createElement("p", {
|
|
83
63
|
className: "govuk-body govuk-!-margin-bottom-0"
|
|
84
64
|
}, /*#__PURE__*/_react.default.createElement("strong", {
|
|
85
65
|
className: "tasklist-summary"
|
|
86
66
|
}, incompleteTitle)), /*#__PURE__*/_react.default.createElement("p", {
|
|
87
67
|
className: "govuk-body govuk-!-margin-bottom-7"
|
|
88
|
-
},
|
|
68
|
+
}, `You have completed ${completeSections} of ${totalSections} sections`), notesTitle && notesText && (0, _showComponent.default)(notes, formData) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
|
|
89
69
|
className: "govuk-body govuk-!-margin-bottom-0"
|
|
90
70
|
}, /*#__PURE__*/_react.default.createElement("strong", {
|
|
91
71
|
className: "tasklist-summary"
|
|
@@ -94,25 +74,17 @@ var TaskList = function TaskList(_ref) {
|
|
|
94
74
|
fieldId: notesId,
|
|
95
75
|
readOnly: true,
|
|
96
76
|
value: _copReactComponents.Utils.interpolateString(notesText, formData)
|
|
97
|
-
})), sections.filter(
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}).map(function (task) {
|
|
109
|
-
return /*#__PURE__*/_react.default.createElement(_Task.default, {
|
|
110
|
-
key: "".concat(section.name, "-").concat(task.name),
|
|
111
|
-
task: task,
|
|
112
|
-
onClick: onClick
|
|
113
|
-
});
|
|
114
|
-
})));
|
|
115
|
-
}));
|
|
77
|
+
})), sections.filter(section => !section.skipped).map((section, index) => /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
78
|
+
key: `${section.name}`
|
|
79
|
+
}, /*#__PURE__*/_react.default.createElement("h2", {
|
|
80
|
+
className: classes('section')
|
|
81
|
+
}, sections.length > 1 ? `${index + 1}. ` : '', section.name), /*#__PURE__*/_react.default.createElement("ol", {
|
|
82
|
+
className: classes('items')
|
|
83
|
+
}, /*#__PURE__*/_react.default.createElement(_dist.Hint, null, section.label ? section.label : ''), section.tasks.filter(task => task.state !== _models.TaskStates.TYPES.SKIPPED).map(task => /*#__PURE__*/_react.default.createElement(_Task.default, {
|
|
84
|
+
key: `${section.name}-${task.name}`,
|
|
85
|
+
task: task,
|
|
86
|
+
onClick: onClick
|
|
87
|
+
}))))));
|
|
116
88
|
};
|
|
117
89
|
TaskList.propTypes = {
|
|
118
90
|
classBlock: _propTypes.default.string,
|
|
@@ -155,5 +127,4 @@ TaskList.defaultProps = {
|
|
|
155
127
|
refNumber: undefined,
|
|
156
128
|
refTitle: undefined
|
|
157
129
|
};
|
|
158
|
-
var _default = TaskList;
|
|
159
|
-
exports.default = _default;
|
|
130
|
+
var _default = exports.default = TaskList;
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
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(
|
|
8
|
-
function _interopRequireWildcard(
|
|
9
|
-
function _interopRequireDefault(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var REF_TITLE = 'COP reference number';
|
|
21
|
-
var sections = [{
|
|
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
|
+
|
|
11
|
+
// Local imports
|
|
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 = [{
|
|
22
19
|
name: 'These are your tasks',
|
|
23
20
|
label: 'This is the label for your first tasks',
|
|
24
21
|
tasks: [{
|
|
@@ -51,24 +48,19 @@ describe('components', function () {
|
|
|
51
48
|
pages: ['pageSix']
|
|
52
49
|
}]
|
|
53
50
|
}];
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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;
|
|
61
61
|
expect(childNodes.length).toEqual(1);
|
|
62
62
|
expect(childNodes[0].childNodes.length).toEqual(8);
|
|
63
|
-
|
|
64
|
-
referenceHeading = _childNodes$0$childNo[0],
|
|
65
|
-
referenceNumber = _childNodes$0$childNo[1],
|
|
66
|
-
incompleteForm = _childNodes$0$childNo[2],
|
|
67
|
-
numComplete = _childNodes$0$childNo[3],
|
|
68
|
-
subSectionOneHeading = _childNodes$0$childNo[4],
|
|
69
|
-
subSectionOneList = _childNodes$0$childNo[5],
|
|
70
|
-
subSectionTwoHeading = _childNodes$0$childNo[6],
|
|
71
|
-
subSectionTwoList = _childNodes$0$childNo[7];
|
|
63
|
+
const [referenceHeading, referenceNumber, incompleteForm, numComplete, subSectionOneHeading, subSectionOneList, subSectionTwoHeading, subSectionTwoList] = childNodes[0].childNodes;
|
|
72
64
|
expect(referenceHeading).toMatchObject({
|
|
73
65
|
tagName: 'P',
|
|
74
66
|
textContent: 'COP reference number'
|
|
@@ -95,15 +87,15 @@ describe('components', function () {
|
|
|
95
87
|
textContent: '2. These are your extra bonus tasks'
|
|
96
88
|
});
|
|
97
89
|
expect(subSectionTwoList.childNodes.length).toEqual(4);
|
|
98
|
-
|
|
90
|
+
const subSectionOneLabel = childNodes[0].childNodes[5].firstChild;
|
|
99
91
|
expect(subSectionOneLabel.textContent).toEqual('This is the label for your first tasks');
|
|
100
|
-
|
|
92
|
+
const subSectionTwoLabel = childNodes[0].childNodes[7].firstChild;
|
|
101
93
|
expect(subSectionTwoLabel.textContent).toEqual('This is the label for your extra tasks');
|
|
102
94
|
});
|
|
103
|
-
it('should not show incomplete title if form is complete',
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
95
|
+
it('should not show incomplete title if form is complete', () => {
|
|
96
|
+
const COP_REF = '123';
|
|
97
|
+
const REF_TITLE = 'COP reference number';
|
|
98
|
+
const sections = [{
|
|
107
99
|
name: 'These are your tasks',
|
|
108
100
|
tasks: [{
|
|
109
101
|
name: 'Nice task',
|
|
@@ -134,18 +126,18 @@ describe('components', function () {
|
|
|
134
126
|
pages: ['pageSix']
|
|
135
127
|
}]
|
|
136
128
|
}];
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
+
}));
|
|
136
|
+
const {
|
|
137
|
+
childNodes
|
|
138
|
+
} = container;
|
|
144
139
|
expect(childNodes[0].childNodes.length).toEqual(7);
|
|
145
|
-
|
|
146
|
-
referenceHeading = _childNodes$0$childNo2[0],
|
|
147
|
-
referenceNumber = _childNodes$0$childNo2[1],
|
|
148
|
-
numComplete = _childNodes$0$childNo2[2];
|
|
140
|
+
const [referenceHeading, referenceNumber, numComplete] = childNodes[0].childNodes;
|
|
149
141
|
expect(referenceHeading).toMatchObject({
|
|
150
142
|
tagName: 'P',
|
|
151
143
|
textContent: 'COP reference number'
|
|
@@ -159,10 +151,10 @@ describe('components', function () {
|
|
|
159
151
|
textContent: 'You have completed 6 of 6 sections'
|
|
160
152
|
});
|
|
161
153
|
});
|
|
162
|
-
it('should not show numbers on section headings if there is only one section',
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
154
|
+
it('should not show numbers on section headings if there is only one section', () => {
|
|
155
|
+
const COP_REF = '123';
|
|
156
|
+
const REF_TITLE = 'COP reference number';
|
|
157
|
+
const sections = [{
|
|
166
158
|
name: 'These are your tasks',
|
|
167
159
|
tasks: [{
|
|
168
160
|
name: 'Nice task',
|
|
@@ -178,20 +170,23 @@ describe('components', function () {
|
|
|
178
170
|
pages: ['pageThree']
|
|
179
171
|
}]
|
|
180
172
|
}];
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
173
|
+
const {
|
|
174
|
+
container
|
|
175
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
176
|
+
refNumber: COP_REF,
|
|
177
|
+
refTitle: REF_TITLE,
|
|
178
|
+
sections: sections
|
|
179
|
+
}));
|
|
180
|
+
const {
|
|
181
|
+
childNodes
|
|
182
|
+
} = container;
|
|
183
|
+
const subSectionOne = childNodes[0].childNodes[4];
|
|
189
184
|
expect(subSectionOne.childNodes[0].textContent).toEqual('');
|
|
190
185
|
expect(subSectionOne.childNodes[1].textContent).toEqual('These are your tasks');
|
|
191
186
|
});
|
|
192
|
-
it('should not display the reference if there is no reference title',
|
|
193
|
-
|
|
194
|
-
|
|
187
|
+
it('should not display the reference if there is no reference title', () => {
|
|
188
|
+
const COP_REF = '123';
|
|
189
|
+
const sections = [{
|
|
195
190
|
name: 'These are your tasks',
|
|
196
191
|
tasks: [{
|
|
197
192
|
name: 'Nice task',
|
|
@@ -222,26 +217,29 @@ describe('components', function () {
|
|
|
222
217
|
pages: ['pageSix']
|
|
223
218
|
}]
|
|
224
219
|
}];
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
220
|
+
const {
|
|
221
|
+
container
|
|
222
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
223
|
+
refNumber: COP_REF,
|
|
224
|
+
sections: sections
|
|
225
|
+
}));
|
|
226
|
+
const {
|
|
227
|
+
childNodes
|
|
228
|
+
} = container;
|
|
231
229
|
expect(childNodes.length).toEqual(1);
|
|
232
230
|
expect(childNodes[0].childNodes.length).toEqual(6);
|
|
233
231
|
|
|
234
232
|
// The first child is now the incomplete text.
|
|
235
|
-
|
|
233
|
+
const incompleteForm = childNodes[0].childNodes[0];
|
|
236
234
|
expect(incompleteForm).toMatchObject({
|
|
237
235
|
tagName: 'P',
|
|
238
236
|
textContent: _TaskList.DEFAULT_INCOMPLETE_TITLE
|
|
239
237
|
});
|
|
240
238
|
});
|
|
241
|
-
it('should show the correct incomplete title',
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
239
|
+
it('should show the correct incomplete title', () => {
|
|
240
|
+
const INCOMPLETE_TITLE = 'Alpha Bravo';
|
|
241
|
+
const COP_REF = '123';
|
|
242
|
+
const sections = [{
|
|
245
243
|
name: 'These are your tasks',
|
|
246
244
|
tasks: [{
|
|
247
245
|
name: 'Nice task',
|
|
@@ -272,21 +270,24 @@ describe('components', function () {
|
|
|
272
270
|
pages: ['pageSix']
|
|
273
271
|
}]
|
|
274
272
|
}];
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
273
|
+
const {
|
|
274
|
+
container
|
|
275
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
276
|
+
refNumber: COP_REF,
|
|
277
|
+
sections: sections,
|
|
278
|
+
incompleteTitle: INCOMPLETE_TITLE
|
|
279
|
+
}));
|
|
280
|
+
const {
|
|
281
|
+
childNodes
|
|
282
|
+
} = container;
|
|
282
283
|
// The first child is now the incomplete text.
|
|
283
|
-
|
|
284
|
+
const incompleteForm = childNodes[0].childNodes[0];
|
|
284
285
|
expect(incompleteForm.textContent).toEqual(INCOMPLETE_TITLE);
|
|
285
286
|
});
|
|
286
|
-
it('should not show skipped sections',
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
it('should not show skipped sections', () => {
|
|
288
|
+
const INCOMPLETE_TITLE = 'Alpha Bravo';
|
|
289
|
+
const COP_REF = '123';
|
|
290
|
+
const sections = [{
|
|
290
291
|
name: 'These are your tasks',
|
|
291
292
|
skipped: true,
|
|
292
293
|
tasks: [{
|
|
@@ -318,29 +319,32 @@ describe('components', function () {
|
|
|
318
319
|
pages: ['pageSix']
|
|
319
320
|
}]
|
|
320
321
|
}];
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
322
|
+
const {
|
|
323
|
+
container
|
|
324
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
325
|
+
refNumber: COP_REF,
|
|
326
|
+
sections: sections,
|
|
327
|
+
incompleteTitle: INCOMPLETE_TITLE
|
|
328
|
+
}));
|
|
329
|
+
const {
|
|
330
|
+
childNodes
|
|
331
|
+
} = container;
|
|
328
332
|
expect(childNodes.length).toEqual(1);
|
|
329
|
-
|
|
333
|
+
const children = childNodes[0].childNodes;
|
|
330
334
|
expect(children.length).toEqual(4);
|
|
331
335
|
expect(children[0].textContent).toEqual(INCOMPLETE_TITLE);
|
|
332
336
|
expect(children[1].textContent).toEqual('You have completed 1 of 3 sections');
|
|
333
|
-
expect(children[2].textContent).toEqual(
|
|
337
|
+
expect(children[2].textContent).toEqual(`1. ${sections[1].name}`);
|
|
334
338
|
});
|
|
335
339
|
});
|
|
336
|
-
it('should pass the selected task to the given onTaskAction function',
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
340
|
+
it('should pass the selected task to the given onTaskAction function', () => {
|
|
341
|
+
const COP_REF = '123';
|
|
342
|
+
const REF_TITLE = 'COP reference number';
|
|
343
|
+
const ON_CLICK_CALLS = [];
|
|
344
|
+
const ON_CLICK = value => {
|
|
341
345
|
ON_CLICK_CALLS.push(value);
|
|
342
346
|
};
|
|
343
|
-
|
|
347
|
+
const sections = [{
|
|
344
348
|
name: 'These are your tasks',
|
|
345
349
|
tasks: [{
|
|
346
350
|
name: 'Nice task',
|
|
@@ -356,17 +360,18 @@ describe('components', function () {
|
|
|
356
360
|
pages: ['pageThree']
|
|
357
361
|
}]
|
|
358
362
|
}];
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
363
|
+
const {
|
|
364
|
+
container
|
|
365
|
+
} = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
366
|
+
refNumber: COP_REF,
|
|
367
|
+
refTitle: REF_TITLE,
|
|
368
|
+
sections: sections,
|
|
369
|
+
onTaskAction: ON_CLICK
|
|
370
|
+
}));
|
|
371
|
+
const taskList = container.childNodes[0].childNodes[5].childNodes;
|
|
372
|
+
const firstTask = taskList[1].childNodes[0].childNodes[0];
|
|
373
|
+
const secondTask = taskList[2].childNodes[0].childNodes[0];
|
|
374
|
+
const thirdTask = taskList[3].childNodes[0].childNodes[0];
|
|
370
375
|
_react.fireEvent.click(firstTask.childNodes[0]);
|
|
371
376
|
expect(ON_CLICK_CALLS[0]).toEqual({
|
|
372
377
|
pages: ['pageOne'],
|
|
@@ -8,17 +8,18 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
10
10
|
var _models = require("../../models");
|
|
11
|
-
function _interopRequireDefault(
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
// Global Imports
|
|
13
13
|
|
|
14
14
|
// Local imports
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const DEFAULT_CLASS = exports.DEFAULT_CLASS = 'hods-task-list';
|
|
17
|
+
const TaskState = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
state
|
|
20
|
+
} = _ref;
|
|
21
|
+
const classes = _copReactComponents.Utils.classBuilder(DEFAULT_CLASS, undefined, undefined);
|
|
22
|
+
const details = _models.TaskStates.DETAILS[state] || _models.TaskStates.DETAILS.cannotStartYet;
|
|
22
23
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Tag, {
|
|
23
24
|
classModifiers: details.colour,
|
|
24
25
|
className: classes('tag')
|
|
@@ -30,5 +31,4 @@ TaskState.propTypes = {
|
|
|
30
31
|
TaskState.defaultProps = {
|
|
31
32
|
state: _models.TaskStates.TYPES.CANNOT_START_YET
|
|
32
33
|
};
|
|
33
|
-
var _default = TaskState;
|
|
34
|
-
exports.default = _default;
|
|
34
|
+
var _default = exports.default = TaskState;
|