@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,164 +0,0 @@
|
|
|
1
|
-
<!-- Global imports -->
|
|
2
|
-
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
3
|
-
import { Details, Heading } from '@ukhomeoffice/cop-react-components';
|
|
4
|
-
|
|
5
|
-
<!-- Local imports -->
|
|
6
|
-
import Utils from '../../utils';
|
|
7
|
-
import TaskList from './TaskList';
|
|
8
|
-
|
|
9
|
-
<Meta title="Components/Task list" id="D-TaskList" component={ TaskList } />
|
|
10
|
-
|
|
11
|
-
<Heading size="xl" caption="Components">Task list</Heading>
|
|
12
|
-
|
|
13
|
-
Renders a list of tasks along with the current status for each. Each task that is not in the `Cannot start yet` state can be
|
|
14
|
-
selected to navigate to that task.
|
|
15
|
-
|
|
16
|
-
<Canvas withToolbar>
|
|
17
|
-
<Story name="Default">
|
|
18
|
-
{() => {
|
|
19
|
-
const onAction = (row) => {
|
|
20
|
-
console.log('action clicked', row);
|
|
21
|
-
};
|
|
22
|
-
const COP_REF = '123';
|
|
23
|
-
const REF_TITLE = 'COP reference number';
|
|
24
|
-
const SECTIONS = [
|
|
25
|
-
{
|
|
26
|
-
name: 'Add event details',
|
|
27
|
-
tasks: [
|
|
28
|
-
{ name: 'Date, location and mode details', state: 'complete' },
|
|
29
|
-
{ name: 'Officer and agency details', state: 'inProgress' },
|
|
30
|
-
],
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: 'Add people details',
|
|
34
|
-
tasks: [
|
|
35
|
-
{ name: 'People details', state: 'complete' },
|
|
36
|
-
{ name: 'Immigration details', state: 'inProgress' },
|
|
37
|
-
{ name: 'Journey details', state: 'notStarted' },
|
|
38
|
-
],
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: 'Add item details',
|
|
42
|
-
tasks: [
|
|
43
|
-
{ name: 'Item details', state: 'cannotStartYet' },
|
|
44
|
-
{ name: 'Search and interception details', state: 'cannotStartYet' },
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
];
|
|
48
|
-
return (
|
|
49
|
-
<TaskList refNumber={COP_REF} refTitle={REF_TITLE} sections={SECTIONS} />
|
|
50
|
-
);
|
|
51
|
-
}}
|
|
52
|
-
</Story>
|
|
53
|
-
</Canvas>
|
|
54
|
-
|
|
55
|
-
<Details summary="Properties" className="no-indent">
|
|
56
|
-
<ArgsTable of={ TaskList } />
|
|
57
|
-
</Details>
|
|
58
|
-
|
|
59
|
-
## With custom incomplete title
|
|
60
|
-
This can be specified within the `hub` portion of the form JSON:
|
|
61
|
-
```
|
|
62
|
-
{
|
|
63
|
-
...
|
|
64
|
-
hub: {
|
|
65
|
-
...
|
|
66
|
-
incompleteTitle: 'You still have work to do, it seems'
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
<Canvas withToolbar>
|
|
72
|
-
<Story name="With custom incomplete title">
|
|
73
|
-
{() => {
|
|
74
|
-
const onAction = (row) => {
|
|
75
|
-
console.log('action clicked', row);
|
|
76
|
-
};
|
|
77
|
-
const COP_REF = '123';
|
|
78
|
-
const REF_TITLE = 'COP reference number';
|
|
79
|
-
const INCOMPLETE_TITLE = 'You still have work to do, it seems'
|
|
80
|
-
const SECTIONS = [
|
|
81
|
-
{
|
|
82
|
-
name: 'Add event details',
|
|
83
|
-
tasks: [
|
|
84
|
-
{ name: 'Date, location and mode details', state: 'complete' },
|
|
85
|
-
{ name: 'Officer and agency details', state: 'inProgress' },
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'Add people details',
|
|
90
|
-
tasks: [
|
|
91
|
-
{ name: 'People details', state: 'complete' },
|
|
92
|
-
{ name: 'Immigration details', state: 'inProgress' },
|
|
93
|
-
{ name: 'Journey details', state: 'notStarted' },
|
|
94
|
-
],
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
name: 'Add item details',
|
|
98
|
-
tasks: [
|
|
99
|
-
{ name: 'Item details', state: 'cannotStartYet' },
|
|
100
|
-
{ name: 'Search and interception details', state: 'cannotStartYet' },
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
];
|
|
104
|
-
return (
|
|
105
|
-
<TaskList refNumber={COP_REF} refTitle={REF_TITLE} sections={SECTIONS} incompleteTitle={INCOMPLETE_TITLE} />
|
|
106
|
-
);
|
|
107
|
-
}}
|
|
108
|
-
</Story>
|
|
109
|
-
</Canvas>
|
|
110
|
-
|
|
111
|
-
## With labels on tasks
|
|
112
|
-
This is a non-required property of the individual `tasks` fields of the form JSON:
|
|
113
|
-
```
|
|
114
|
-
{
|
|
115
|
-
...
|
|
116
|
-
tasks: [
|
|
117
|
-
{
|
|
118
|
-
...
|
|
119
|
-
label: 'This is a label'
|
|
120
|
-
}
|
|
121
|
-
...
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
<Canvas withToolbar>
|
|
126
|
-
<Story name="With labels on tasks">
|
|
127
|
-
{() => {
|
|
128
|
-
const onAction = (row) => {
|
|
129
|
-
console.log('action clicked', row);
|
|
130
|
-
};
|
|
131
|
-
const COP_REF = '123';
|
|
132
|
-
const REF_TITLE = 'COP reference number';
|
|
133
|
-
const SECTIONS = [
|
|
134
|
-
{
|
|
135
|
-
name: 'Add event details',
|
|
136
|
-
label: 'Task 1 label',
|
|
137
|
-
tasks: [
|
|
138
|
-
{ name: 'Date, location and mode details', state: 'complete' },
|
|
139
|
-
{ name: 'Officer and agency details', state: 'inProgress' },
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
name: 'Add people details',
|
|
144
|
-
tasks: [
|
|
145
|
-
{ name: 'People details', state: 'complete' },
|
|
146
|
-
{ name: 'Immigration details', state: 'inProgress' },
|
|
147
|
-
{ name: 'Journey details', state: 'notStarted' },
|
|
148
|
-
],
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
name: 'Add item details',
|
|
152
|
-
label: 'Task 3 label',
|
|
153
|
-
tasks: [
|
|
154
|
-
{ name: 'Item details', state: 'cannotStartYet' },
|
|
155
|
-
{ name: 'Search and interception details', state: 'cannotStartYet' },
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
];
|
|
159
|
-
return (
|
|
160
|
-
<TaskList refNumber={COP_REF} refTitle={REF_TITLE} sections={SECTIONS} />
|
|
161
|
-
);
|
|
162
|
-
}}
|
|
163
|
-
</Story>
|
|
164
|
-
</Canvas>
|
|
@@ -1,334 +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 _TaskList = _interopRequireWildcard(require("./TaskList"));
|
|
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
|
-
// Global imports
|
|
18
|
-
// Local imports
|
|
19
|
-
describe('components', function () {
|
|
20
|
-
describe('TaskList', function () {
|
|
21
|
-
it('should render a TaskList', function () {
|
|
22
|
-
var COP_REF = '123';
|
|
23
|
-
var REF_TITLE = 'COP reference number';
|
|
24
|
-
var sections = [{
|
|
25
|
-
name: 'These are your tasks',
|
|
26
|
-
label: 'This is the label for your first tasks',
|
|
27
|
-
tasks: [{
|
|
28
|
-
name: 'Nice task',
|
|
29
|
-
state: 'complete',
|
|
30
|
-
pages: ['pageOne']
|
|
31
|
-
}, {
|
|
32
|
-
name: 'Ok task',
|
|
33
|
-
state: 'inProgress',
|
|
34
|
-
pages: ['pageTwo']
|
|
35
|
-
}, {
|
|
36
|
-
name: 'Terrible task',
|
|
37
|
-
state: 'notStarted',
|
|
38
|
-
pages: ['pageThree']
|
|
39
|
-
}]
|
|
40
|
-
}, {
|
|
41
|
-
name: 'These are your extra bonus tasks',
|
|
42
|
-
label: 'This is the label for your extra tasks',
|
|
43
|
-
tasks: [{
|
|
44
|
-
name: 'Nice task',
|
|
45
|
-
state: 'complete',
|
|
46
|
-
pages: ['pageFour']
|
|
47
|
-
}, {
|
|
48
|
-
name: 'Ok task',
|
|
49
|
-
state: 'cannotStartYet',
|
|
50
|
-
pages: ['pageFive']
|
|
51
|
-
}, {
|
|
52
|
-
name: 'Terrible task',
|
|
53
|
-
state: 'cannotStartYet',
|
|
54
|
-
pages: ['pageSix']
|
|
55
|
-
}]
|
|
56
|
-
}];
|
|
57
|
-
|
|
58
|
-
var _render = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
59
|
-
refNumber: COP_REF,
|
|
60
|
-
refTitle: REF_TITLE,
|
|
61
|
-
sections: sections
|
|
62
|
-
})),
|
|
63
|
-
container = _render.container;
|
|
64
|
-
|
|
65
|
-
expect(container.childNodes.length).toEqual(1);
|
|
66
|
-
var referenceHeading = container.childNodes[0].childNodes[0];
|
|
67
|
-
expect(referenceHeading.tagName).toEqual('P');
|
|
68
|
-
expect(referenceHeading.textContent).toEqual('COP reference number');
|
|
69
|
-
var referenceNumber = container.childNodes[0].childNodes[1];
|
|
70
|
-
expect(referenceNumber.tagName).toEqual('P');
|
|
71
|
-
expect(referenceNumber.textContent).toEqual('123');
|
|
72
|
-
var incompleteForm = container.childNodes[0].childNodes[2];
|
|
73
|
-
expect(incompleteForm.tagName).toEqual('P');
|
|
74
|
-
expect(incompleteForm.textContent).toEqual(_TaskList.DEFAULT_INCOMPLETE_TITLE);
|
|
75
|
-
var numComplete = container.childNodes[0].childNodes[3];
|
|
76
|
-
expect(numComplete.tagName).toEqual('P');
|
|
77
|
-
expect(numComplete.textContent).toEqual('You have completed 2 of 6 sections');
|
|
78
|
-
expect(container.childNodes[0].childNodes.length).toEqual(8);
|
|
79
|
-
var subSectionOneHeading = container.childNodes[0].childNodes[4];
|
|
80
|
-
expect(subSectionOneHeading.tagName).toEqual('H2');
|
|
81
|
-
expect(subSectionOneHeading.textContent).toEqual('1. These are your tasks');
|
|
82
|
-
var subSectionOneList = container.childNodes[0].childNodes[5];
|
|
83
|
-
expect(subSectionOneList.childNodes.length).toEqual(4);
|
|
84
|
-
var subSectionTwoHeading = container.childNodes[0].childNodes[6];
|
|
85
|
-
expect(subSectionTwoHeading.tagName).toEqual('H2');
|
|
86
|
-
expect(subSectionTwoHeading.textContent).toEqual('2. These are your extra bonus tasks');
|
|
87
|
-
var subSectionTwoList = container.childNodes[0].childNodes[7];
|
|
88
|
-
expect(subSectionTwoList.childNodes.length).toEqual(4);
|
|
89
|
-
var subSectionOneLabel = container.childNodes[0].childNodes[5].firstChild;
|
|
90
|
-
expect(subSectionOneLabel.textContent).toEqual('This is the label for your first tasks');
|
|
91
|
-
var subSectionTwoLabel = container.childNodes[0].childNodes[7].firstChild;
|
|
92
|
-
expect(subSectionTwoLabel.textContent).toEqual('This is the label for your extra tasks');
|
|
93
|
-
});
|
|
94
|
-
it('should not show incomplete title if form is complete', function () {
|
|
95
|
-
var COP_REF = '123';
|
|
96
|
-
var REF_TITLE = 'COP reference number';
|
|
97
|
-
var sections = [{
|
|
98
|
-
name: 'These are your tasks',
|
|
99
|
-
tasks: [{
|
|
100
|
-
name: 'Nice task',
|
|
101
|
-
state: 'complete',
|
|
102
|
-
pages: ['pageOne']
|
|
103
|
-
}, {
|
|
104
|
-
name: 'Ok task',
|
|
105
|
-
state: 'complete',
|
|
106
|
-
pages: ['pageTwo']
|
|
107
|
-
}, {
|
|
108
|
-
name: 'Terrible task',
|
|
109
|
-
state: 'complete',
|
|
110
|
-
pages: ['pageThree']
|
|
111
|
-
}]
|
|
112
|
-
}, {
|
|
113
|
-
name: 'These are your extra bonus tasks',
|
|
114
|
-
tasks: [{
|
|
115
|
-
name: 'Nice task',
|
|
116
|
-
state: 'complete',
|
|
117
|
-
pages: ['pageFour']
|
|
118
|
-
}, {
|
|
119
|
-
name: 'Ok task',
|
|
120
|
-
state: 'complete',
|
|
121
|
-
pages: ['pageFive']
|
|
122
|
-
}, {
|
|
123
|
-
name: 'Terrible task',
|
|
124
|
-
state: 'complete',
|
|
125
|
-
pages: ['pageSix']
|
|
126
|
-
}]
|
|
127
|
-
}];
|
|
128
|
-
|
|
129
|
-
var _render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
130
|
-
refNumber: COP_REF,
|
|
131
|
-
refTitle: REF_TITLE,
|
|
132
|
-
sections: sections
|
|
133
|
-
})),
|
|
134
|
-
container = _render2.container;
|
|
135
|
-
|
|
136
|
-
expect(container.childNodes[0].childNodes.length).toEqual(7);
|
|
137
|
-
var referenceHeading = container.childNodes[0].childNodes[0];
|
|
138
|
-
expect(referenceHeading.tagName).toEqual('P');
|
|
139
|
-
expect(referenceHeading.textContent).toEqual('COP reference number');
|
|
140
|
-
var referenceNumber = container.childNodes[0].childNodes[1];
|
|
141
|
-
expect(referenceNumber.tagName).toEqual('P');
|
|
142
|
-
expect(referenceNumber.textContent).toEqual('123');
|
|
143
|
-
var numComplete = container.childNodes[0].childNodes[2];
|
|
144
|
-
expect(numComplete.tagName).toEqual('P');
|
|
145
|
-
expect(numComplete.textContent).toEqual('You have completed 6 of 6 sections');
|
|
146
|
-
});
|
|
147
|
-
it('should not show numbers on section headings if there is only one section', function () {
|
|
148
|
-
var COP_REF = '123';
|
|
149
|
-
var REF_TITLE = 'COP reference number';
|
|
150
|
-
var sections = [{
|
|
151
|
-
name: 'These are your tasks',
|
|
152
|
-
tasks: [{
|
|
153
|
-
name: 'Nice task',
|
|
154
|
-
state: 'complete',
|
|
155
|
-
pages: ['pageOne']
|
|
156
|
-
}, {
|
|
157
|
-
name: 'Ok task',
|
|
158
|
-
state: 'complete',
|
|
159
|
-
pages: ['pageTwo']
|
|
160
|
-
}, {
|
|
161
|
-
name: 'Terrible task',
|
|
162
|
-
state: 'notStarted',
|
|
163
|
-
pages: ['pageThree']
|
|
164
|
-
}]
|
|
165
|
-
}];
|
|
166
|
-
|
|
167
|
-
var _render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
168
|
-
refNumber: COP_REF,
|
|
169
|
-
refTitle: REF_TITLE,
|
|
170
|
-
sections: sections
|
|
171
|
-
})),
|
|
172
|
-
container = _render3.container;
|
|
173
|
-
|
|
174
|
-
var subSectionOne = container.childNodes[0].childNodes[4];
|
|
175
|
-
expect(subSectionOne.childNodes[0].textContent).toEqual('');
|
|
176
|
-
expect(subSectionOne.childNodes[1].textContent).toEqual('These are your tasks');
|
|
177
|
-
});
|
|
178
|
-
it('should not display the reference if there is no reference title', function () {
|
|
179
|
-
var COP_REF = '123';
|
|
180
|
-
var sections = [{
|
|
181
|
-
name: 'These are your tasks',
|
|
182
|
-
tasks: [{
|
|
183
|
-
name: 'Nice task',
|
|
184
|
-
state: 'complete',
|
|
185
|
-
pages: ['pageOne']
|
|
186
|
-
}, {
|
|
187
|
-
name: 'Ok task',
|
|
188
|
-
state: 'inProgress',
|
|
189
|
-
pages: ['pageTwo']
|
|
190
|
-
}, {
|
|
191
|
-
name: 'Terrible task',
|
|
192
|
-
state: 'notStarted',
|
|
193
|
-
pages: ['pageThree']
|
|
194
|
-
}]
|
|
195
|
-
}, {
|
|
196
|
-
name: 'These are your extra bonus tasks',
|
|
197
|
-
tasks: [{
|
|
198
|
-
name: 'Nice task',
|
|
199
|
-
state: 'complete',
|
|
200
|
-
pages: ['pageFour']
|
|
201
|
-
}, {
|
|
202
|
-
name: 'Ok task',
|
|
203
|
-
state: 'cannotStartYet',
|
|
204
|
-
pages: ['pageFive']
|
|
205
|
-
}, {
|
|
206
|
-
name: 'Terrible task',
|
|
207
|
-
state: 'cannotStartYet',
|
|
208
|
-
pages: ['pageSix']
|
|
209
|
-
}]
|
|
210
|
-
}];
|
|
211
|
-
|
|
212
|
-
var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
213
|
-
refNumber: COP_REF,
|
|
214
|
-
sections: sections
|
|
215
|
-
})),
|
|
216
|
-
container = _render4.container;
|
|
217
|
-
|
|
218
|
-
expect(container.childNodes.length).toEqual(1);
|
|
219
|
-
expect(container.childNodes[0].childNodes.length).toEqual(6); // The first child is now the incomplete text.
|
|
220
|
-
|
|
221
|
-
var incompleteForm = container.childNodes[0].childNodes[0];
|
|
222
|
-
expect(incompleteForm.tagName).toEqual('P');
|
|
223
|
-
expect(incompleteForm.textContent).toEqual(_TaskList.DEFAULT_INCOMPLETE_TITLE);
|
|
224
|
-
});
|
|
225
|
-
it('should show the correct incomplete title', function () {
|
|
226
|
-
var INCOMPLETE_TITLE = 'Alpha Bravo';
|
|
227
|
-
var COP_REF = '123';
|
|
228
|
-
var sections = [{
|
|
229
|
-
name: 'These are your tasks',
|
|
230
|
-
tasks: [{
|
|
231
|
-
name: 'Nice task',
|
|
232
|
-
state: 'complete',
|
|
233
|
-
pages: ['pageOne']
|
|
234
|
-
}, {
|
|
235
|
-
name: 'Ok task',
|
|
236
|
-
state: 'inProgress',
|
|
237
|
-
pages: ['pageTwo']
|
|
238
|
-
}, {
|
|
239
|
-
name: 'Terrible task',
|
|
240
|
-
state: 'notStarted',
|
|
241
|
-
pages: ['pageThree']
|
|
242
|
-
}]
|
|
243
|
-
}, {
|
|
244
|
-
name: 'These are your extra bonus tasks',
|
|
245
|
-
tasks: [{
|
|
246
|
-
name: 'Nice task',
|
|
247
|
-
state: 'complete',
|
|
248
|
-
pages: ['pageFour']
|
|
249
|
-
}, {
|
|
250
|
-
name: 'Ok task',
|
|
251
|
-
state: 'cannotStartYet',
|
|
252
|
-
pages: ['pageFive']
|
|
253
|
-
}, {
|
|
254
|
-
name: 'Terrible task',
|
|
255
|
-
state: 'cannotStartYet',
|
|
256
|
-
pages: ['pageSix']
|
|
257
|
-
}]
|
|
258
|
-
}];
|
|
259
|
-
|
|
260
|
-
var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
261
|
-
refNumber: COP_REF,
|
|
262
|
-
sections: sections,
|
|
263
|
-
incompleteTitle: INCOMPLETE_TITLE
|
|
264
|
-
})),
|
|
265
|
-
container = _render5.container; // The first child is now the incomplete text.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
var incompleteForm = container.childNodes[0].childNodes[0];
|
|
269
|
-
expect(incompleteForm.textContent).toEqual(INCOMPLETE_TITLE);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
it('should pass the selected task to the given onTaskAction function', function () {
|
|
273
|
-
var COP_REF = '123';
|
|
274
|
-
var REF_TITLE = 'COP reference number';
|
|
275
|
-
var ON_CLICK_CALLS = [];
|
|
276
|
-
|
|
277
|
-
var ON_CLICK = function ON_CLICK(value) {
|
|
278
|
-
ON_CLICK_CALLS.push(value);
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
var sections = [{
|
|
282
|
-
name: 'These are your tasks',
|
|
283
|
-
tasks: [{
|
|
284
|
-
name: 'Nice task',
|
|
285
|
-
state: 'complete',
|
|
286
|
-
pages: ['pageOne']
|
|
287
|
-
}, {
|
|
288
|
-
name: 'Ok task',
|
|
289
|
-
state: 'complete',
|
|
290
|
-
pages: ['pageTwo']
|
|
291
|
-
}, {
|
|
292
|
-
name: 'Terrible task',
|
|
293
|
-
state: 'notStarted',
|
|
294
|
-
pages: ['pageThree']
|
|
295
|
-
}]
|
|
296
|
-
}];
|
|
297
|
-
|
|
298
|
-
var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
299
|
-
refNumber: COP_REF,
|
|
300
|
-
refTitle: REF_TITLE,
|
|
301
|
-
sections: sections,
|
|
302
|
-
onTaskAction: ON_CLICK
|
|
303
|
-
})),
|
|
304
|
-
container = _render6.container;
|
|
305
|
-
|
|
306
|
-
var firstTask = container.childNodes[0].childNodes[5].childNodes[1].childNodes[0].childNodes[0];
|
|
307
|
-
var secondTask = container.childNodes[0].childNodes[5].childNodes[2].childNodes[0].childNodes[0];
|
|
308
|
-
var thirdTask = container.childNodes[0].childNodes[5].childNodes[3].childNodes[0].childNodes[0];
|
|
309
|
-
|
|
310
|
-
_react.fireEvent.click(firstTask.childNodes[0]);
|
|
311
|
-
|
|
312
|
-
expect(ON_CLICK_CALLS[0]).toEqual({
|
|
313
|
-
pages: ['pageOne'],
|
|
314
|
-
name: "Nice task",
|
|
315
|
-
state: 'complete'
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
_react.fireEvent.click(secondTask.childNodes[0]);
|
|
319
|
-
|
|
320
|
-
expect(ON_CLICK_CALLS[1]).toEqual({
|
|
321
|
-
pages: ['pageTwo'],
|
|
322
|
-
name: "Ok task",
|
|
323
|
-
state: 'complete'
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
_react.fireEvent.click(thirdTask.childNodes[0]);
|
|
327
|
-
|
|
328
|
-
expect(ON_CLICK_CALLS[2]).toEqual({
|
|
329
|
-
pages: ['pageThree'],
|
|
330
|
-
name: "Terrible task",
|
|
331
|
-
state: 'notStarted'
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _TaskState = _interopRequireDefault(require("./TaskState"));
|
|
8
|
-
|
|
9
|
-
var _models = require("../../models");
|
|
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.TaskState', function () {
|
|
17
|
-
var checkIsCannotStartYet = function checkIsCannotStartYet(container) {
|
|
18
|
-
expect(container.childNodes.length).toEqual(1);
|
|
19
|
-
expect(container.childNodes[0].classList).toContain('hods-tag');
|
|
20
|
-
expect(container.childNodes[0].classList).toContain("hods-tag--".concat(_models.TaskStates.DETAILS.cannotStartYet.colour));
|
|
21
|
-
expect(container.childNodes[0].textContent).toEqual(_models.TaskStates.DETAILS.cannotStartYet.label);
|
|
22
|
-
return true;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
it('should render a complete state icon', function () {
|
|
26
|
-
var STATE = _models.TaskStates.TYPES.COMPLETE;
|
|
27
|
-
|
|
28
|
-
var _render = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
|
|
29
|
-
state: STATE
|
|
30
|
-
})),
|
|
31
|
-
container = _render.container;
|
|
32
|
-
|
|
33
|
-
expect(container.childNodes.length).toEqual(1);
|
|
34
|
-
expect(container.childNodes[0].classList).toContain('hods-tag');
|
|
35
|
-
expect(container.childNodes[0].textContent).toEqual(_models.TaskStates.DETAILS.complete.label);
|
|
36
|
-
});
|
|
37
|
-
it('should render an in progress state icon', function () {
|
|
38
|
-
var STATE = _models.TaskStates.TYPES.IN_PROGRESS;
|
|
39
|
-
|
|
40
|
-
var _render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
|
|
41
|
-
state: STATE
|
|
42
|
-
})),
|
|
43
|
-
container = _render2.container;
|
|
44
|
-
|
|
45
|
-
expect(container.childNodes.length).toEqual(1);
|
|
46
|
-
expect(container.childNodes[0].classList).toContain('hods-tag');
|
|
47
|
-
expect(container.childNodes[0].classList).toContain("hods-tag--".concat(_models.TaskStates.DETAILS.inProgress.colour));
|
|
48
|
-
expect(container.childNodes[0].textContent).toEqual(_models.TaskStates.DETAILS.inProgress.label);
|
|
49
|
-
});
|
|
50
|
-
it('should render a not started state icon', function () {
|
|
51
|
-
var STATE = _models.TaskStates.TYPES.NOT_STARTED;
|
|
52
|
-
|
|
53
|
-
var _render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
|
|
54
|
-
state: STATE
|
|
55
|
-
})),
|
|
56
|
-
container = _render3.container;
|
|
57
|
-
|
|
58
|
-
expect(container.childNodes.length).toEqual(1);
|
|
59
|
-
expect(container.childNodes[0].classList).toContain('hods-tag');
|
|
60
|
-
expect(container.childNodes[0].classList).toContain("hods-tag--".concat(_models.TaskStates.DETAILS.notStarted.colour));
|
|
61
|
-
expect(container.childNodes[0].textContent).toEqual(_models.TaskStates.DETAILS.notStarted.label);
|
|
62
|
-
});
|
|
63
|
-
it('should render a cannot start state icon', function () {
|
|
64
|
-
var STATE = _models.TaskStates.TYPES.CANNOT_START_YET;
|
|
65
|
-
|
|
66
|
-
var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
|
|
67
|
-
state: STATE
|
|
68
|
-
})),
|
|
69
|
-
container = _render4.container;
|
|
70
|
-
|
|
71
|
-
expect(checkIsCannotStartYet(container)).toBeTruthy();
|
|
72
|
-
});
|
|
73
|
-
it('should render the "Cannot start yet" state if given an unknown value', function () {
|
|
74
|
-
var STATE = 'spellingError';
|
|
75
|
-
|
|
76
|
-
var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
|
|
77
|
-
state: STATE
|
|
78
|
-
})),
|
|
79
|
-
container = _render5.container;
|
|
80
|
-
|
|
81
|
-
expect(checkIsCannotStartYet(container)).toBeTruthy();
|
|
82
|
-
});
|
|
83
|
-
it('should render the "Cannot start yet" state if given null', function () {
|
|
84
|
-
var STATE = null;
|
|
85
|
-
|
|
86
|
-
var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
|
|
87
|
-
state: STATE
|
|
88
|
-
})),
|
|
89
|
-
container = _render6.container;
|
|
90
|
-
|
|
91
|
-
expect(checkIsCannotStartYet(container)).toBeTruthy();
|
|
92
|
-
});
|
|
93
|
-
it('should render the "Cannot start yet" state if given undefined', function () {
|
|
94
|
-
var STATE = undefined;
|
|
95
|
-
|
|
96
|
-
var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
|
|
97
|
-
state: STATE
|
|
98
|
-
})),
|
|
99
|
-
container = _render7.container;
|
|
100
|
-
|
|
101
|
-
expect(checkIsCannotStartYet(container)).toBeTruthy();
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1,60 +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 _hooks = require("../../hooks");
|
|
10
|
-
|
|
11
|
-
var _HooksContext = _interopRequireWildcard(require("./HooksContext"));
|
|
12
|
-
|
|
13
|
-
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); }
|
|
14
|
-
|
|
15
|
-
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; }
|
|
16
|
-
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
20
|
-
|
|
21
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
22
|
-
|
|
23
|
-
var TestComponent = function TestComponent() {
|
|
24
|
-
var _useHooks = (0, _hooks.useHooks)(),
|
|
25
|
-
hooks = _useHooks.hooks,
|
|
26
|
-
addHook = _useHooks.addHook,
|
|
27
|
-
removeHook = _useHooks.removeHook;
|
|
28
|
-
|
|
29
|
-
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, typeof addHook === 'function' && /*#__PURE__*/_react2.default.createElement("span", null, "addHook is a function"), typeof removeHook === 'function' && /*#__PURE__*/_react2.default.createElement("span", null, "removeHook is a function"), Object.keys(hooks).map(function (key) {
|
|
30
|
-
return typeof hooks[key] === 'function' && /*#__PURE__*/_react2.default.createElement("span", {
|
|
31
|
-
key: key
|
|
32
|
-
}, key, " is a function");
|
|
33
|
-
}));
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
describe('context.ValidationContext', function () {
|
|
37
|
-
it('should appropriately set up the context', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
38
|
-
var _render, container;
|
|
39
|
-
|
|
40
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
41
|
-
while (1) {
|
|
42
|
-
switch (_context.prev = _context.next) {
|
|
43
|
-
case 0:
|
|
44
|
-
_render = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_HooksContext.default, null, /*#__PURE__*/_react2.default.createElement(TestComponent, null))), container = _render.container;
|
|
45
|
-
expect(container.childNodes.length).toEqual(2 + _HooksContext.ALLOWED_HOOKS.length);
|
|
46
|
-
expect(container.textContent).toContain('addHook is a function');
|
|
47
|
-
expect(container.textContent).toContain('removeHook is a function');
|
|
48
|
-
|
|
49
|
-
_HooksContext.ALLOWED_HOOKS.forEach(function (hook) {
|
|
50
|
-
expect(container.textContent).toContain("".concat(hook, " is a function"));
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
case 5:
|
|
54
|
-
case "end":
|
|
55
|
-
return _context.stop();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, _callee);
|
|
59
|
-
})));
|
|
60
|
-
});
|