@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,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _elevateNestedComponents = _interopRequireDefault(require("./elevateNestedComponents"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
describe('utils.Component.elevateNestedComponents', function () {
|
|
8
|
-
it('should return an empty array if components is undefined', function () {
|
|
9
|
-
var DATA = {
|
|
10
|
-
alpha: 'abc'
|
|
11
|
-
};
|
|
12
|
-
expect((0, _elevateNestedComponents.default)(undefined, DATA)).toEqual([]);
|
|
13
|
-
});
|
|
14
|
-
it('should return an empty array if components is null', function () {
|
|
15
|
-
var DATA = {
|
|
16
|
-
alpha: 'abc'
|
|
17
|
-
};
|
|
18
|
-
expect((0, _elevateNestedComponents.default)(null, DATA)).toEqual([]);
|
|
19
|
-
});
|
|
20
|
-
it('should return an empty array if components is empty', function () {
|
|
21
|
-
var DATA = {
|
|
22
|
-
alpha: 'abc'
|
|
23
|
-
};
|
|
24
|
-
expect((0, _elevateNestedComponents.default)([], DATA)).toEqual([]);
|
|
25
|
-
});
|
|
26
|
-
it('should return the original components if none have nested components', function () {
|
|
27
|
-
var COMPONENTS = [{
|
|
28
|
-
id: 'textComp'
|
|
29
|
-
}, {
|
|
30
|
-
id: 'radiosComp',
|
|
31
|
-
data: {
|
|
32
|
-
options: [{
|
|
33
|
-
label: 'Yes',
|
|
34
|
-
value: 'yes'
|
|
35
|
-
}, {
|
|
36
|
-
label: 'No',
|
|
37
|
-
value: 'no'
|
|
38
|
-
}]
|
|
39
|
-
}
|
|
40
|
-
}];
|
|
41
|
-
var DATA = {
|
|
42
|
-
alpha: 'abc'
|
|
43
|
-
};
|
|
44
|
-
expect((0, _elevateNestedComponents.default)(COMPONENTS, DATA)).toEqual(COMPONENTS);
|
|
45
|
-
});
|
|
46
|
-
it('should return the original components if data is null', function () {
|
|
47
|
-
var COMPONENTS = [{
|
|
48
|
-
id: 'textComp'
|
|
49
|
-
}, {
|
|
50
|
-
id: 'radiosComp',
|
|
51
|
-
data: {
|
|
52
|
-
options: [{
|
|
53
|
-
label: 'Yes',
|
|
54
|
-
value: 'yes'
|
|
55
|
-
}, {
|
|
56
|
-
label: 'No',
|
|
57
|
-
value: 'no'
|
|
58
|
-
}]
|
|
59
|
-
}
|
|
60
|
-
}];
|
|
61
|
-
expect((0, _elevateNestedComponents.default)(COMPONENTS, null)).toEqual(COMPONENTS);
|
|
62
|
-
});
|
|
63
|
-
it('should return the original array with elevated nested components when they are visible', function () {
|
|
64
|
-
var COMPONENTS = [{
|
|
65
|
-
id: 'textComp'
|
|
66
|
-
}, {
|
|
67
|
-
id: 'radiosComp',
|
|
68
|
-
data: {
|
|
69
|
-
options: [{
|
|
70
|
-
label: 'Yes',
|
|
71
|
-
value: 'yes',
|
|
72
|
-
nested: [{
|
|
73
|
-
id: 'nestedOne'
|
|
74
|
-
}, {
|
|
75
|
-
id: 'nestedTwo'
|
|
76
|
-
}]
|
|
77
|
-
}, {
|
|
78
|
-
label: 'No',
|
|
79
|
-
value: 'no'
|
|
80
|
-
}]
|
|
81
|
-
}
|
|
82
|
-
}];
|
|
83
|
-
var DATA = {
|
|
84
|
-
radiosComp: 'yes'
|
|
85
|
-
};
|
|
86
|
-
expect((0, _elevateNestedComponents.default)(COMPONENTS, DATA)).toEqual([].concat(COMPONENTS, [{
|
|
87
|
-
id: 'nestedOne'
|
|
88
|
-
}, {
|
|
89
|
-
id: 'nestedTwo'
|
|
90
|
-
}]));
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _models = require("../../models");
|
|
4
|
-
|
|
5
|
-
var _getDefaultValue = _interopRequireDefault(require("./getDefaultValue"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
describe('utils.Component.defaultValue', function () {
|
|
10
|
-
it('should return an empty string if the component is undefined', function () {
|
|
11
|
-
expect((0, _getDefaultValue.default)(undefined)).toEqual('');
|
|
12
|
-
});
|
|
13
|
-
it('should return an empty string if the component is null', function () {
|
|
14
|
-
expect((0, _getDefaultValue.default)(null)).toEqual('');
|
|
15
|
-
});
|
|
16
|
-
it('should return an empty string if the component has no type', function () {
|
|
17
|
-
expect((0, _getDefaultValue.default)({})).toEqual('');
|
|
18
|
-
});
|
|
19
|
-
it('should return an empty string if the component type is null', function () {
|
|
20
|
-
expect((0, _getDefaultValue.default)({
|
|
21
|
-
type: null
|
|
22
|
-
})).toEqual('');
|
|
23
|
-
});
|
|
24
|
-
it('should return an empty string if the component type is undefined', function () {
|
|
25
|
-
expect((0, _getDefaultValue.default)({
|
|
26
|
-
type: undefined
|
|
27
|
-
})).toEqual('');
|
|
28
|
-
});
|
|
29
|
-
it("should return an empty array if the component type is 'collection'", function () {
|
|
30
|
-
expect((0, _getDefaultValue.default)({
|
|
31
|
-
type: _models.ComponentTypes.COLLECTION
|
|
32
|
-
})).toEqual([]);
|
|
33
|
-
});
|
|
34
|
-
it("should return an empty object if the component type is 'container'", function () {
|
|
35
|
-
expect((0, _getDefaultValue.default)({
|
|
36
|
-
type: _models.ComponentTypes.CONTAINER
|
|
37
|
-
})).toEqual({});
|
|
38
|
-
});
|
|
39
|
-
it("should return an empty object if the component type is 'file'", function () {
|
|
40
|
-
expect((0, _getDefaultValue.default)({
|
|
41
|
-
type: _models.ComponentTypes.FILE
|
|
42
|
-
})).toEqual({});
|
|
43
|
-
});
|
|
44
|
-
Object.values(_models.ComponentTypes).forEach(function (value) {
|
|
45
|
-
if (![_models.ComponentTypes.COLLECTION, _models.ComponentTypes.CONTAINER, _models.ComponentTypes.FILE].includes(value)) {
|
|
46
|
-
it("should return an empty object if the component type is '".concat(value, "'"), function () {
|
|
47
|
-
expect((0, _getDefaultValue.default)({
|
|
48
|
-
type: _models.ComponentTypes.TEXT
|
|
49
|
-
})).toEqual('');
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,42 +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 _isEditable = _interopRequireWildcard(require("./isEditable"));
|
|
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('isEditable', function () {
|
|
15
|
-
_isEditable.EDITABLE_TYPES.forEach(function (type) {
|
|
16
|
-
it("should return true for a type of '".concat(type, "'"), function () {
|
|
17
|
-
var OPTIONS = {
|
|
18
|
-
type: type
|
|
19
|
-
};
|
|
20
|
-
expect((0, _isEditable.default)(OPTIONS)).toEqual(true);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should return false if options is undefined', function () {
|
|
25
|
-
expect((0, _isEditable.default)(undefined)).toEqual(false);
|
|
26
|
-
});
|
|
27
|
-
it('should return false if options is null', function () {
|
|
28
|
-
expect((0, _isEditable.default)(null)).toEqual(false);
|
|
29
|
-
});
|
|
30
|
-
it('should return false if options has no type', function () {
|
|
31
|
-
expect((0, _isEditable.default)({
|
|
32
|
-
bob: 'Bob'
|
|
33
|
-
})).toEqual(false);
|
|
34
|
-
});
|
|
35
|
-
it("should return false if options has a type of 'hidden'", function () {
|
|
36
|
-
expect((0, _isEditable.default)({
|
|
37
|
-
type: 'hidden'
|
|
38
|
-
})).toEqual(false);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _showComponent = _interopRequireDefault(require("./showComponent"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
// Local imports
|
|
8
|
-
describe('utils', function () {
|
|
9
|
-
describe('Component', function () {
|
|
10
|
-
describe('show', function () {
|
|
11
|
-
it('should not show when there are no options', function () {
|
|
12
|
-
expect((0, _showComponent.default)(null, null)).toBeFalsy();
|
|
13
|
-
});
|
|
14
|
-
it('should not show when hidden and disabled', function () {
|
|
15
|
-
expect((0, _showComponent.default)({
|
|
16
|
-
hidden: true,
|
|
17
|
-
disabled: true
|
|
18
|
-
}, null)).toBeFalsy();
|
|
19
|
-
});
|
|
20
|
-
it('should show when hidden but not disabled', function () {
|
|
21
|
-
expect((0, _showComponent.default)({
|
|
22
|
-
hidden: true
|
|
23
|
-
}, null)).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
it('should show when disabled but not hidden', function () {
|
|
26
|
-
expect((0, _showComponent.default)({
|
|
27
|
-
disabled: true
|
|
28
|
-
}, null)).toBeTruthy();
|
|
29
|
-
});
|
|
30
|
-
it('should show when a single show_when condition is met', function () {
|
|
31
|
-
var COMPONENT = {
|
|
32
|
-
show_when: {
|
|
33
|
-
field: 'alpha',
|
|
34
|
-
op: 'eq',
|
|
35
|
-
value: 'bravo'
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var DATA = {
|
|
39
|
-
alpha: 'bravo'
|
|
40
|
-
};
|
|
41
|
-
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
|
|
42
|
-
});
|
|
43
|
-
it('should not show when a single show_when condition is not met', function () {
|
|
44
|
-
var COMPONENT = {
|
|
45
|
-
show_when: {
|
|
46
|
-
field: 'alpha',
|
|
47
|
-
op: 'eq',
|
|
48
|
-
value: 'bravo'
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
var DATA = {
|
|
52
|
-
alpha: 'charlie'
|
|
53
|
-
};
|
|
54
|
-
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeFalsy();
|
|
55
|
-
});
|
|
56
|
-
it('should show when multiple show_when conditions are met', function () {
|
|
57
|
-
var COMPONENT = {
|
|
58
|
-
show_when: [{
|
|
59
|
-
field: 'alpha',
|
|
60
|
-
op: 'eq',
|
|
61
|
-
value: 'bravo'
|
|
62
|
-
}, {
|
|
63
|
-
field: 'charlie',
|
|
64
|
-
op: 'eq',
|
|
65
|
-
value: 'delta'
|
|
66
|
-
}]
|
|
67
|
-
};
|
|
68
|
-
var DATA = {
|
|
69
|
-
alpha: 'bravo',
|
|
70
|
-
charlie: 'delta'
|
|
71
|
-
};
|
|
72
|
-
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
|
|
73
|
-
});
|
|
74
|
-
it('should not show when one of multiple show_when conditions is not met', function () {
|
|
75
|
-
var COMPONENT = {
|
|
76
|
-
show_when: [{
|
|
77
|
-
field: 'alpha',
|
|
78
|
-
op: 'eq',
|
|
79
|
-
value: 'bravo'
|
|
80
|
-
}, {
|
|
81
|
-
field: 'charlie',
|
|
82
|
-
op: 'eq',
|
|
83
|
-
value: 'delta'
|
|
84
|
-
}]
|
|
85
|
-
};
|
|
86
|
-
var DATA = {
|
|
87
|
-
alpha: 'bravo',
|
|
88
|
-
charlie: 'echo'
|
|
89
|
-
};
|
|
90
|
-
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeFalsy();
|
|
91
|
-
});
|
|
92
|
-
it('SHOULD be shown when the component has multiple show_when conditions, with type "or" provided and ALL are matched', function () {
|
|
93
|
-
var COMPONENT = {
|
|
94
|
-
show_when: {
|
|
95
|
-
"type": "or",
|
|
96
|
-
"conditions": [{
|
|
97
|
-
field: 'alpha',
|
|
98
|
-
op: '=',
|
|
99
|
-
value: 'Alpha'
|
|
100
|
-
}, {
|
|
101
|
-
field: 'bravo',
|
|
102
|
-
op: '=',
|
|
103
|
-
value: 'Bravo'
|
|
104
|
-
}]
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
var DATA = {
|
|
108
|
-
alpha: 'Alpha',
|
|
109
|
-
bravo: 'Bravo'
|
|
110
|
-
};
|
|
111
|
-
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
|
|
112
|
-
});
|
|
113
|
-
it('SHOULD be shown when the component has multiple show_when conditions, with type "or" provided and at least ONE is matched', function () {
|
|
114
|
-
var COMPONENT = {
|
|
115
|
-
show_when: {
|
|
116
|
-
"type": "or",
|
|
117
|
-
"conditions": [{
|
|
118
|
-
field: 'alpha',
|
|
119
|
-
op: '=',
|
|
120
|
-
value: 'Alpha'
|
|
121
|
-
}, {
|
|
122
|
-
field: 'charlie',
|
|
123
|
-
op: '=',
|
|
124
|
-
value: 'Charlie'
|
|
125
|
-
}]
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
var DATA = {
|
|
129
|
-
alpha: 'Alpha',
|
|
130
|
-
bravo: 'Bravo'
|
|
131
|
-
};
|
|
132
|
-
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
|
|
133
|
-
});
|
|
134
|
-
it('should NOT be shown when the component has multiple show_when conditions, with type "or" provided and NONE are matched', function () {
|
|
135
|
-
var COMPONENT = {
|
|
136
|
-
show_when: {
|
|
137
|
-
"type": "or",
|
|
138
|
-
"conditions": [{
|
|
139
|
-
field: 'alpha',
|
|
140
|
-
op: '!=',
|
|
141
|
-
value: 'Alpha'
|
|
142
|
-
}, {
|
|
143
|
-
field: 'charlie',
|
|
144
|
-
op: '=',
|
|
145
|
-
value: 'Charlie'
|
|
146
|
-
}]
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
var DATA = {
|
|
150
|
-
alpha: 'Alpha',
|
|
151
|
-
bravo: 'Bravo'
|
|
152
|
-
};
|
|
153
|
-
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeFalsy();
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _meetsAllConditions = _interopRequireDefault(require("./meetsAllConditions"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
// Local imports
|
|
8
|
-
describe('utils.Condition.meetsAllConditions', function () {
|
|
9
|
-
var DATA = {
|
|
10
|
-
alpha: 'bravo',
|
|
11
|
-
charlie: 'delta'
|
|
12
|
-
};
|
|
13
|
-
it('should evaluate to true when conditions are null', function () {
|
|
14
|
-
expect((0, _meetsAllConditions.default)(null, DATA)).toBeTruthy();
|
|
15
|
-
});
|
|
16
|
-
it('should evaluate to true when conditions are undefined', function () {
|
|
17
|
-
expect((0, _meetsAllConditions.default)(undefined, DATA)).toBeTruthy();
|
|
18
|
-
});
|
|
19
|
-
it('should evaluate to true when conditions is an empty array', function () {
|
|
20
|
-
expect((0, _meetsAllConditions.default)([], DATA)).toBeTruthy();
|
|
21
|
-
});
|
|
22
|
-
it('should evaluate to true when a single condition is met', function () {
|
|
23
|
-
var CONDITION = {
|
|
24
|
-
field: 'alpha',
|
|
25
|
-
op: 'eq',
|
|
26
|
-
value: 'bravo'
|
|
27
|
-
};
|
|
28
|
-
expect((0, _meetsAllConditions.default)(CONDITION, DATA)).toBeTruthy();
|
|
29
|
-
});
|
|
30
|
-
it('should evaluate to false when a single condition is not met', function () {
|
|
31
|
-
var CONDITION = {
|
|
32
|
-
field: 'alpha',
|
|
33
|
-
op: 'ne',
|
|
34
|
-
value: 'bravo'
|
|
35
|
-
};
|
|
36
|
-
expect((0, _meetsAllConditions.default)(CONDITION, DATA)).toBeFalsy();
|
|
37
|
-
});
|
|
38
|
-
it('should evaluate to true when all conditions are met', function () {
|
|
39
|
-
var CONDITIONS = [{
|
|
40
|
-
field: 'alpha',
|
|
41
|
-
op: 'eq',
|
|
42
|
-
value: 'bravo'
|
|
43
|
-
}, {
|
|
44
|
-
field: 'charlie',
|
|
45
|
-
op: 'eq',
|
|
46
|
-
value: 'delta'
|
|
47
|
-
}];
|
|
48
|
-
expect((0, _meetsAllConditions.default)(CONDITIONS, DATA)).toBeTruthy();
|
|
49
|
-
});
|
|
50
|
-
it('should evaluate to false when one of the conditions is not met', function () {
|
|
51
|
-
var CONDITIONS = [{
|
|
52
|
-
field: 'alpha',
|
|
53
|
-
op: 'eq',
|
|
54
|
-
value: 'bravo'
|
|
55
|
-
}, {
|
|
56
|
-
field: 'charlie',
|
|
57
|
-
op: 'eq',
|
|
58
|
-
value: 'echo'
|
|
59
|
-
}];
|
|
60
|
-
expect((0, _meetsAllConditions.default)(CONDITIONS, DATA)).toBeFalsy();
|
|
61
|
-
});
|
|
62
|
-
});
|