@ukhomeoffice/cop-react-form-renderer 4.18.0 → 5.0.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +1 -14
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +19 -57
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +8 -38
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +13 -54
- package/dist/components/FormComponent/Container.js +6 -30
- package/dist/components/FormComponent/FormComponent.js +14 -57
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
- package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
- package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
- package/dist/components/FormComponent/helpers/index.js +0 -4
- package/dist/components/FormComponent/index.js +0 -3
- package/dist/components/FormPage/FormPage.js +14 -45
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -189
- package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
- package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
- package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
- package/dist/components/FormRenderer/handlers/index.js +0 -5
- package/dist/components/FormRenderer/handlers/navigate.js +0 -5
- package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
- package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +0 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -6
- package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
- package/dist/components/FormRenderer/helpers/getPage.js +0 -5
- package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +0 -6
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +6 -20
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +3 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +3 -24
- package/dist/components/SummaryList/RowAction.js +3 -23
- package/dist/components/SummaryList/SummaryList.js +6 -28
- package/dist/components/SummaryList/SummaryListRow.js +4 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/index.js +0 -2
- package/dist/components/SummaryList/index.js +0 -3
- package/dist/components/TaskList/Task.js +7 -29
- package/dist/components/TaskList/TaskList.js +12 -33
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -6
- package/dist/context/HooksContext/HooksContext.js +14 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +8 -34
- package/dist/context/ValidationContext/index.js +0 -5
- package/dist/context/index.js +0 -3
- package/dist/hooks/index.js +0 -9
- package/dist/hooks/useAxios.js +8 -25
- package/dist/hooks/useGetRequest.js +13 -47
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +8 -37
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -6
- package/dist/models/PageAction.js +0 -3
- package/dist/models/TaskStates.js +0 -3
- package/dist/models/index.js +0 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +0 -10
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +0 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +2 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +0 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +0 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -11
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +0 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +1 -12
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/elevateNestedComponents.js +0 -3
- package/dist/utils/Component/getComponent.js +4 -68
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +10 -28
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +10 -27
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +4 -22
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +6 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +6 -33
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +4 -21
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +10 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
- package/dist/utils/Component/getDefaultValue.js +0 -7
- package/dist/utils/Component/index.js +0 -9
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/wrapInFormGroup.js +0 -7
- package/dist/utils/Condition/index.js +0 -5
- package/dist/utils/Condition/meetsAllConditions.js +0 -9
- package/dist/utils/Condition/meetsCondition.js +7 -19
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/setupConditions.js +0 -12
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +0 -11
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Data/applyFormula.js +2 -28
- package/dist/utils/Data/getAutocompleteSource.js +1 -4
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getOptions.js +0 -9
- package/dist/utils/Data/getSourceData.js +4 -19
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +1 -12
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setupFormData.js +2 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.js +0 -14
- package/dist/utils/FormPage/getFormPage.js +0 -15
- package/dist/utils/FormPage/getFormPages.js +0 -8
- package/dist/utils/FormPage/getPageActions.js +3 -18
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/index.js +0 -6
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/useComponent.js +3 -18
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForForm.js +0 -8
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/index.js +1 -3
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +0 -9
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentForField.js +0 -11
- package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -11
- package/dist/utils/Meta/index.js +2 -6
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/runPageOperations.js +3 -18
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Validate/additional/index.js +1 -18
- package/dist/utils/Validate/additional/index.test.js +0 -6
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
- package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
- package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +0 -7
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -4
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +0 -4
- package/dist/utils/Validate/additional/utils.js +8 -24
- package/dist/utils/Validate/index.js +1 -9
- package/dist/utils/Validate/validateCollection.js +0 -9
- package/dist/utils/Validate/validateComponent.js +2 -35
- package/dist/utils/Validate/validateContainer.js +0 -13
- package/dist/utils/Validate/validateDate.js +4 -36
- package/dist/utils/Validate/validateEmail.js +1 -7
- package/dist/utils/Validate/validatePage.js +0 -15
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateTime.js +3 -20
- package/dist/utils/index.js +0 -19
- package/package.json +50 -34
- package/dist/components/CheckYourAnswers/Answer.test.js +0 -95
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +0 -410
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +0 -680
- package/dist/components/CollectionPage/CollectionPage.test.js +0 -428
- package/dist/components/FormComponent/Collection.test.js +0 -381
- package/dist/components/FormComponent/Container.test.js +0 -423
- package/dist/components/FormComponent/FormComponent.stories.mdx +0 -184
- package/dist/components/FormComponent/FormComponent.test.js +0 -264
- package/dist/components/FormPage/FormPage.stories.mdx +0 -131
- package/dist/components/FormPage/FormPage.test.js +0 -368
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +0 -183
- package/dist/components/FormRenderer/FormRenderer.test.js +0 -1006
- package/dist/components/PageActions/ActionButton.test.js +0 -116
- package/dist/components/PageActions/PageActions.stories.mdx +0 -74
- package/dist/components/PageActions/PageActions.test.js +0 -157
- package/dist/components/SummaryList/GroupAction.test.js +0 -94
- package/dist/components/SummaryList/RowAction.test.js +0 -94
- package/dist/components/SummaryList/SummaryList.stories.mdx +0 -90
- package/dist/components/SummaryList/SummaryList.test.js +0 -361
- package/dist/components/TaskList/Task.test.js +0 -194
- package/dist/components/TaskList/TaskList.stories.mdx +0 -164
- package/dist/components/TaskList/TaskList.test.js +0 -334
- package/dist/components/TaskList/TaskState.test.js +0 -104
- package/dist/context/HooksContext/HooksContext.test.js +0 -60
- package/dist/context/ValidationContext/ValidationContext.test.js +0 -98
- package/dist/json/areYouACivilServant.json +0 -7
- package/dist/json/firstForm.json +0 -94
- package/dist/json/grade.json +0 -108
- package/dist/json/group.data.json +0 -21
- package/dist/json/group.json +0 -402
- package/dist/json/groupOfRow.json +0 -137
- package/dist/json/groupOfRowData.json +0 -15
- package/dist/json/port.json +0 -346
- package/dist/json/saveAndContinue.json +0 -98
- package/dist/json/sublocation.json +0 -859
- package/dist/json/taskList.json +0 -265
- package/dist/json/team.json +0 -17351
- package/dist/json/terminal.json +0 -81
- package/dist/json/userProfile.data.json +0 -21
- package/dist/json/userProfile.json +0 -276
- package/dist/setupTests.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +0 -139
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +0 -76
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +0 -59
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +0 -256
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +0 -77
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +0 -199
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +0 -170
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +0 -323
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +0 -281
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +0 -64
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +0 -41
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +0 -54
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +0 -131
- package/dist/utils/Component/cleanAttributes.test.js +0 -69
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -92
- package/dist/utils/Component/getDefaultValue.test.js +0 -53
- package/dist/utils/Component/isEditable.test.js +0 -42
- package/dist/utils/Component/showComponent.test.js +0 -157
- package/dist/utils/Condition/meetsAllConditions.test.js +0 -62
- package/dist/utils/Condition/meetsCondition.test.js +0 -391
- package/dist/utils/Condition/meetsOneCondition.test.js +0 -101
- package/dist/utils/Condition/setupConditions.test.js +0 -35
- package/dist/utils/Container/getEditableComponents.test.js +0 -146
- package/dist/utils/Container/setupNesting.test.js +0 -92
- package/dist/utils/Container/showContainer.test.js +0 -179
- package/dist/utils/Data/applyFormula.test.js +0 -264
- package/dist/utils/Data/getAutocompleteSource.test.js +0 -146
- package/dist/utils/Data/getDataPath.test.js +0 -52
- package/dist/utils/Data/getOptions.test.js +0 -71
- package/dist/utils/Data/getSourceData.test.js +0 -141
- package/dist/utils/Data/refDataToOptions.test.js +0 -197
- package/dist/utils/Data/setDataItem.test.js +0 -112
- package/dist/utils/Data/setupFormData.test.js +0 -276
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +0 -133
- package/dist/utils/FormPage/getFormPage.test.js +0 -205
- package/dist/utils/FormPage/getFormPages.test.js +0 -98
- package/dist/utils/FormPage/getPageActions.test.js +0 -89
- package/dist/utils/FormPage/getParagraphFromText.test.js +0 -29
- package/dist/utils/FormPage/showFormPage.test.js +0 -182
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -30
- package/dist/utils/FormPage/useComponent.test.js +0 -169
- package/dist/utils/Format/formatData.test.js +0 -46
- package/dist/utils/Format/formatDataForComponent.test.js +0 -161
- package/dist/utils/Format/formatDataForForm.test.js +0 -78
- package/dist/utils/Format/formatDataForPage.test.js +0 -96
- package/dist/utils/Hub/getFormHub.test.js +0 -107
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -44
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +0 -159
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -106
- package/dist/utils/Operate/runPageOperations.test.js +0 -107
- package/dist/utils/Operate/setValueInFormData.test.js +0 -46
- package/dist/utils/Operate/shouldRun.test.js +0 -69
- package/dist/utils/Validate/validateCollection.test.js +0 -74
- package/dist/utils/Validate/validateComponent.test.js +0 -267
- package/dist/utils/Validate/validateContainer.test.js +0 -81
- package/dist/utils/Validate/validateDate.test.js +0 -118
- package/dist/utils/Validate/validateEmail.test.js +0 -57
- package/dist/utils/Validate/validatePage.test.js +0 -383
- package/dist/utils/Validate/validateRegex.test.js +0 -41
- package/dist/utils/Validate/validateRequired.test.js +0 -62
- package/dist/utils/Validate/validateTime.test.js +0 -61
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
|
|
5
|
-
var _react = require("@testing-library/react");
|
|
6
|
-
|
|
7
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
8
|
-
|
|
9
|
-
var _SummaryList = _interopRequireWildcard(require("./SummaryList"));
|
|
10
|
-
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
|
|
13
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
-
|
|
19
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
-
|
|
21
|
-
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); }
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
|
|
25
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
26
|
-
|
|
27
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
28
|
-
|
|
29
|
-
describe('components', function () {
|
|
30
|
-
describe('SummaryList', function () {
|
|
31
|
-
var checkSummaryList = function checkSummaryList(container, id) {
|
|
32
|
-
var summaryList = (0, _react.getByTestId)(container, id);
|
|
33
|
-
expect(summaryList.tagName).toEqual('DL');
|
|
34
|
-
expect(summaryList.classList).toContain(_SummaryList.DEFAULT_CLASS);
|
|
35
|
-
return summaryList;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
var checkTitleRow = function checkTitleRow(summaryList, index) {
|
|
39
|
-
var row = summaryList.childNodes[index];
|
|
40
|
-
expect(row.tagName).toEqual('DIV');
|
|
41
|
-
expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
|
|
42
|
-
expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__title"));
|
|
43
|
-
|
|
44
|
-
var _row$childNodes = _slicedToArray(row.childNodes, 1),
|
|
45
|
-
heading = _row$childNodes[0];
|
|
46
|
-
|
|
47
|
-
expect(heading.tagName).toEqual('H3');
|
|
48
|
-
expect(heading.classList).toContain('govuk-heading-s');
|
|
49
|
-
return heading;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
var checkRow = function checkRow(summaryList, index) {
|
|
53
|
-
var row = summaryList.childNodes[index];
|
|
54
|
-
expect(row.tagName).toEqual('DIV');
|
|
55
|
-
expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
|
|
56
|
-
|
|
57
|
-
var _row$childNodes2 = _slicedToArray(row.childNodes, 3),
|
|
58
|
-
key = _row$childNodes2[0],
|
|
59
|
-
value = _row$childNodes2[1],
|
|
60
|
-
actions = _row$childNodes2[2];
|
|
61
|
-
|
|
62
|
-
expect(key.tagName).toEqual('DT');
|
|
63
|
-
expect(key.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__key"));
|
|
64
|
-
expect(value.tagName).toEqual('DD');
|
|
65
|
-
expect(value.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__value"));
|
|
66
|
-
expect(actions.tagName).toEqual('DD');
|
|
67
|
-
expect(actions.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__actions"));
|
|
68
|
-
return [key, value, actions];
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
var checkRowNoChangeActions = function checkRowNoChangeActions(summaryList, index) {
|
|
72
|
-
var row = summaryList.childNodes[index];
|
|
73
|
-
expect(row.tagName).toEqual('DIV');
|
|
74
|
-
expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
|
|
75
|
-
|
|
76
|
-
var _row$childNodes3 = _slicedToArray(row.childNodes, 2),
|
|
77
|
-
key = _row$childNodes3[0],
|
|
78
|
-
value = _row$childNodes3[1];
|
|
79
|
-
|
|
80
|
-
expect(key.tagName).toEqual('DT');
|
|
81
|
-
expect(key.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__key"));
|
|
82
|
-
expect(value.tagName).toEqual('DD');
|
|
83
|
-
expect(value.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__value"));
|
|
84
|
-
expect(row.childNodes.length).toEqual(2);
|
|
85
|
-
return [key, value];
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
it('should handle an empty rows array', function () {
|
|
89
|
-
var ID = 'test-id';
|
|
90
|
-
var ROWS = [];
|
|
91
|
-
|
|
92
|
-
var _render = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
93
|
-
"data-testid": ID,
|
|
94
|
-
rows: ROWS
|
|
95
|
-
})),
|
|
96
|
-
container = _render.container;
|
|
97
|
-
|
|
98
|
-
var summaryList = checkSummaryList(container, ID);
|
|
99
|
-
expect(summaryList.childNodes.length).toEqual(0);
|
|
100
|
-
});
|
|
101
|
-
it('should handle rows with no actions and string values', function () {
|
|
102
|
-
var ID = 'test-id';
|
|
103
|
-
var ROWS = [{
|
|
104
|
-
pageId: 'p1',
|
|
105
|
-
fieldId: 'a',
|
|
106
|
-
key: 'Alpha',
|
|
107
|
-
value: 'Alpha value'
|
|
108
|
-
}, {
|
|
109
|
-
pageId: 'p2',
|
|
110
|
-
fieldId: 'b',
|
|
111
|
-
key: 'Bravo',
|
|
112
|
-
value: 'Bravo value'
|
|
113
|
-
}];
|
|
114
|
-
|
|
115
|
-
var _render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
116
|
-
"data-testid": ID,
|
|
117
|
-
rows: ROWS
|
|
118
|
-
})),
|
|
119
|
-
container = _render2.container;
|
|
120
|
-
|
|
121
|
-
var summaryList = checkSummaryList(container, ID);
|
|
122
|
-
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
123
|
-
ROWS.forEach(function (row, index) {
|
|
124
|
-
var _checkRow = checkRow(summaryList, index),
|
|
125
|
-
_checkRow2 = _slicedToArray(_checkRow, 3),
|
|
126
|
-
key = _checkRow2[0],
|
|
127
|
-
value = _checkRow2[1],
|
|
128
|
-
actions = _checkRow2[2];
|
|
129
|
-
|
|
130
|
-
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
131
|
-
expect(value.textContent).toEqual(row.value);
|
|
132
|
-
expect(actions.childNodes.length).toEqual(0);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
it('should handle title rows', function () {
|
|
136
|
-
var ID = 'test-id';
|
|
137
|
-
var ROWS = [{
|
|
138
|
-
pageId: 'p1',
|
|
139
|
-
fieldId: 'a',
|
|
140
|
-
type: 'title',
|
|
141
|
-
key: 'Title'
|
|
142
|
-
}, {
|
|
143
|
-
pageId: 'p1',
|
|
144
|
-
fieldId: 'a',
|
|
145
|
-
key: 'Alpha',
|
|
146
|
-
value: 'Alpha value'
|
|
147
|
-
}, {
|
|
148
|
-
pageId: 'p2',
|
|
149
|
-
fieldId: 'b',
|
|
150
|
-
key: 'Bravo',
|
|
151
|
-
value: 'Bravo value'
|
|
152
|
-
}];
|
|
153
|
-
|
|
154
|
-
var _render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
155
|
-
"data-testid": ID,
|
|
156
|
-
rows: ROWS
|
|
157
|
-
})),
|
|
158
|
-
container = _render3.container;
|
|
159
|
-
|
|
160
|
-
var summaryList = checkSummaryList(container, ID);
|
|
161
|
-
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
162
|
-
|
|
163
|
-
var assessTitleRow = function assessTitleRow(row, index) {
|
|
164
|
-
var heading = checkTitleRow(summaryList, index);
|
|
165
|
-
expect(heading.textContent).toEqual(row.key);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
var assessRow = function assessRow(row, index) {
|
|
169
|
-
var _checkRow3 = checkRow(summaryList, index),
|
|
170
|
-
_checkRow4 = _slicedToArray(_checkRow3, 3),
|
|
171
|
-
key = _checkRow4[0],
|
|
172
|
-
value = _checkRow4[1],
|
|
173
|
-
actions = _checkRow4[2];
|
|
174
|
-
|
|
175
|
-
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
176
|
-
expect(value.textContent).toEqual(row.value);
|
|
177
|
-
expect(actions.childNodes.length).toEqual(0);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
ROWS.forEach(function (row, index) {
|
|
181
|
-
if (row.type === 'title') {
|
|
182
|
-
assessTitleRow(row, index);
|
|
183
|
-
} else {
|
|
184
|
-
assessRow(row, index);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
it('should handle rows with no actions and component values', function () {
|
|
189
|
-
var ID = 'test-id';
|
|
190
|
-
var VALUES = ['Alpha component value', 'Bravo component value'];
|
|
191
|
-
var ROWS = [{
|
|
192
|
-
pageId: 'p1',
|
|
193
|
-
fieldId: 'a',
|
|
194
|
-
key: 'Alpha',
|
|
195
|
-
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[0])
|
|
196
|
-
}, {
|
|
197
|
-
pageId: 'p2',
|
|
198
|
-
fieldId: 'b',
|
|
199
|
-
key: 'Bravo',
|
|
200
|
-
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[1])
|
|
201
|
-
}];
|
|
202
|
-
|
|
203
|
-
var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
204
|
-
"data-testid": ID,
|
|
205
|
-
rows: ROWS
|
|
206
|
-
})),
|
|
207
|
-
container = _render4.container;
|
|
208
|
-
|
|
209
|
-
var summaryList = checkSummaryList(container, ID);
|
|
210
|
-
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
211
|
-
ROWS.forEach(function (row, index) {
|
|
212
|
-
var _checkRow5 = checkRow(summaryList, index),
|
|
213
|
-
_checkRow6 = _slicedToArray(_checkRow5, 3),
|
|
214
|
-
key = _checkRow6[0],
|
|
215
|
-
value = _checkRow6[1],
|
|
216
|
-
actions = _checkRow6[2];
|
|
217
|
-
|
|
218
|
-
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
219
|
-
expect(value.childNodes.length).toEqual(1);
|
|
220
|
-
var valueDiv = value.childNodes[0];
|
|
221
|
-
expect(valueDiv.tagName).toEqual('DIV');
|
|
222
|
-
expect(valueDiv.textContent).toEqual(VALUES[index]);
|
|
223
|
-
expect(actions.childNodes.length).toEqual(0);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
it('should handle rows with actions', function () {
|
|
227
|
-
var ID = 'test-id';
|
|
228
|
-
var ON_ACTION_CALLS = [];
|
|
229
|
-
|
|
230
|
-
var ON_ACTION = function ON_ACTION(row) {
|
|
231
|
-
ON_ACTION_CALLS.push(row);
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
var ROWS = [{
|
|
235
|
-
pageId: 'p1',
|
|
236
|
-
fieldId: 'a',
|
|
237
|
-
key: 'Alpha',
|
|
238
|
-
value: 'Alpha value',
|
|
239
|
-
action: {
|
|
240
|
-
label: 'Change A',
|
|
241
|
-
onAction: ON_ACTION
|
|
242
|
-
}
|
|
243
|
-
}, {
|
|
244
|
-
pageId: 'p2',
|
|
245
|
-
fieldId: 'b',
|
|
246
|
-
key: 'Bravo',
|
|
247
|
-
value: 'Bravo value',
|
|
248
|
-
action: {
|
|
249
|
-
label: 'Change B',
|
|
250
|
-
onAction: ON_ACTION
|
|
251
|
-
}
|
|
252
|
-
}];
|
|
253
|
-
|
|
254
|
-
var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
255
|
-
"data-testid": ID,
|
|
256
|
-
rows: ROWS
|
|
257
|
-
})),
|
|
258
|
-
container = _render5.container;
|
|
259
|
-
|
|
260
|
-
var summaryList = checkSummaryList(container, ID);
|
|
261
|
-
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
262
|
-
ROWS.forEach(function (row, index) {
|
|
263
|
-
var _checkRow7 = checkRow(summaryList, index),
|
|
264
|
-
_checkRow8 = _slicedToArray(_checkRow7, 3),
|
|
265
|
-
key = _checkRow8[0],
|
|
266
|
-
value = _checkRow8[1],
|
|
267
|
-
actions = _checkRow8[2];
|
|
268
|
-
|
|
269
|
-
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
270
|
-
expect(value.textContent).toEqual(row.value);
|
|
271
|
-
var a = actions.childNodes[0];
|
|
272
|
-
expect(a.textContent).toEqual(row.action.label);
|
|
273
|
-
|
|
274
|
-
_react.fireEvent.click(a, {});
|
|
275
|
-
|
|
276
|
-
expect(ON_ACTION_CALLS.length).toEqual(index + 1);
|
|
277
|
-
expect(ON_ACTION_CALLS[index]).toEqual(row);
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
it('should handle rows with component values and actions set to hidden', function () {
|
|
281
|
-
var ID = 'test-id';
|
|
282
|
-
var VALUES = ['Alpha component value', 'Bravo component value'];
|
|
283
|
-
var ROWS = [{
|
|
284
|
-
pageId: 'p1',
|
|
285
|
-
fieldId: 'a',
|
|
286
|
-
key: 'Alpha',
|
|
287
|
-
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[0])
|
|
288
|
-
}, {
|
|
289
|
-
pageId: 'p2',
|
|
290
|
-
fieldId: 'b',
|
|
291
|
-
key: 'Bravo',
|
|
292
|
-
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[1])
|
|
293
|
-
}];
|
|
294
|
-
|
|
295
|
-
var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
296
|
-
"data-testid": ID,
|
|
297
|
-
rows: ROWS,
|
|
298
|
-
noChangeAction: true
|
|
299
|
-
})),
|
|
300
|
-
container = _render6.container;
|
|
301
|
-
|
|
302
|
-
var summaryList = checkSummaryList(container, ID);
|
|
303
|
-
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
304
|
-
ROWS.forEach(function (row, index) {
|
|
305
|
-
var _checkRowNoChangeActi = checkRowNoChangeActions(summaryList, index),
|
|
306
|
-
_checkRowNoChangeActi2 = _slicedToArray(_checkRowNoChangeActi, 2),
|
|
307
|
-
key = _checkRowNoChangeActi2[0],
|
|
308
|
-
value = _checkRowNoChangeActi2[1];
|
|
309
|
-
|
|
310
|
-
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
311
|
-
expect(value.childNodes.length).toEqual(1);
|
|
312
|
-
var valueDiv = value.childNodes[0];
|
|
313
|
-
expect(valueDiv.tagName).toEqual('DIV');
|
|
314
|
-
expect(valueDiv.textContent).toEqual(VALUES[index]);
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
it('should render groups of rows corretly', function () {
|
|
318
|
-
var ID = 'test-id';
|
|
319
|
-
var VALUES = ['Alpha component value', 'Bravo component value', 'Charlie component value'];
|
|
320
|
-
var ISGROUP = true;
|
|
321
|
-
var ROWS = [{
|
|
322
|
-
pageId: 'p1',
|
|
323
|
-
fieldId: 'a',
|
|
324
|
-
key: 'Alpha',
|
|
325
|
-
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[0])
|
|
326
|
-
}, {
|
|
327
|
-
pageId: 'p1',
|
|
328
|
-
fieldId: 'b',
|
|
329
|
-
key: 'Bravo',
|
|
330
|
-
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[1])
|
|
331
|
-
}, {
|
|
332
|
-
pageId: 'p1',
|
|
333
|
-
fieldId: 'c',
|
|
334
|
-
key: 'Charlie',
|
|
335
|
-
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[2])
|
|
336
|
-
}];
|
|
337
|
-
|
|
338
|
-
var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
339
|
-
"data-testid": ID,
|
|
340
|
-
rows: ROWS,
|
|
341
|
-
isGroup: ISGROUP
|
|
342
|
-
})),
|
|
343
|
-
container = _render7.container;
|
|
344
|
-
|
|
345
|
-
var summaryList = checkSummaryList(container, ID);
|
|
346
|
-
expect(summaryList.childNodes.length).toEqual(ROWS.length + 1);
|
|
347
|
-
ROWS.forEach(function (row, index) {
|
|
348
|
-
var _checkRow9 = checkRow(summaryList, index),
|
|
349
|
-
_checkRow10 = _slicedToArray(_checkRow9, 2),
|
|
350
|
-
key = _checkRow10[0],
|
|
351
|
-
value = _checkRow10[1];
|
|
352
|
-
|
|
353
|
-
expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
|
|
354
|
-
expect(value.childNodes.length).toEqual(1);
|
|
355
|
-
var valueDiv = value.childNodes[0];
|
|
356
|
-
expect(valueDiv.tagName).toEqual('DIV');
|
|
357
|
-
expect(valueDiv.textContent).toEqual(VALUES[index]);
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
});
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _models = require("../../models");
|
|
8
|
-
|
|
9
|
-
var _Task = _interopRequireDefault(require("./Task"));
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
// Global imports
|
|
14
|
-
// Local imports
|
|
15
|
-
describe('components', function () {
|
|
16
|
-
describe('TaskList.Task', function () {
|
|
17
|
-
it('should render a task', function () {
|
|
18
|
-
var STATE = _models.TaskStates.TYPES.COMPLETE;
|
|
19
|
-
var TASK = {
|
|
20
|
-
name: 'taskName',
|
|
21
|
-
pages: ['pageName'],
|
|
22
|
-
state: STATE
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
var ON_CLICK = function ON_CLICK() {};
|
|
26
|
-
|
|
27
|
-
var _render = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_Task.default, {
|
|
28
|
-
task: TASK,
|
|
29
|
-
onClick: ON_CLICK
|
|
30
|
-
})),
|
|
31
|
-
container = _render.container;
|
|
32
|
-
|
|
33
|
-
expect(container.childNodes.length).toEqual(1);
|
|
34
|
-
expect(container.childNodes[0].classList).toContain('hods-task-list__item');
|
|
35
|
-
var span = container.childNodes[0].childNodes[0];
|
|
36
|
-
var state = container.childNodes[0].childNodes[1];
|
|
37
|
-
expect(span.classList).toContain('hods-task-list__task-name');
|
|
38
|
-
expect(span.textContent).toEqual(TASK.name);
|
|
39
|
-
expect(state.textContent).toEqual('Completed');
|
|
40
|
-
});
|
|
41
|
-
it('should render a task with a displayName', function () {
|
|
42
|
-
var STATE = _models.TaskStates.TYPES.COMPLETE;
|
|
43
|
-
var TASK = {
|
|
44
|
-
name: 'taskName',
|
|
45
|
-
displayName: 'Alpha Bravo',
|
|
46
|
-
pages: ['pageName'],
|
|
47
|
-
state: STATE
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
var ON_CLICK = function ON_CLICK() {};
|
|
51
|
-
|
|
52
|
-
var _render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_Task.default, {
|
|
53
|
-
task: TASK,
|
|
54
|
-
onClick: ON_CLICK
|
|
55
|
-
})),
|
|
56
|
-
container = _render2.container;
|
|
57
|
-
|
|
58
|
-
expect(container.childNodes.length).toEqual(1);
|
|
59
|
-
expect(container.childNodes[0].classList).toContain('hods-task-list__item');
|
|
60
|
-
var span = container.childNodes[0].childNodes[0];
|
|
61
|
-
var state = container.childNodes[0].childNodes[1];
|
|
62
|
-
expect(span.classList).toContain('hods-task-list__task-name');
|
|
63
|
-
expect(span.textContent).toEqual(TASK.displayName);
|
|
64
|
-
expect(state.textContent).toEqual('Completed');
|
|
65
|
-
});
|
|
66
|
-
it('should render a task with inactive link if state is cannotStartYet', function () {
|
|
67
|
-
var STATE = _models.TaskStates.TYPES.CANNOT_START_YET;
|
|
68
|
-
var TASK = {
|
|
69
|
-
name: 'taskName',
|
|
70
|
-
pages: ['pageName'],
|
|
71
|
-
state: STATE
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
var ON_CLICK = function ON_CLICK() {};
|
|
75
|
-
|
|
76
|
-
var _render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_Task.default, {
|
|
77
|
-
task: TASK,
|
|
78
|
-
onClick: ON_CLICK
|
|
79
|
-
})),
|
|
80
|
-
container = _render3.container;
|
|
81
|
-
|
|
82
|
-
var span = container.childNodes[0].childNodes[0];
|
|
83
|
-
expect(span.childNodes[0].tagName).toEqual(undefined);
|
|
84
|
-
expect(span.textContent).toEqual(TASK.name);
|
|
85
|
-
});
|
|
86
|
-
it('should render a task with a link if state is not cannotStartYet', function () {
|
|
87
|
-
var STATE = _models.TaskStates.TYPES.IN_PROGRESS;
|
|
88
|
-
var TASK = {
|
|
89
|
-
name: 'taskName',
|
|
90
|
-
pages: ['pageName'],
|
|
91
|
-
state: STATE
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
var ON_CLICK = function ON_CLICK() {};
|
|
95
|
-
|
|
96
|
-
var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_Task.default, {
|
|
97
|
-
task: TASK,
|
|
98
|
-
onClick: ON_CLICK
|
|
99
|
-
})),
|
|
100
|
-
container = _render4.container;
|
|
101
|
-
|
|
102
|
-
var span = container.childNodes[0].childNodes[0];
|
|
103
|
-
expect(span.childNodes.length).toEqual(1);
|
|
104
|
-
expect(span.childNodes[0].tagName).toEqual('A');
|
|
105
|
-
expect(span.textContent).toEqual(TASK.name);
|
|
106
|
-
});
|
|
107
|
-
it('should render the displayName of a task with a link if state is not cannotStartYet', function () {
|
|
108
|
-
var STATE = _models.TaskStates.TYPES.IN_PROGRESS;
|
|
109
|
-
var TASK = {
|
|
110
|
-
name: 'taskName',
|
|
111
|
-
displayName: 'Charlie Delta',
|
|
112
|
-
pages: ['pageName'],
|
|
113
|
-
state: STATE
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
var ON_CLICK = function ON_CLICK() {};
|
|
117
|
-
|
|
118
|
-
var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_Task.default, {
|
|
119
|
-
task: TASK,
|
|
120
|
-
onClick: ON_CLICK
|
|
121
|
-
})),
|
|
122
|
-
container = _render5.container;
|
|
123
|
-
|
|
124
|
-
var span = container.childNodes[0].childNodes[0];
|
|
125
|
-
expect(span.childNodes.length).toEqual(1);
|
|
126
|
-
expect(span.childNodes[0].tagName).toEqual('A');
|
|
127
|
-
expect(span.textContent).toEqual(TASK.displayName);
|
|
128
|
-
});
|
|
129
|
-
it('should call the given onClick function when the link is clicked', function () {
|
|
130
|
-
var STATE = _models.TaskStates.TYPES.IN_PROGRESS;
|
|
131
|
-
var TASK = {
|
|
132
|
-
name: 'taskName',
|
|
133
|
-
pages: ['pageName'],
|
|
134
|
-
state: STATE
|
|
135
|
-
};
|
|
136
|
-
var ON_CLICK_CALLS = [];
|
|
137
|
-
|
|
138
|
-
var ON_CLICK = function ON_CLICK(value) {
|
|
139
|
-
ON_CLICK_CALLS.push(value);
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_Task.default, {
|
|
143
|
-
task: TASK,
|
|
144
|
-
onClick: ON_CLICK
|
|
145
|
-
})),
|
|
146
|
-
container = _render6.container;
|
|
147
|
-
|
|
148
|
-
var link = container.childNodes[0].childNodes[0].childNodes[0];
|
|
149
|
-
|
|
150
|
-
_react.fireEvent.click(link);
|
|
151
|
-
|
|
152
|
-
expect(ON_CLICK_CALLS.length).toEqual(1);
|
|
153
|
-
expect(ON_CLICK_CALLS[0]).toEqual({
|
|
154
|
-
pages: ['pageName'],
|
|
155
|
-
name: "taskName",
|
|
156
|
-
state: STATE
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
it('should call the given onClick function when the enter key is pressed on the link', function () {
|
|
160
|
-
var STATE = _models.TaskStates.TYPES.IN_PROGRESS;
|
|
161
|
-
var TASK = {
|
|
162
|
-
name: 'taskName',
|
|
163
|
-
pages: ['pageName'],
|
|
164
|
-
state: STATE
|
|
165
|
-
};
|
|
166
|
-
var ON_CLICK_CALLS = [];
|
|
167
|
-
|
|
168
|
-
var ON_CLICK = function ON_CLICK(value) {
|
|
169
|
-
ON_CLICK_CALLS.push(value);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_Task.default, {
|
|
173
|
-
task: TASK,
|
|
174
|
-
onClick: ON_CLICK
|
|
175
|
-
})),
|
|
176
|
-
container = _render7.container;
|
|
177
|
-
|
|
178
|
-
var link = container.childNodes[0].childNodes[0].childNodes[0]; // The keyPress event needs charCode: 13 or it fails; bug with the library.
|
|
179
|
-
|
|
180
|
-
_react.fireEvent.keyPress(link, {
|
|
181
|
-
key: 'Enter',
|
|
182
|
-
code: 13,
|
|
183
|
-
charCode: 13
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
expect(ON_CLICK_CALLS.length).toEqual(1);
|
|
187
|
-
expect(ON_CLICK_CALLS[0]).toEqual({
|
|
188
|
-
pages: ['pageName'],
|
|
189
|
-
name: "taskName",
|
|
190
|
-
state: STATE
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
});
|