@ukhomeoffice/cop-react-form-renderer 4.17.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,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _getDataPath = _interopRequireDefault(require("./getDataPath"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
describe('utils.Data.getDataPath', function () {
|
|
8
|
-
var CURRENT_PATH = 'this.is.the.current.path';
|
|
9
|
-
var RELATIVE = 'relative.path';
|
|
10
|
-
var ABSOLUTE = 'absolute.path';
|
|
11
|
-
|
|
12
|
-
var doTest = function doTest(path, currentPath, expected) {
|
|
13
|
-
expect((0, _getDataPath.default)(path, currentPath)).toEqual(expected);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
it("should return an absolute path appropriately", function () {
|
|
17
|
-
doTest(ABSOLUTE, CURRENT_PATH, ABSOLUTE);
|
|
18
|
-
});
|
|
19
|
-
it("should return an absolute path appropriately where the current path is null", function () {
|
|
20
|
-
doTest(ABSOLUTE, null, ABSOLUTE);
|
|
21
|
-
});
|
|
22
|
-
[{
|
|
23
|
-
p: "./".concat(RELATIVE),
|
|
24
|
-
e: "this.is.the.current.".concat(RELATIVE),
|
|
25
|
-
d: 'a sibling node'
|
|
26
|
-
}, {
|
|
27
|
-
p: "../".concat(RELATIVE),
|
|
28
|
-
e: "this.is.the.".concat(RELATIVE),
|
|
29
|
-
d: 'a cousin node'
|
|
30
|
-
}, {
|
|
31
|
-
p: "./../".concat(RELATIVE),
|
|
32
|
-
e: "this.is.the.".concat(RELATIVE),
|
|
33
|
-
d: 'a cousin node with leading dot-slash'
|
|
34
|
-
}, {
|
|
35
|
-
p: "../../../../../../../".concat(RELATIVE),
|
|
36
|
-
e: RELATIVE,
|
|
37
|
-
d: 'an inappropriately nested node'
|
|
38
|
-
}].forEach(function (test) {
|
|
39
|
-
it("should return ".concat(test.d, " appropriately"), function () {
|
|
40
|
-
doTest(test.p, CURRENT_PATH, test.e);
|
|
41
|
-
});
|
|
42
|
-
it("should return ".concat(test.d, " appropriately where the current path is null"), function () {
|
|
43
|
-
doTest(test.p, null, RELATIVE);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
it('should handle a null path and return null', function () {
|
|
47
|
-
doTest(null, CURRENT_PATH, null);
|
|
48
|
-
});
|
|
49
|
-
it('should handle an undefined path and return undefined', function () {
|
|
50
|
-
doTest(undefined, CURRENT_PATH, undefined);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _getOptions = _interopRequireDefault(require("./getOptions"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
// Local imports
|
|
8
|
-
describe('utils', function () {
|
|
9
|
-
describe('Data', function () {
|
|
10
|
-
describe('getOptions', function () {
|
|
11
|
-
it('should handle a null config', function () {
|
|
12
|
-
(0, _getOptions.default)(null, function (options) {
|
|
13
|
-
expect(options).toEqual([]);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
it('should get any specified options from the config', function () {
|
|
17
|
-
var CONFIG = {
|
|
18
|
-
options: [{
|
|
19
|
-
value: 'a',
|
|
20
|
-
label: 'Alpha'
|
|
21
|
-
}, {
|
|
22
|
-
value: 'b',
|
|
23
|
-
label: 'Bravo'
|
|
24
|
-
}]
|
|
25
|
-
};
|
|
26
|
-
(0, _getOptions.default)(CONFIG, function (options) {
|
|
27
|
-
expect(options).toEqual(CONFIG.options);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
it('should get any specified options from the data property of the config', function () {
|
|
31
|
-
var CONFIG = {
|
|
32
|
-
data: {
|
|
33
|
-
options: [{
|
|
34
|
-
value: 'a',
|
|
35
|
-
label: 'Alpha'
|
|
36
|
-
}, {
|
|
37
|
-
value: 'b',
|
|
38
|
-
label: 'Bravo'
|
|
39
|
-
}]
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
(0, _getOptions.default)(CONFIG, function (options) {
|
|
43
|
-
expect(options).toEqual(CONFIG.data.options);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
it('should use the top-level options over those in the data property', function () {
|
|
47
|
-
var CONFIG = {
|
|
48
|
-
options: [{
|
|
49
|
-
value: 'a',
|
|
50
|
-
label: 'Alpha'
|
|
51
|
-
}, {
|
|
52
|
-
value: 'b',
|
|
53
|
-
label: 'Bravo'
|
|
54
|
-
}],
|
|
55
|
-
data: {
|
|
56
|
-
options: [{
|
|
57
|
-
value: 'c',
|
|
58
|
-
label: 'Charlie'
|
|
59
|
-
}, {
|
|
60
|
-
value: 'd',
|
|
61
|
-
label: 'Delta'
|
|
62
|
-
}]
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
(0, _getOptions.default)(CONFIG, function (options) {
|
|
66
|
-
expect(options).toEqual(CONFIG.options);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _getSourceData = _interopRequireDefault(require("./getSourceData"));
|
|
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', function () {
|
|
10
|
-
describe('Data', function () {
|
|
11
|
-
describe('getSourceData', function () {
|
|
12
|
-
it('should return the value at the top level', function () {
|
|
13
|
-
var FIELD_ID = 'field';
|
|
14
|
-
var VALUE = 'value';
|
|
15
|
-
|
|
16
|
-
var DATA = _defineProperty({}, FIELD_ID, VALUE);
|
|
17
|
-
|
|
18
|
-
var value = (0, _getSourceData.default)(DATA, FIELD_ID);
|
|
19
|
-
expect(value).toEqual(VALUE);
|
|
20
|
-
});
|
|
21
|
-
it('should return a nested value', function () {
|
|
22
|
-
var FIELD_ID = 'field.nested';
|
|
23
|
-
var VALUE = 'nested value';
|
|
24
|
-
var DATA = {
|
|
25
|
-
field: {
|
|
26
|
-
nested: VALUE
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var value = (0, _getSourceData.default)(DATA, FIELD_ID);
|
|
30
|
-
expect(value).toEqual(VALUE);
|
|
31
|
-
});
|
|
32
|
-
it('should return a deeply nested value', function () {
|
|
33
|
-
var FIELD_ID = 'field.nested.and.even.further.down';
|
|
34
|
-
var VALUE = 'deeply nested value';
|
|
35
|
-
var DATA = {
|
|
36
|
-
field: {
|
|
37
|
-
nested: {
|
|
38
|
-
and: {
|
|
39
|
-
even: {
|
|
40
|
-
further: {
|
|
41
|
-
down: VALUE
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var value = (0, _getSourceData.default)(DATA, FIELD_ID);
|
|
49
|
-
expect(value).toEqual(VALUE);
|
|
50
|
-
});
|
|
51
|
-
it('should handle null data', function () {
|
|
52
|
-
var FIELD_ID = 'field.nested';
|
|
53
|
-
var value = (0, _getSourceData.default)(null, FIELD_ID);
|
|
54
|
-
expect(value).toBeUndefined();
|
|
55
|
-
});
|
|
56
|
-
it('should handle undefined data', function () {
|
|
57
|
-
var FIELD_ID = 'field.nested';
|
|
58
|
-
var value = (0, _getSourceData.default)(undefined, FIELD_ID);
|
|
59
|
-
expect(value).toBeUndefined();
|
|
60
|
-
});
|
|
61
|
-
it('should handle missing value', function () {
|
|
62
|
-
var FIELD_ID = 'field.nested';
|
|
63
|
-
var VALUE = 'other value';
|
|
64
|
-
var DATA = {
|
|
65
|
-
field: {
|
|
66
|
-
other: VALUE
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var value = (0, _getSourceData.default)(DATA, FIELD_ID);
|
|
70
|
-
expect(value).toBeUndefined();
|
|
71
|
-
});
|
|
72
|
-
it('should handle null fieldId', function () {
|
|
73
|
-
var VALUE = 'value';
|
|
74
|
-
var DATA = {
|
|
75
|
-
field: VALUE
|
|
76
|
-
};
|
|
77
|
-
var value = (0, _getSourceData.default)(DATA, null);
|
|
78
|
-
expect(value).toBeUndefined();
|
|
79
|
-
});
|
|
80
|
-
it('should handle undefined fieldId', function () {
|
|
81
|
-
var VALUE = 'value';
|
|
82
|
-
var DATA = {
|
|
83
|
-
field: VALUE
|
|
84
|
-
};
|
|
85
|
-
var value = (0, _getSourceData.default)(DATA, undefined);
|
|
86
|
-
expect(value).toBeUndefined();
|
|
87
|
-
});
|
|
88
|
-
it('should handle empty fieldId', function () {
|
|
89
|
-
var VALUE = 'value';
|
|
90
|
-
var DATA = {
|
|
91
|
-
field: VALUE
|
|
92
|
-
};
|
|
93
|
-
var value = (0, _getSourceData.default)(DATA, '');
|
|
94
|
-
expect(value).toBeUndefined();
|
|
95
|
-
});
|
|
96
|
-
it('should handle fieldId with trailing dot', function () {
|
|
97
|
-
var FIELD_ID = 'field.';
|
|
98
|
-
var VALUE = 'value';
|
|
99
|
-
var DATA = {
|
|
100
|
-
field: VALUE
|
|
101
|
-
};
|
|
102
|
-
var value = (0, _getSourceData.default)(DATA, FIELD_ID);
|
|
103
|
-
expect(value).toBeUndefined();
|
|
104
|
-
});
|
|
105
|
-
it('should handle fieldId with leading dot', function () {
|
|
106
|
-
var FIELD_ID = '.field';
|
|
107
|
-
var VALUE = 'value';
|
|
108
|
-
var DATA = {
|
|
109
|
-
field: VALUE
|
|
110
|
-
};
|
|
111
|
-
var value = (0, _getSourceData.default)(DATA, FIELD_ID);
|
|
112
|
-
expect(value).toBeUndefined();
|
|
113
|
-
});
|
|
114
|
-
it('should handle fieldId that is just a dot', function () {
|
|
115
|
-
var FIELD_ID = '.';
|
|
116
|
-
var VALUE = 'value';
|
|
117
|
-
var DATA = {
|
|
118
|
-
field: VALUE
|
|
119
|
-
};
|
|
120
|
-
var value = (0, _getSourceData.default)(DATA, FIELD_ID);
|
|
121
|
-
expect(value).toBeUndefined();
|
|
122
|
-
});
|
|
123
|
-
it('should handle a reference to an array item', function () {
|
|
124
|
-
var FIELD_ID = 'items[1]';
|
|
125
|
-
var ALPHA = 'alpha';
|
|
126
|
-
var BETA = 'beta';
|
|
127
|
-
var DATA = {
|
|
128
|
-
items: [ALPHA, BETA]
|
|
129
|
-
};
|
|
130
|
-
var value = (0, _getSourceData.default)(DATA, FIELD_ID);
|
|
131
|
-
expect(value).toEqual(BETA);
|
|
132
|
-
});
|
|
133
|
-
it('should handle a reference to an array that does not exist', function () {
|
|
134
|
-
var FIELD_ID = 'items[1]';
|
|
135
|
-
var DATA = {};
|
|
136
|
-
var value = (0, _getSourceData.default)(DATA, FIELD_ID);
|
|
137
|
-
expect(value).toBeUndefined();
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
});
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _refDataToOptions = _interopRequireDefault(require("./refDataToOptions"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
// Local imports
|
|
8
|
-
describe('utils', function () {
|
|
9
|
-
describe('Data', function () {
|
|
10
|
-
describe('refDataToOptions', function () {
|
|
11
|
-
it('can handle a null refData', function () {
|
|
12
|
-
expect((0, _refDataToOptions.default)(null)).toEqual([]);
|
|
13
|
-
});
|
|
14
|
-
it('can handle an undefined refData', function () {
|
|
15
|
-
expect((0, _refDataToOptions.default)(undefined)).toEqual([]);
|
|
16
|
-
});
|
|
17
|
-
it('can handle genuine refData', function () {
|
|
18
|
-
var REF_DATA = [{
|
|
19
|
-
id: 'a',
|
|
20
|
-
name: 'Alpha'
|
|
21
|
-
}, {
|
|
22
|
-
id: 'b',
|
|
23
|
-
name: 'Bravo'
|
|
24
|
-
}, {
|
|
25
|
-
id: 'c',
|
|
26
|
-
name: 'Charlie'
|
|
27
|
-
}];
|
|
28
|
-
expect((0, _refDataToOptions.default)(REF_DATA)).toEqual([{
|
|
29
|
-
id: 'a',
|
|
30
|
-
name: 'Alpha',
|
|
31
|
-
value: 'a',
|
|
32
|
-
label: 'Alpha'
|
|
33
|
-
}, {
|
|
34
|
-
id: 'b',
|
|
35
|
-
name: 'Bravo',
|
|
36
|
-
value: 'b',
|
|
37
|
-
label: 'Bravo'
|
|
38
|
-
}, {
|
|
39
|
-
id: 'c',
|
|
40
|
-
name: 'Charlie',
|
|
41
|
-
value: 'c',
|
|
42
|
-
label: 'Charlie'
|
|
43
|
-
}]);
|
|
44
|
-
});
|
|
45
|
-
it('can handle refData that is already in a usable options format', function () {
|
|
46
|
-
var REF_DATA = [{
|
|
47
|
-
value: 'a',
|
|
48
|
-
label: 'Alpha'
|
|
49
|
-
}, {
|
|
50
|
-
value: 'b',
|
|
51
|
-
label: 'Bravo'
|
|
52
|
-
}, {
|
|
53
|
-
value: 'c',
|
|
54
|
-
label: 'Charlie'
|
|
55
|
-
}];
|
|
56
|
-
expect((0, _refDataToOptions.default)(REF_DATA)).toEqual([{
|
|
57
|
-
value: 'a',
|
|
58
|
-
label: 'Alpha'
|
|
59
|
-
}, {
|
|
60
|
-
value: 'b',
|
|
61
|
-
label: 'Bravo'
|
|
62
|
-
}, {
|
|
63
|
-
value: 'c',
|
|
64
|
-
label: 'Charlie'
|
|
65
|
-
}]);
|
|
66
|
-
});
|
|
67
|
-
it('can handle refData that is in a mixed format', function () {
|
|
68
|
-
var REF_DATA = [{
|
|
69
|
-
id: 'a',
|
|
70
|
-
name: 'Alpha',
|
|
71
|
-
type: 'Delta'
|
|
72
|
-
}, {
|
|
73
|
-
value: 'b',
|
|
74
|
-
label: 'Bravo'
|
|
75
|
-
}, {
|
|
76
|
-
id: 'c',
|
|
77
|
-
name: 'Charlie',
|
|
78
|
-
type: 'Delta'
|
|
79
|
-
}];
|
|
80
|
-
expect((0, _refDataToOptions.default)(REF_DATA)).toEqual([{
|
|
81
|
-
id: 'a',
|
|
82
|
-
name: 'Alpha',
|
|
83
|
-
value: 'a',
|
|
84
|
-
label: 'Alpha',
|
|
85
|
-
type: 'Delta'
|
|
86
|
-
}, {
|
|
87
|
-
value: 'b',
|
|
88
|
-
label: 'Bravo'
|
|
89
|
-
}, {
|
|
90
|
-
id: 'c',
|
|
91
|
-
name: 'Charlie',
|
|
92
|
-
value: 'c',
|
|
93
|
-
label: 'Charlie',
|
|
94
|
-
type: 'Delta'
|
|
95
|
-
}]);
|
|
96
|
-
});
|
|
97
|
-
it('can handle refData that contains strings and objects', function () {
|
|
98
|
-
var REF_DATA = [{
|
|
99
|
-
id: 'a',
|
|
100
|
-
name: 'Alpha',
|
|
101
|
-
type: 'Delta'
|
|
102
|
-
}, {
|
|
103
|
-
value: 'b',
|
|
104
|
-
label: 'Bravo'
|
|
105
|
-
}, 'Charlie', {
|
|
106
|
-
id: 'd',
|
|
107
|
-
name: 'Delta',
|
|
108
|
-
type: 'Delta'
|
|
109
|
-
}];
|
|
110
|
-
expect((0, _refDataToOptions.default)(REF_DATA)).toEqual([{
|
|
111
|
-
id: 'a',
|
|
112
|
-
name: 'Alpha',
|
|
113
|
-
value: 'a',
|
|
114
|
-
label: 'Alpha',
|
|
115
|
-
type: 'Delta'
|
|
116
|
-
}, {
|
|
117
|
-
value: 'b',
|
|
118
|
-
label: 'Bravo'
|
|
119
|
-
}, 'Charlie', {
|
|
120
|
-
id: 'd',
|
|
121
|
-
name: 'Delta',
|
|
122
|
-
value: 'd',
|
|
123
|
-
label: 'Delta',
|
|
124
|
-
type: 'Delta'
|
|
125
|
-
}]);
|
|
126
|
-
});
|
|
127
|
-
it('can handle refData with custom value and label properties', function () {
|
|
128
|
-
var REF_DATA = [{
|
|
129
|
-
id: 1,
|
|
130
|
-
displayName: 'Alpha'
|
|
131
|
-
}, {
|
|
132
|
-
id: 2,
|
|
133
|
-
displayName: 'Bravo'
|
|
134
|
-
}, {
|
|
135
|
-
id: 3,
|
|
136
|
-
displayName: 'Charlie'
|
|
137
|
-
}];
|
|
138
|
-
var ITEM_STRUCTURE = {
|
|
139
|
-
value: 'id',
|
|
140
|
-
label: 'displayName'
|
|
141
|
-
};
|
|
142
|
-
expect((0, _refDataToOptions.default)(REF_DATA, ITEM_STRUCTURE)).toEqual([{
|
|
143
|
-
id: 1,
|
|
144
|
-
displayName: 'Alpha',
|
|
145
|
-
value: '1',
|
|
146
|
-
label: 'Alpha'
|
|
147
|
-
}, {
|
|
148
|
-
id: 2,
|
|
149
|
-
displayName: 'Bravo',
|
|
150
|
-
value: '2',
|
|
151
|
-
label: 'Bravo'
|
|
152
|
-
}, {
|
|
153
|
-
id: 3,
|
|
154
|
-
displayName: 'Charlie',
|
|
155
|
-
value: '3',
|
|
156
|
-
label: 'Charlie'
|
|
157
|
-
}]);
|
|
158
|
-
});
|
|
159
|
-
it('can handle refData with missing custom value and label properties', function () {
|
|
160
|
-
var REF_DATA = [{
|
|
161
|
-
id: 1,
|
|
162
|
-
name: 'Alpha'
|
|
163
|
-
}, {
|
|
164
|
-
id: 2,
|
|
165
|
-
name: 'Bravo',
|
|
166
|
-
displayName: 'Bravo Zulu'
|
|
167
|
-
}, {
|
|
168
|
-
id: 3,
|
|
169
|
-
objId: 'chaz',
|
|
170
|
-
name: 'Charlie'
|
|
171
|
-
}];
|
|
172
|
-
var ITEM_STRUCTURE = {
|
|
173
|
-
value: 'objId',
|
|
174
|
-
label: 'displayName'
|
|
175
|
-
};
|
|
176
|
-
expect((0, _refDataToOptions.default)(REF_DATA, ITEM_STRUCTURE)).toEqual([{
|
|
177
|
-
id: 1,
|
|
178
|
-
name: 'Alpha',
|
|
179
|
-
value: '1',
|
|
180
|
-
label: 'Alpha'
|
|
181
|
-
}, {
|
|
182
|
-
id: 2,
|
|
183
|
-
name: 'Bravo',
|
|
184
|
-
displayName: 'Bravo Zulu',
|
|
185
|
-
value: '2',
|
|
186
|
-
label: 'Bravo Zulu'
|
|
187
|
-
}, {
|
|
188
|
-
id: 3,
|
|
189
|
-
objId: 'chaz',
|
|
190
|
-
name: 'Charlie',
|
|
191
|
-
value: 'chaz',
|
|
192
|
-
label: 'Charlie'
|
|
193
|
-
}]);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
});
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _setDataItem = _interopRequireDefault(require("./setDataItem"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
describe('utils.Data.setDataItem', function () {
|
|
8
|
-
it('should handle a null data object', function () {
|
|
9
|
-
var DATA = null;
|
|
10
|
-
var FIELD_ID = 'alpha.bravo.charlie';
|
|
11
|
-
var VALUE = 'delta';
|
|
12
|
-
expect((0, _setDataItem.default)(DATA, FIELD_ID, VALUE)).toBeNull();
|
|
13
|
-
expect(DATA).toBeNull();
|
|
14
|
-
});
|
|
15
|
-
it('should handle an undefined data object', function () {
|
|
16
|
-
var DATA = undefined;
|
|
17
|
-
var FIELD_ID = 'alpha.bravo.charlie';
|
|
18
|
-
var VALUE = 'delta';
|
|
19
|
-
expect((0, _setDataItem.default)(DATA, FIELD_ID, VALUE)).toBeUndefined();
|
|
20
|
-
expect(DATA).toBeUndefined();
|
|
21
|
-
});
|
|
22
|
-
it('should handle a null fieldId', function () {
|
|
23
|
-
var DATA = {};
|
|
24
|
-
var FIELD_ID = null;
|
|
25
|
-
var VALUE = 'delta';
|
|
26
|
-
expect((0, _setDataItem.default)(DATA, FIELD_ID, VALUE)).toMatchObject({});
|
|
27
|
-
expect(DATA).toMatchObject({});
|
|
28
|
-
});
|
|
29
|
-
it('should handle an undefined fieldId', function () {
|
|
30
|
-
var DATA = {};
|
|
31
|
-
var FIELD_ID = undefined;
|
|
32
|
-
var VALUE = 'delta';
|
|
33
|
-
expect((0, _setDataItem.default)(DATA, FIELD_ID, VALUE)).toMatchObject({});
|
|
34
|
-
expect(DATA).toMatchObject({});
|
|
35
|
-
});
|
|
36
|
-
it('should handle an empty fieldId', function () {
|
|
37
|
-
var DATA = {};
|
|
38
|
-
var FIELD_ID = '';
|
|
39
|
-
var VALUE = 'delta';
|
|
40
|
-
expect((0, _setDataItem.default)(DATA, FIELD_ID, VALUE)).toMatchObject({});
|
|
41
|
-
expect(DATA).toMatchObject({});
|
|
42
|
-
});
|
|
43
|
-
it('should appropriately set a nested value', function () {
|
|
44
|
-
var DATA = {
|
|
45
|
-
alpha: {}
|
|
46
|
-
};
|
|
47
|
-
var FIELD_ID = 'alpha.bravo.charlie';
|
|
48
|
-
var VALUE = 'delta';
|
|
49
|
-
expect((0, _setDataItem.default)(DATA, FIELD_ID, VALUE)).toMatchObject({
|
|
50
|
-
alpha: {
|
|
51
|
-
bravo: {
|
|
52
|
-
charlie: VALUE
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
expect(DATA).toMatchObject({
|
|
57
|
-
alpha: {
|
|
58
|
-
bravo: {
|
|
59
|
-
charlie: VALUE
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
it('should appropriately change a nested value', function () {
|
|
65
|
-
var DATA = {
|
|
66
|
-
alpha: {
|
|
67
|
-
bravo: {
|
|
68
|
-
charlie: 'echo'
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var FIELD_ID = 'alpha.bravo.charlie';
|
|
73
|
-
var VALUE = 'delta';
|
|
74
|
-
expect((0, _setDataItem.default)(DATA, FIELD_ID, VALUE)).toMatchObject({
|
|
75
|
-
alpha: {
|
|
76
|
-
bravo: {
|
|
77
|
-
charlie: VALUE
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
expect(DATA).toMatchObject({
|
|
82
|
-
alpha: {
|
|
83
|
-
bravo: {
|
|
84
|
-
charlie: VALUE
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
it('should handle a parent node that is not an object and convert it appropriately', function () {
|
|
90
|
-
var DATA = {
|
|
91
|
-
alpha: {
|
|
92
|
-
bravo: 'echo'
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var FIELD_ID = 'alpha.bravo.charlie';
|
|
96
|
-
var VALUE = 'delta';
|
|
97
|
-
expect((0, _setDataItem.default)(DATA, FIELD_ID, VALUE)).toMatchObject({
|
|
98
|
-
alpha: {
|
|
99
|
-
bravo: {
|
|
100
|
-
charlie: VALUE
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
expect(DATA).toMatchObject({
|
|
105
|
-
alpha: {
|
|
106
|
-
bravo: {
|
|
107
|
-
charlie: VALUE
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|