@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,281 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _setupTests = require("../../setupTests");
|
|
4
|
-
|
|
5
|
-
var _models = require("../../models");
|
|
6
|
-
|
|
7
|
-
var _getCYARowsForPage = _interopRequireDefault(require("./getCYARowsForPage"));
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
|
|
13
|
-
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; }
|
|
14
|
-
|
|
15
|
-
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; }
|
|
16
|
-
|
|
17
|
-
describe('utils', function () {
|
|
18
|
-
describe('CheckYourAnswers', function () {
|
|
19
|
-
describe('getCYARowsForPage', function () {
|
|
20
|
-
it('should get a appropriate row for a page with a single readonly text component', function () {
|
|
21
|
-
var COMPONENT = {
|
|
22
|
-
type: 'text',
|
|
23
|
-
readonly: true,
|
|
24
|
-
id: 'a',
|
|
25
|
-
fieldId: 'a',
|
|
26
|
-
label: 'Alpha'
|
|
27
|
-
};
|
|
28
|
-
var PAGE = {
|
|
29
|
-
id: 'page',
|
|
30
|
-
components: [COMPONENT],
|
|
31
|
-
formData: {
|
|
32
|
-
a: 'Bravo'
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
37
|
-
|
|
38
|
-
var ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
39
|
-
expect(ROWS.length).toEqual(1);
|
|
40
|
-
ROWS.forEach(function (row, index) {
|
|
41
|
-
(0, _setupTests.expectObjectLike)(row, {
|
|
42
|
-
pageId: PAGE.id,
|
|
43
|
-
fieldId: PAGE.components[index].fieldId,
|
|
44
|
-
key: PAGE.components[index].label,
|
|
45
|
-
action: null,
|
|
46
|
-
component: COMPONENT,
|
|
47
|
-
value: 'Bravo'
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
it('should get appropriate rows for a page with two editable text components', function () {
|
|
52
|
-
var COMPONENT_A = {
|
|
53
|
-
type: 'text',
|
|
54
|
-
id: 'a',
|
|
55
|
-
fieldId: 'a',
|
|
56
|
-
label: 'Alpha'
|
|
57
|
-
};
|
|
58
|
-
var COMPONENT_B = {
|
|
59
|
-
type: 'text',
|
|
60
|
-
id: 'b',
|
|
61
|
-
fieldId: 'b',
|
|
62
|
-
label: 'Bravo'
|
|
63
|
-
};
|
|
64
|
-
var PAGE = {
|
|
65
|
-
id: 'page',
|
|
66
|
-
components: [COMPONENT_A, COMPONENT_B],
|
|
67
|
-
formData: {
|
|
68
|
-
a: 'Alpha Charlie',
|
|
69
|
-
b: 'Bravo Charlie'
|
|
70
|
-
},
|
|
71
|
-
cya_link: {}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
75
|
-
|
|
76
|
-
var ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
77
|
-
expect(ROWS.length).toEqual(2);
|
|
78
|
-
ROWS.forEach(function (row, index) {
|
|
79
|
-
(0, _setupTests.expectObjectLike)(row, {
|
|
80
|
-
pageId: PAGE.id,
|
|
81
|
-
fieldId: PAGE.components[index].fieldId,
|
|
82
|
-
key: PAGE.components[index].label,
|
|
83
|
-
component: PAGE.components[index],
|
|
84
|
-
value: "".concat(PAGE.components[index].label, " Charlie")
|
|
85
|
-
});
|
|
86
|
-
(0, _setupTests.expectObjectLike)(row.action, {
|
|
87
|
-
onAction: ON_ACTION
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
it("should filter out any components that shouldn't be shown", function () {
|
|
92
|
-
var COMPONENT_A = {
|
|
93
|
-
type: 'text',
|
|
94
|
-
id: 'a',
|
|
95
|
-
fieldId: 'a',
|
|
96
|
-
label: 'Alpha'
|
|
97
|
-
};
|
|
98
|
-
var COMPONENT_B = {
|
|
99
|
-
type: 'text',
|
|
100
|
-
id: 'b',
|
|
101
|
-
fieldId: 'b',
|
|
102
|
-
label: 'Bravo'
|
|
103
|
-
};
|
|
104
|
-
var COMPONENT_C = {
|
|
105
|
-
type: 'heading',
|
|
106
|
-
content: 'Heading component'
|
|
107
|
-
};
|
|
108
|
-
var PAGE = {
|
|
109
|
-
id: 'page',
|
|
110
|
-
components: [COMPONENT_A, COMPONENT_B, COMPONENT_C],
|
|
111
|
-
formData: {
|
|
112
|
-
a: 'Alpha Charlie',
|
|
113
|
-
b: 'Bravo Charlie'
|
|
114
|
-
},
|
|
115
|
-
cya_link: {}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
119
|
-
|
|
120
|
-
var ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
121
|
-
expect(ROWS.length).toEqual(2);
|
|
122
|
-
ROWS.forEach(function (row, index) {
|
|
123
|
-
(0, _setupTests.expectObjectLike)(row, {
|
|
124
|
-
pageId: PAGE.id,
|
|
125
|
-
fieldId: PAGE.components[index].fieldId,
|
|
126
|
-
key: PAGE.components[index].label,
|
|
127
|
-
component: PAGE.components[index],
|
|
128
|
-
value: "".concat(PAGE.components[index].label, " Charlie")
|
|
129
|
-
});
|
|
130
|
-
(0, _setupTests.expectObjectLike)(row.action, {
|
|
131
|
-
onAction: ON_ACTION
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
it('should get a appropriate row for a page with a single readonly text component inside of a container', function () {
|
|
136
|
-
var FORM_DATA = {
|
|
137
|
-
container: {
|
|
138
|
-
a: 'Bravo'
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
var COMPONENT = {
|
|
142
|
-
type: 'text',
|
|
143
|
-
readonly: true,
|
|
144
|
-
id: 'a',
|
|
145
|
-
fieldId: 'a',
|
|
146
|
-
label: 'Alpha'
|
|
147
|
-
};
|
|
148
|
-
var CONTAINER = {
|
|
149
|
-
id: 'container',
|
|
150
|
-
fieldId: 'container',
|
|
151
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
152
|
-
components: [COMPONENT],
|
|
153
|
-
value: FORM_DATA.container,
|
|
154
|
-
formData: FORM_DATA
|
|
155
|
-
};
|
|
156
|
-
var PAGE = {
|
|
157
|
-
id: 'page',
|
|
158
|
-
components: [CONTAINER],
|
|
159
|
-
formData: FORM_DATA
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
163
|
-
|
|
164
|
-
var ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
165
|
-
expect(ROWS.length).toEqual(1);
|
|
166
|
-
ROWS.forEach(function (row, index) {
|
|
167
|
-
(0, _setupTests.expectObjectLike)(row, {
|
|
168
|
-
pageId: PAGE.id,
|
|
169
|
-
fieldId: CONTAINER.components[index].fieldId,
|
|
170
|
-
key: CONTAINER.components[index].label,
|
|
171
|
-
action: null,
|
|
172
|
-
component: COMPONENT,
|
|
173
|
-
value: 'Bravo'
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
it('Add ability to display answers from multiple fields in a single row', function () {
|
|
178
|
-
var COMPONENT_ADDRESS = {
|
|
179
|
-
id: 'firstLineOfTheAddress',
|
|
180
|
-
fieldId: 'firstLineOfTheAddress',
|
|
181
|
-
label: 'address',
|
|
182
|
-
type: 'text'
|
|
183
|
-
};
|
|
184
|
-
var COMPONENT_TOWN = {
|
|
185
|
-
id: 'town',
|
|
186
|
-
fieldId: 'town',
|
|
187
|
-
label: 'Town',
|
|
188
|
-
type: 'text'
|
|
189
|
-
};
|
|
190
|
-
var COMPONENT_CITY = {
|
|
191
|
-
id: 'city',
|
|
192
|
-
fieldId: 'city',
|
|
193
|
-
label: 'City',
|
|
194
|
-
type: 'text'
|
|
195
|
-
};
|
|
196
|
-
var COMPONENT_POSTCODE = {
|
|
197
|
-
id: 'postCode',
|
|
198
|
-
fieldId: 'postCode',
|
|
199
|
-
label: 'postCode',
|
|
200
|
-
type: 'text'
|
|
201
|
-
};
|
|
202
|
-
var PAGE = {
|
|
203
|
-
components: [COMPONENT_ADDRESS, COMPONENT_TOWN, COMPONENT_CITY, COMPONENT_POSTCODE],
|
|
204
|
-
id: 'addressDetails',
|
|
205
|
-
fieldId: 'UK address',
|
|
206
|
-
groups: [{
|
|
207
|
-
id: 'address',
|
|
208
|
-
label: 'Address details',
|
|
209
|
-
components: ['firstLineOfTheAddress', 'town', 'city', 'postCode']
|
|
210
|
-
}],
|
|
211
|
-
name: 'address-details',
|
|
212
|
-
title: 'Address details',
|
|
213
|
-
formData: {
|
|
214
|
-
firstLineOfTheAddress: '10 Downing Street',
|
|
215
|
-
town: 'City of Westminster',
|
|
216
|
-
city: 'London',
|
|
217
|
-
postCode: 'SW1A 2AA'
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
222
|
-
|
|
223
|
-
var _renderWithValidation = (0, _setupTests.renderWithValidation)((0, _getCYARowsForPage.default)(PAGE, ON_ACTION).map(function (row) {
|
|
224
|
-
return row.value;
|
|
225
|
-
})),
|
|
226
|
-
container = _renderWithValidation.container;
|
|
227
|
-
|
|
228
|
-
expect(container.childNodes.length).toEqual(4);
|
|
229
|
-
var addressValues = container.childNodes;
|
|
230
|
-
expect(addressValues[0].childNodes[0].textContent).toEqual('10 Downing Street');
|
|
231
|
-
expect(addressValues[1].childNodes[0].textContent).toEqual('City of Westminster');
|
|
232
|
-
expect(addressValues[2].childNodes[0].textContent).toEqual('London');
|
|
233
|
-
expect(addressValues[3].childNodes[0].textContent).toEqual('SW1A 2AA');
|
|
234
|
-
});
|
|
235
|
-
it('should get appropriate rows for a page with a single readonly text component within a collection', function () {
|
|
236
|
-
var FORM_DATA = {
|
|
237
|
-
collection: [{
|
|
238
|
-
a: 'Bravo'
|
|
239
|
-
}]
|
|
240
|
-
};
|
|
241
|
-
var COMPONENT = {
|
|
242
|
-
type: 'text',
|
|
243
|
-
readonly: true,
|
|
244
|
-
id: 'a',
|
|
245
|
-
fieldId: 'a',
|
|
246
|
-
label: 'Alpha'
|
|
247
|
-
};
|
|
248
|
-
var COLLECTION = {
|
|
249
|
-
id: 'collection',
|
|
250
|
-
fieldId: 'collection',
|
|
251
|
-
type: _models.ComponentTypes.COLLECTION,
|
|
252
|
-
item: [COMPONENT],
|
|
253
|
-
value: FORM_DATA.collection,
|
|
254
|
-
formData: FORM_DATA
|
|
255
|
-
};
|
|
256
|
-
var PAGE = {
|
|
257
|
-
id: 'page',
|
|
258
|
-
components: [COLLECTION],
|
|
259
|
-
formData: FORM_DATA
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
var ON_ACTION = function ON_ACTION() {};
|
|
263
|
-
|
|
264
|
-
var ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
265
|
-
expect(ROWS.length).toEqual(2); // Title and item row
|
|
266
|
-
|
|
267
|
-
(0, _setupTests.expectObjectLike)(ROWS[1], {
|
|
268
|
-
pageId: PAGE.id,
|
|
269
|
-
fieldId: COMPONENT.fieldId,
|
|
270
|
-
full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
|
|
271
|
-
key: COMPONENT.label,
|
|
272
|
-
action: null,
|
|
273
|
-
component: _objectSpread(_objectSpread({}, COMPONENT), {}, {
|
|
274
|
-
full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId)
|
|
275
|
-
}),
|
|
276
|
-
value: 'Bravo'
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _models = require("../../models");
|
|
4
|
-
|
|
5
|
-
var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
// Local imports
|
|
10
|
-
describe('utils', function () {
|
|
11
|
-
describe('CheckYourAnswers', function () {
|
|
12
|
-
describe('showComponentCYA', function () {
|
|
13
|
-
it('should not show when there are no options', function () {
|
|
14
|
-
expect((0, _showComponentCYA.default)(null, null)).toBeFalsy();
|
|
15
|
-
});
|
|
16
|
-
it('should not show when show_on_cya is defined and falsy', function () {
|
|
17
|
-
expect((0, _showComponentCYA.default)({
|
|
18
|
-
show_on_cya: false
|
|
19
|
-
})).toBeFalsy();
|
|
20
|
-
});
|
|
21
|
-
it('should not show when it is a heading type', function () {
|
|
22
|
-
expect((0, _showComponentCYA.default)({
|
|
23
|
-
type: _models.ComponentTypes.HEADING
|
|
24
|
-
}, null)).toBeFalsy();
|
|
25
|
-
});
|
|
26
|
-
it('should not show when it is an html type', function () {
|
|
27
|
-
expect((0, _showComponentCYA.default)({
|
|
28
|
-
type: _models.ComponentTypes.HTML
|
|
29
|
-
}, null)).toBeFalsy();
|
|
30
|
-
});
|
|
31
|
-
it('should not show when it is an inset-text type', function () {
|
|
32
|
-
expect((0, _showComponentCYA.default)({
|
|
33
|
-
type: _models.ComponentTypes.INSET_TEXT
|
|
34
|
-
}, null)).toBeFalsy();
|
|
35
|
-
});
|
|
36
|
-
it('should not show when it hidden and disabled', function () {
|
|
37
|
-
expect((0, _showComponentCYA.default)({
|
|
38
|
-
hidden: true,
|
|
39
|
-
disabled: true
|
|
40
|
-
}, null)).toBeFalsy();
|
|
41
|
-
});
|
|
42
|
-
it('should show when show_on_cya is defined and truthy', function () {
|
|
43
|
-
expect((0, _showComponentCYA.default)({
|
|
44
|
-
show_on_cya: true
|
|
45
|
-
})).toBeTruthy();
|
|
46
|
-
});
|
|
47
|
-
it('should show when it hidden but not disabled', function () {
|
|
48
|
-
expect((0, _showComponentCYA.default)({
|
|
49
|
-
hidden: true
|
|
50
|
-
}, null)).toBeTruthy();
|
|
51
|
-
});
|
|
52
|
-
it('should show when it disabled but not hidden', function () {
|
|
53
|
-
expect((0, _showComponentCYA.default)({
|
|
54
|
-
disabled: true
|
|
55
|
-
}, null)).toBeTruthy();
|
|
56
|
-
});
|
|
57
|
-
it('should show when it not html, inset-text, a heading, hidden, or disabled', function () {
|
|
58
|
-
expect((0, _showComponentCYA.default)({
|
|
59
|
-
type: _models.ComponentTypes.TEXT
|
|
60
|
-
}, null)).toBeTruthy();
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _duplicateCollectionPageActiveEntry = _interopRequireDefault(require("./duplicateCollectionPageActiveEntry"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
|
-
describe('utils.CollectionPage.duplicateCollectionPageActiveEntry', function () {
|
|
10
|
-
var COLLECTION_NAME = 'testCollection';
|
|
11
|
-
var OBJ = {
|
|
12
|
-
id: '1',
|
|
13
|
-
value: 'value'
|
|
14
|
-
};
|
|
15
|
-
it('should duplicate the active entry if one exists', function () {
|
|
16
|
-
var _FORM_DATA;
|
|
17
|
-
|
|
18
|
-
var FORM_DATA = (_FORM_DATA = {}, _defineProperty(_FORM_DATA, "".concat(COLLECTION_NAME, "ActiveId"), '1'), _defineProperty(_FORM_DATA, COLLECTION_NAME, [OBJ]), _FORM_DATA);
|
|
19
|
-
(0, _duplicateCollectionPageActiveEntry.default)(COLLECTION_NAME, FORM_DATA);
|
|
20
|
-
expect(FORM_DATA[COLLECTION_NAME].length).toEqual(2);
|
|
21
|
-
expect(FORM_DATA[COLLECTION_NAME][1].value).toEqual(FORM_DATA[COLLECTION_NAME][0].value);
|
|
22
|
-
expect(FORM_DATA[COLLECTION_NAME][1].id).toBeTruthy();
|
|
23
|
-
expect(FORM_DATA[COLLECTION_NAME][1].id === '1').toBeFalsy();
|
|
24
|
-
expect(FORM_DATA["".concat(COLLECTION_NAME, "ActiveId")]).toBeTruthy();
|
|
25
|
-
expect(FORM_DATA["".concat(COLLECTION_NAME, "ActiveId")] === '1').toBeFalsy();
|
|
26
|
-
});
|
|
27
|
-
it('should do nothing if there is no active entry', function () {
|
|
28
|
-
var _FORM_DATA2;
|
|
29
|
-
|
|
30
|
-
var FORM_DATA = (_FORM_DATA2 = {}, _defineProperty(_FORM_DATA2, "".concat(COLLECTION_NAME, "ActiveId"), '2'), _defineProperty(_FORM_DATA2, COLLECTION_NAME, [OBJ]), _FORM_DATA2);
|
|
31
|
-
(0, _duplicateCollectionPageActiveEntry.default)(COLLECTION_NAME, FORM_DATA);
|
|
32
|
-
expect(FORM_DATA[COLLECTION_NAME].length).toEqual(1);
|
|
33
|
-
expect(FORM_DATA[COLLECTION_NAME][0]).toEqual(OBJ);
|
|
34
|
-
expect(FORM_DATA["".concat(COLLECTION_NAME, "ActiveId")]).toEqual('2'); // Shouldn't have changed.
|
|
35
|
-
});
|
|
36
|
-
it('should do nothing if the collection does not exist', function () {
|
|
37
|
-
var FORM_DATA = {};
|
|
38
|
-
(0, _duplicateCollectionPageActiveEntry.default)(COLLECTION_NAME, FORM_DATA);
|
|
39
|
-
expect(FORM_DATA).toEqual({});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _getCollectionPageActiveIndex = _interopRequireDefault(require("./getCollectionPageActiveIndex"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
// Local imports
|
|
8
|
-
describe('utils.CollectionPage.getCollectionPageActiveIndex', function () {
|
|
9
|
-
it('should return the index of the active item in the collection, if one exists', function () {
|
|
10
|
-
var COLLECTION_NAME = 'test';
|
|
11
|
-
var ACTIVE_ID = '002';
|
|
12
|
-
var FORM_DATA = {
|
|
13
|
-
testActiveId: ACTIVE_ID,
|
|
14
|
-
test: [{
|
|
15
|
-
id: '001'
|
|
16
|
-
}, {
|
|
17
|
-
id: '002'
|
|
18
|
-
}]
|
|
19
|
-
};
|
|
20
|
-
var PAGE = {
|
|
21
|
-
collection: {
|
|
22
|
-
name: COLLECTION_NAME
|
|
23
|
-
},
|
|
24
|
-
formData: FORM_DATA
|
|
25
|
-
};
|
|
26
|
-
expect((0, _getCollectionPageActiveIndex.default)(PAGE.collection.name, PAGE.formData)).toEqual(1);
|
|
27
|
-
});
|
|
28
|
-
it('should return null if no active item can be found in the collection', function () {
|
|
29
|
-
var COLLECTION_NAME = 'test';
|
|
30
|
-
var ACTIVE_ID = '002';
|
|
31
|
-
var FORM_DATA = {
|
|
32
|
-
testActiveId: ACTIVE_ID,
|
|
33
|
-
test: [{
|
|
34
|
-
id: '001'
|
|
35
|
-
}]
|
|
36
|
-
};
|
|
37
|
-
var PAGE = {
|
|
38
|
-
collection: {
|
|
39
|
-
name: COLLECTION_NAME
|
|
40
|
-
},
|
|
41
|
-
formData: FORM_DATA
|
|
42
|
-
};
|
|
43
|
-
expect((0, _getCollectionPageActiveIndex.default)(PAGE.collection.name, PAGE.formData)).toEqual(null);
|
|
44
|
-
});
|
|
45
|
-
it('should return null if formData is null', function () {
|
|
46
|
-
var COLLECTION_NAME = 'test';
|
|
47
|
-
var PAGE = {
|
|
48
|
-
collection: {
|
|
49
|
-
name: COLLECTION_NAME
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
expect((0, _getCollectionPageActiveIndex.default)(PAGE.collection.name, null)).toEqual(null);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _mergeCollectionPages = _interopRequireDefault(require("./mergeCollectionPages"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
// Local imports
|
|
8
|
-
describe('utils.CollectionPage.mergeCollectionPages', function () {
|
|
9
|
-
var TEXT_COMP = {
|
|
10
|
-
id: 'testText',
|
|
11
|
-
fieldId: 'testText',
|
|
12
|
-
type: 'text'
|
|
13
|
-
};
|
|
14
|
-
var DATE_COMP = {
|
|
15
|
-
id: 'testDate',
|
|
16
|
-
fieldId: 'testDate',
|
|
17
|
-
type: 'date'
|
|
18
|
-
};
|
|
19
|
-
it('should return the same array if no pages belong to collections', function () {
|
|
20
|
-
var PAGES = [{
|
|
21
|
-
id: 'page1'
|
|
22
|
-
}, {
|
|
23
|
-
id: 'page2'
|
|
24
|
-
}];
|
|
25
|
-
expect((0, _mergeCollectionPages.default)(PAGES)).toEqual(PAGES);
|
|
26
|
-
});
|
|
27
|
-
it('should merge pages from the same collection into a single page', function () {
|
|
28
|
-
var PAGES = [{
|
|
29
|
-
id: 'page1',
|
|
30
|
-
collection: {
|
|
31
|
-
name: 'collection'
|
|
32
|
-
},
|
|
33
|
-
components: [TEXT_COMP]
|
|
34
|
-
}, {
|
|
35
|
-
id: 'page2',
|
|
36
|
-
collection: {
|
|
37
|
-
name: 'collection'
|
|
38
|
-
},
|
|
39
|
-
components: [DATE_COMP]
|
|
40
|
-
}];
|
|
41
|
-
var RESULT = (0, _mergeCollectionPages.default)(PAGES);
|
|
42
|
-
expect(RESULT.length).toEqual(1);
|
|
43
|
-
expect(RESULT[0]).toEqual({
|
|
44
|
-
id: 'page1',
|
|
45
|
-
title: 'Collection',
|
|
46
|
-
collection: {
|
|
47
|
-
name: 'collection'
|
|
48
|
-
},
|
|
49
|
-
components: [TEXT_COMP, DATE_COMP],
|
|
50
|
-
formData: {}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
it('should leave non-collection pages unaffected', function () {
|
|
54
|
-
var PAGES = [{
|
|
55
|
-
id: 'page1',
|
|
56
|
-
collection: {
|
|
57
|
-
name: 'collection'
|
|
58
|
-
},
|
|
59
|
-
components: [TEXT_COMP]
|
|
60
|
-
}, {
|
|
61
|
-
id: 'page2',
|
|
62
|
-
collection: {
|
|
63
|
-
name: 'collection'
|
|
64
|
-
},
|
|
65
|
-
components: [DATE_COMP]
|
|
66
|
-
}, {
|
|
67
|
-
id: 'page3'
|
|
68
|
-
}];
|
|
69
|
-
var RESULT = (0, _mergeCollectionPages.default)(PAGES);
|
|
70
|
-
expect(RESULT.length).toEqual(2);
|
|
71
|
-
expect(RESULT[0]).toEqual({
|
|
72
|
-
id: 'page1',
|
|
73
|
-
title: 'Collection',
|
|
74
|
-
collection: {
|
|
75
|
-
name: 'collection'
|
|
76
|
-
},
|
|
77
|
-
components: [TEXT_COMP, DATE_COMP],
|
|
78
|
-
formData: {}
|
|
79
|
-
});
|
|
80
|
-
expect(RESULT[1]).toEqual({
|
|
81
|
-
id: 'page3'
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
it('should handle multiple collections', function () {
|
|
85
|
-
var PAGES = [{
|
|
86
|
-
id: 'page1',
|
|
87
|
-
collection: {
|
|
88
|
-
name: 'collection1'
|
|
89
|
-
},
|
|
90
|
-
components: []
|
|
91
|
-
}, {
|
|
92
|
-
id: 'page2',
|
|
93
|
-
collection: {
|
|
94
|
-
name: 'collection1'
|
|
95
|
-
},
|
|
96
|
-
components: []
|
|
97
|
-
}, {
|
|
98
|
-
id: 'page3',
|
|
99
|
-
collection: {
|
|
100
|
-
name: 'collection2'
|
|
101
|
-
},
|
|
102
|
-
components: []
|
|
103
|
-
}, {
|
|
104
|
-
id: 'page4',
|
|
105
|
-
collection: {
|
|
106
|
-
name: 'collection2'
|
|
107
|
-
},
|
|
108
|
-
components: []
|
|
109
|
-
}];
|
|
110
|
-
var RESULT = (0, _mergeCollectionPages.default)(PAGES);
|
|
111
|
-
expect(RESULT.length).toEqual(2);
|
|
112
|
-
expect(RESULT[0]).toEqual({
|
|
113
|
-
id: 'page1',
|
|
114
|
-
collection: {
|
|
115
|
-
name: 'collection1'
|
|
116
|
-
},
|
|
117
|
-
title: 'Collection1',
|
|
118
|
-
components: [],
|
|
119
|
-
formData: {}
|
|
120
|
-
});
|
|
121
|
-
expect(RESULT[1]).toEqual({
|
|
122
|
-
id: 'page3',
|
|
123
|
-
collection: {
|
|
124
|
-
name: 'collection2'
|
|
125
|
-
},
|
|
126
|
-
title: 'Collection2',
|
|
127
|
-
components: [],
|
|
128
|
-
formData: {}
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
|
@@ -1,69 +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 _cleanAttributes = _interopRequireWildcard(require("./cleanAttributes"));
|
|
6
|
-
|
|
7
|
-
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); }
|
|
8
|
-
|
|
9
|
-
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; }
|
|
10
|
-
|
|
11
|
-
// Local imports
|
|
12
|
-
describe('utils', function () {
|
|
13
|
-
describe('Component', function () {
|
|
14
|
-
describe('clean', function () {
|
|
15
|
-
it('should handle null options', function () {
|
|
16
|
-
expect((0, _cleanAttributes.default)(null)).toEqual({});
|
|
17
|
-
});
|
|
18
|
-
it('should handle undefined options', function () {
|
|
19
|
-
expect((0, _cleanAttributes.default)(undefined)).toEqual({});
|
|
20
|
-
});
|
|
21
|
-
it('should handle empty options', function () {
|
|
22
|
-
expect((0, _cleanAttributes.default)({}, null)).toEqual({});
|
|
23
|
-
});
|
|
24
|
-
it('should handle a non-object options', function () {
|
|
25
|
-
expect((0, _cleanAttributes.default)(23, null)).toEqual({});
|
|
26
|
-
});
|
|
27
|
-
it('should only remove properties specific to JSON', function () {
|
|
28
|
-
var OPTIONS = {
|
|
29
|
-
id: 'bob'
|
|
30
|
-
}; // Add a bunch of properties we know will need to be removed.
|
|
31
|
-
|
|
32
|
-
_cleanAttributes.JSON_ONLY_PROPERTIES.forEach(function (p) {
|
|
33
|
-
return OPTIONS[p] = 'value';
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
var RESULT = (0, _cleanAttributes.default)(OPTIONS); // The original options should remain untouched.
|
|
37
|
-
|
|
38
|
-
expect(OPTIONS.id).toEqual('bob');
|
|
39
|
-
expect(OPTIONS['source']).toEqual('value'); // But those values should have been removed from the result,
|
|
40
|
-
// which means it should simply have an id of 'bob'.
|
|
41
|
-
|
|
42
|
-
expect(RESULT).toEqual({
|
|
43
|
-
id: 'bob'
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
it('should also remove properties specified in the alsoRemove parameter', function () {
|
|
47
|
-
var OPTIONS = {
|
|
48
|
-
id: 'bob',
|
|
49
|
-
fieldId: 'bobField'
|
|
50
|
-
}; // Add a bunch of properties we know will need to be removed.
|
|
51
|
-
|
|
52
|
-
_cleanAttributes.JSON_ONLY_PROPERTIES.forEach(function (p) {
|
|
53
|
-
return OPTIONS[p] = 'value';
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
var RESULT = (0, _cleanAttributes.default)(OPTIONS, ['fieldId']); // The original options should remain untouched.
|
|
57
|
-
|
|
58
|
-
expect(OPTIONS.id).toEqual('bob');
|
|
59
|
-
expect(OPTIONS.fieldId).toEqual('bobField');
|
|
60
|
-
expect(OPTIONS['source']).toEqual('value'); // But those values should have been removed from the result,
|
|
61
|
-
// which means it should simply have an id of 'bob'.
|
|
62
|
-
|
|
63
|
-
expect(RESULT).toEqual({
|
|
64
|
-
id: 'bob'
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|