@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,170 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _getCYARowsForCollectionPage = _interopRequireDefault(require("./getCYARowsForCollectionPage"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
|
|
11
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
|
|
13
|
-
describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
14
|
-
var TEXT_COMP = {
|
|
15
|
-
id: 'testText',
|
|
16
|
-
fieldId: 'testText',
|
|
17
|
-
label: 'Test text',
|
|
18
|
-
type: 'text'
|
|
19
|
-
};
|
|
20
|
-
var MASTER_PAGE = {
|
|
21
|
-
id: 'page1',
|
|
22
|
-
collection: {
|
|
23
|
-
name: 'collection',
|
|
24
|
-
labels: {
|
|
25
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
26
|
-
item: 'Collection entry ${index}'
|
|
27
|
-
},
|
|
28
|
-
actions: [{
|
|
29
|
-
type: 'change'
|
|
30
|
-
}, {
|
|
31
|
-
type: 'remove',
|
|
32
|
-
label: 'custom remove label'
|
|
33
|
-
}, {
|
|
34
|
-
type: 'change',
|
|
35
|
-
label: 'custom change label',
|
|
36
|
-
page: 'confirmDelete'
|
|
37
|
-
}]
|
|
38
|
-
},
|
|
39
|
-
title: 'Collection',
|
|
40
|
-
components: [TEXT_COMP]
|
|
41
|
-
};
|
|
42
|
-
it('should return an empty array if the collection has no entries', function () {
|
|
43
|
-
var FORM_DATA = {};
|
|
44
|
-
|
|
45
|
-
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
46
|
-
formData: FORM_DATA
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
50
|
-
expect(ROWS.length).toEqual(0);
|
|
51
|
-
});
|
|
52
|
-
it('should format titles correctly when collection.labels.item is specified', function () {
|
|
53
|
-
var FORM_DATA = {
|
|
54
|
-
collection: [{
|
|
55
|
-
id: '01',
|
|
56
|
-
testText: 'value'
|
|
57
|
-
}]
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
61
|
-
formData: FORM_DATA
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
65
|
-
expect(ROWS.length).toEqual(5); // Title row + action rows + component row
|
|
66
|
-
|
|
67
|
-
expect(ROWS[0].key).toEqual('Collection entry 1');
|
|
68
|
-
});
|
|
69
|
-
it('should provide default titles if collection.labels.item is not specified', function () {
|
|
70
|
-
var FORM_DATA = {
|
|
71
|
-
collection: [{
|
|
72
|
-
id: '01',
|
|
73
|
-
testText: 'value'
|
|
74
|
-
}]
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
78
|
-
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
79
|
-
labels: {}
|
|
80
|
-
}),
|
|
81
|
-
formData: FORM_DATA
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
85
|
-
expect(ROWS.length).toEqual(5); // Title row + action rows + component row
|
|
86
|
-
|
|
87
|
-
expect(ROWS[0].key).toEqual('Item 1');
|
|
88
|
-
});
|
|
89
|
-
it('should return correctly formatted rows for mutliple entries', function () {
|
|
90
|
-
var FORM_DATA = {
|
|
91
|
-
collection: [{
|
|
92
|
-
id: '01',
|
|
93
|
-
testText: 'value'
|
|
94
|
-
}, {
|
|
95
|
-
id: '02',
|
|
96
|
-
testText: 'value'
|
|
97
|
-
}]
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
101
|
-
formData: FORM_DATA
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
105
|
-
expect(ROWS.length).toEqual(10); // Title row + component row for each item
|
|
106
|
-
|
|
107
|
-
expect(ROWS[0].type).toEqual('title');
|
|
108
|
-
expect(ROWS[0].key).toEqual('Collection entry 1'); // Formatted according to collection.labels.item
|
|
109
|
-
|
|
110
|
-
expect(ROWS[1].action.label).toEqual('Change');
|
|
111
|
-
expect(ROWS[2].action.label).toEqual('custom remove label');
|
|
112
|
-
expect(ROWS[3].action.label).toEqual('custom change label');
|
|
113
|
-
expect(ROWS[4].value).toEqual('value');
|
|
114
|
-
expect(ROWS[4].key).toEqual('Test text');
|
|
115
|
-
expect(ROWS[5].type).toEqual('title');
|
|
116
|
-
expect(ROWS[5].key).toEqual('Collection entry 2'); // Formatted according to collection.labels.item
|
|
117
|
-
|
|
118
|
-
expect(ROWS[6].action.label).toEqual('Change');
|
|
119
|
-
expect(ROWS[7].action.label).toEqual('custom remove label');
|
|
120
|
-
expect(ROWS[8].action.label).toEqual('custom change label');
|
|
121
|
-
expect(ROWS[9].value).toEqual('value');
|
|
122
|
-
expect(ROWS[9].key).toEqual('Test text');
|
|
123
|
-
});
|
|
124
|
-
it('should exclude components that should not be shown', function () {
|
|
125
|
-
var FD = {
|
|
126
|
-
collection: [{
|
|
127
|
-
id: '01',
|
|
128
|
-
otherField: 'yes',
|
|
129
|
-
testText: 'testing'
|
|
130
|
-
}, {
|
|
131
|
-
id: '02',
|
|
132
|
-
otherField: 'no',
|
|
133
|
-
testText: 'testing'
|
|
134
|
-
}]
|
|
135
|
-
};
|
|
136
|
-
var C = {
|
|
137
|
-
id: 'testText',
|
|
138
|
-
fieldId: 'testText',
|
|
139
|
-
label: 'Test text',
|
|
140
|
-
type: 'text',
|
|
141
|
-
show_when: {
|
|
142
|
-
field: "otherField",
|
|
143
|
-
op: "!=",
|
|
144
|
-
value: "no"
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
var P = {
|
|
148
|
-
id: 'page1',
|
|
149
|
-
collection: {
|
|
150
|
-
name: 'collection'
|
|
151
|
-
},
|
|
152
|
-
title: 'Collection',
|
|
153
|
-
components: [C]
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
var PAGE = _objectSpread(_objectSpread({}, P), {}, {
|
|
157
|
-
formData: FD
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
161
|
-
expect(ROWS.length).toEqual(3); // Title row + single component as other should fail show check
|
|
162
|
-
|
|
163
|
-
expect(ROWS[0].type).toEqual('title');
|
|
164
|
-
expect(ROWS[0].key).toEqual('Item 1');
|
|
165
|
-
expect(ROWS[1].value).toEqual('testing');
|
|
166
|
-
expect(ROWS[1].key).toEqual('Test text');
|
|
167
|
-
expect(ROWS[2].type).toEqual('title');
|
|
168
|
-
expect(ROWS[2].key).toEqual('Item 2');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _models = require("../../models");
|
|
4
|
-
|
|
5
|
-
var _setupTests = require("../../setupTests");
|
|
6
|
-
|
|
7
|
-
var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
|
|
13
|
-
describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
14
|
-
it('should get an appropriate row for a container with a single readonly text component', function () {
|
|
15
|
-
var FORM_DATA = {
|
|
16
|
-
container: {
|
|
17
|
-
a: 'Bravo'
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var PAGE = {
|
|
21
|
-
id: 'page',
|
|
22
|
-
formData: FORM_DATA,
|
|
23
|
-
cya_link: {}
|
|
24
|
-
};
|
|
25
|
-
var COMPONENT = {
|
|
26
|
-
type: 'text',
|
|
27
|
-
readonly: true,
|
|
28
|
-
id: 'a',
|
|
29
|
-
fieldId: 'a',
|
|
30
|
-
label: 'Alpha'
|
|
31
|
-
};
|
|
32
|
-
var CONTAINER = {
|
|
33
|
-
id: 'container',
|
|
34
|
-
fieldId: 'container',
|
|
35
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
36
|
-
components: [COMPONENT],
|
|
37
|
-
value: FORM_DATA.container,
|
|
38
|
-
formData: FORM_DATA
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
42
|
-
|
|
43
|
-
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
44
|
-
expect(ROWS.length).toEqual(1);
|
|
45
|
-
ROWS.forEach(function (row, index) {
|
|
46
|
-
(0, _setupTests.expectObjectLike)(row, {
|
|
47
|
-
pageId: PAGE.id,
|
|
48
|
-
fieldId: CONTAINER.components[index].fieldId,
|
|
49
|
-
key: CONTAINER.components[index].label,
|
|
50
|
-
action: null,
|
|
51
|
-
component: COMPONENT,
|
|
52
|
-
value: 'Bravo'
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
it('should get appropriate rows for a container with two editable text components', function () {
|
|
57
|
-
var FORM_DATA = {
|
|
58
|
-
container: {
|
|
59
|
-
a: 'Alpha Charlie',
|
|
60
|
-
b: 'Bravo Charlie'
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
var PAGE = {
|
|
64
|
-
id: 'page',
|
|
65
|
-
formData: FORM_DATA,
|
|
66
|
-
cya_link: {}
|
|
67
|
-
};
|
|
68
|
-
var COMPONENT_A = {
|
|
69
|
-
type: 'text',
|
|
70
|
-
id: 'a',
|
|
71
|
-
fieldId: 'a',
|
|
72
|
-
label: 'Alpha'
|
|
73
|
-
};
|
|
74
|
-
var COMPONENT_B = {
|
|
75
|
-
type: 'text',
|
|
76
|
-
id: 'b',
|
|
77
|
-
fieldId: 'b',
|
|
78
|
-
label: 'Bravo'
|
|
79
|
-
};
|
|
80
|
-
var CONTAINER = {
|
|
81
|
-
id: 'container',
|
|
82
|
-
fieldId: 'container',
|
|
83
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
84
|
-
components: [COMPONENT_A, COMPONENT_B],
|
|
85
|
-
value: FORM_DATA.container,
|
|
86
|
-
formData: FORM_DATA
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
90
|
-
|
|
91
|
-
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
92
|
-
expect(ROWS.length).toEqual(2);
|
|
93
|
-
ROWS.forEach(function (row, index) {
|
|
94
|
-
(0, _setupTests.expectObjectLike)(row, {
|
|
95
|
-
pageId: PAGE.id,
|
|
96
|
-
fieldId: CONTAINER.components[index].fieldId,
|
|
97
|
-
key: CONTAINER.components[index].label,
|
|
98
|
-
component: CONTAINER.components[index],
|
|
99
|
-
value: "".concat(CONTAINER.components[index].label, " Charlie")
|
|
100
|
-
});
|
|
101
|
-
(0, _setupTests.expectObjectLike)(row.action, {
|
|
102
|
-
onAction: ON_ACTION
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
it("should filter out any components that shouldn't be shown", function () {
|
|
107
|
-
var FORM_DATA = {
|
|
108
|
-
container: {
|
|
109
|
-
a: 'Alpha Charlie',
|
|
110
|
-
b: 'Bravo Charlie'
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
var PAGE = {
|
|
114
|
-
id: 'page',
|
|
115
|
-
formData: FORM_DATA,
|
|
116
|
-
cya_link: {}
|
|
117
|
-
};
|
|
118
|
-
var COMPONENT_A = {
|
|
119
|
-
type: 'text',
|
|
120
|
-
id: 'a',
|
|
121
|
-
fieldId: 'a',
|
|
122
|
-
label: 'Alpha'
|
|
123
|
-
};
|
|
124
|
-
var COMPONENT_B = {
|
|
125
|
-
type: 'text',
|
|
126
|
-
id: 'b',
|
|
127
|
-
fieldId: 'b',
|
|
128
|
-
label: 'Bravo'
|
|
129
|
-
};
|
|
130
|
-
var COMPONENT_C = {
|
|
131
|
-
type: 'heading',
|
|
132
|
-
content: 'Heading component'
|
|
133
|
-
};
|
|
134
|
-
var CONTAINER = {
|
|
135
|
-
id: 'container',
|
|
136
|
-
fieldId: 'container',
|
|
137
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
138
|
-
components: [COMPONENT_A, COMPONENT_B, COMPONENT_C],
|
|
139
|
-
value: FORM_DATA.container,
|
|
140
|
-
formData: FORM_DATA
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
144
|
-
|
|
145
|
-
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
146
|
-
expect(ROWS.length).toEqual(2);
|
|
147
|
-
ROWS.forEach(function (row, index) {
|
|
148
|
-
(0, _setupTests.expectObjectLike)(row, {
|
|
149
|
-
pageId: PAGE.id,
|
|
150
|
-
fieldId: CONTAINER.components[index].fieldId,
|
|
151
|
-
key: CONTAINER.components[index].label,
|
|
152
|
-
component: CONTAINER.components[index],
|
|
153
|
-
value: "".concat(CONTAINER.components[index].label, " Charlie")
|
|
154
|
-
});
|
|
155
|
-
(0, _setupTests.expectObjectLike)(row.action, {
|
|
156
|
-
onAction: ON_ACTION
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
it('should get an appropriate row for a container with a single readonly text component inside a nested container', function () {
|
|
161
|
-
var FORM_DATA = {
|
|
162
|
-
container: {
|
|
163
|
-
nested: {
|
|
164
|
-
a: 'Bravo'
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
var PAGE = {
|
|
169
|
-
id: 'page',
|
|
170
|
-
formData: FORM_DATA,
|
|
171
|
-
cya_link: {}
|
|
172
|
-
};
|
|
173
|
-
var COMPONENT = {
|
|
174
|
-
type: 'text',
|
|
175
|
-
readonly: true,
|
|
176
|
-
id: 'a',
|
|
177
|
-
fieldId: 'a',
|
|
178
|
-
label: 'Alpha'
|
|
179
|
-
};
|
|
180
|
-
var NESTED_CONTAINER = {
|
|
181
|
-
id: 'nested',
|
|
182
|
-
fieldId: 'nested',
|
|
183
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
184
|
-
components: [COMPONENT],
|
|
185
|
-
value: FORM_DATA.container.nested,
|
|
186
|
-
formData: FORM_DATA
|
|
187
|
-
};
|
|
188
|
-
var CONTAINER = {
|
|
189
|
-
id: 'container',
|
|
190
|
-
fieldId: 'container',
|
|
191
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
192
|
-
components: [NESTED_CONTAINER],
|
|
193
|
-
value: FORM_DATA.container,
|
|
194
|
-
formData: FORM_DATA
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
198
|
-
|
|
199
|
-
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
200
|
-
expect(ROWS.length).toEqual(1);
|
|
201
|
-
ROWS.forEach(function (row, index) {
|
|
202
|
-
(0, _setupTests.expectObjectLike)(row, {
|
|
203
|
-
pageId: PAGE.id,
|
|
204
|
-
fieldId: NESTED_CONTAINER.components[index].fieldId,
|
|
205
|
-
key: NESTED_CONTAINER.components[index].label,
|
|
206
|
-
action: null,
|
|
207
|
-
component: COMPONENT,
|
|
208
|
-
value: 'Bravo'
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
it('should get an appropriate row for a container with a single readonly text component inside a nested container but no formData', function () {
|
|
213
|
-
var FORM_DATA = undefined;
|
|
214
|
-
var PAGE = {
|
|
215
|
-
id: 'page',
|
|
216
|
-
formData: FORM_DATA,
|
|
217
|
-
cya_link: {}
|
|
218
|
-
};
|
|
219
|
-
var COMPONENT = {
|
|
220
|
-
type: 'text',
|
|
221
|
-
readonly: true,
|
|
222
|
-
id: 'a',
|
|
223
|
-
fieldId: 'a',
|
|
224
|
-
label: 'Alpha'
|
|
225
|
-
};
|
|
226
|
-
var NESTED_CONTAINER = {
|
|
227
|
-
id: 'nested',
|
|
228
|
-
fieldId: 'nested',
|
|
229
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
230
|
-
components: [COMPONENT]
|
|
231
|
-
};
|
|
232
|
-
var CONTAINER = {
|
|
233
|
-
id: 'container',
|
|
234
|
-
fieldId: 'container',
|
|
235
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
236
|
-
components: [NESTED_CONTAINER]
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
240
|
-
|
|
241
|
-
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, undefined, ON_ACTION);
|
|
242
|
-
expect(ROWS.length).toEqual(1);
|
|
243
|
-
ROWS.forEach(function (row, index) {
|
|
244
|
-
(0, _setupTests.expectObjectLike)(row, {
|
|
245
|
-
pageId: PAGE.id,
|
|
246
|
-
fieldId: NESTED_CONTAINER.components[index].fieldId,
|
|
247
|
-
key: NESTED_CONTAINER.components[index].label,
|
|
248
|
-
action: null,
|
|
249
|
-
component: COMPONENT,
|
|
250
|
-
value: ''
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
it('should get an appropriate row for a collection with a single text component inside a container', function () {
|
|
255
|
-
var OUTER_ID = 'a';
|
|
256
|
-
var INNER_ID = 'b';
|
|
257
|
-
|
|
258
|
-
var FORM_DATA = _defineProperty({}, OUTER_ID, [_defineProperty({}, INNER_ID, 'Bravo'), _defineProperty({}, INNER_ID, 'Charlie')]);
|
|
259
|
-
|
|
260
|
-
var PAGE = {
|
|
261
|
-
id: 'page',
|
|
262
|
-
formData: FORM_DATA,
|
|
263
|
-
cya_link: {},
|
|
264
|
-
collection: 'collectionName'
|
|
265
|
-
};
|
|
266
|
-
var COLLECTION_COMPONENT = {
|
|
267
|
-
type: 'collection',
|
|
268
|
-
id: OUTER_ID,
|
|
269
|
-
fieldId: OUTER_ID,
|
|
270
|
-
label: 'Alpha',
|
|
271
|
-
item: [{
|
|
272
|
-
id: INNER_ID,
|
|
273
|
-
fieldId: INNER_ID,
|
|
274
|
-
label: INNER_ID,
|
|
275
|
-
type: 'text'
|
|
276
|
-
}]
|
|
277
|
-
};
|
|
278
|
-
var CONTAINER = {
|
|
279
|
-
id: 'container',
|
|
280
|
-
fieldId: 'container',
|
|
281
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
282
|
-
components: [COLLECTION_COMPONENT],
|
|
283
|
-
value: FORM_DATA.container,
|
|
284
|
-
formData: FORM_DATA
|
|
285
|
-
};
|
|
286
|
-
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA, function () {});
|
|
287
|
-
expect(ROWS.length).toEqual(4);
|
|
288
|
-
|
|
289
|
-
var checkTitleRow = function checkTitleRow(index, row) {
|
|
290
|
-
expect(row).toEqual({
|
|
291
|
-
pageId: PAGE.id,
|
|
292
|
-
fieldId: CONTAINER.components[0].fieldId,
|
|
293
|
-
key: "Item ".concat(index + 1),
|
|
294
|
-
action: null,
|
|
295
|
-
full_path: "".concat(OUTER_ID, "[").concat(index, "]"),
|
|
296
|
-
type: 'title'
|
|
297
|
-
});
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
var checkValueRow = function checkValueRow(index, row, value) {
|
|
301
|
-
(0, _setupTests.expectObjectLike)(row, {
|
|
302
|
-
pageId: PAGE.id,
|
|
303
|
-
fieldId: INNER_ID,
|
|
304
|
-
key: INNER_ID,
|
|
305
|
-
id: INNER_ID,
|
|
306
|
-
component: {
|
|
307
|
-
fieldId: INNER_ID,
|
|
308
|
-
full_path: "".concat(OUTER_ID, "[").concat(index, "].").concat(INNER_ID),
|
|
309
|
-
id: INNER_ID,
|
|
310
|
-
label: INNER_ID,
|
|
311
|
-
type: 'text'
|
|
312
|
-
},
|
|
313
|
-
value: value,
|
|
314
|
-
full_path: "".concat(OUTER_ID, "[").concat(index, "].").concat(INNER_ID)
|
|
315
|
-
});
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
checkTitleRow(0, ROWS[0]);
|
|
319
|
-
checkValueRow(0, ROWS[1], 'Bravo');
|
|
320
|
-
checkTitleRow(1, ROWS[2]);
|
|
321
|
-
checkValueRow(1, ROWS[3], 'Charlie');
|
|
322
|
-
});
|
|
323
|
-
});
|