@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,276 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _setupFormData = _interopRequireDefault(require("./setupFormData"));
|
|
4
|
-
|
|
5
|
-
var _userProfile = _interopRequireDefault(require("../../json/userProfile.json"));
|
|
6
|
-
|
|
7
|
-
var _userProfileData = _interopRequireDefault(require("../../json/userProfile.data.json"));
|
|
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('Data', function () {
|
|
19
|
-
describe('setupFormData', function () {
|
|
20
|
-
it('should populate a simple form', function () {
|
|
21
|
-
var PAGES = [];
|
|
22
|
-
var COMPONENTS = [{
|
|
23
|
-
fieldId: 'testField',
|
|
24
|
-
source: {
|
|
25
|
-
field: 'sourceField'
|
|
26
|
-
}
|
|
27
|
-
}];
|
|
28
|
-
var DATA = {
|
|
29
|
-
sourceField: 'VALUE'
|
|
30
|
-
};
|
|
31
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
32
|
-
expect(RESULT).toEqual({
|
|
33
|
-
sourceField: 'VALUE',
|
|
34
|
-
testField: 'VALUE'
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
it('should handle a missing source field', function () {
|
|
38
|
-
var PAGES = [];
|
|
39
|
-
var COMPONENTS = [{
|
|
40
|
-
fieldId: 'testField',
|
|
41
|
-
source: {
|
|
42
|
-
field: 'otherSourceField'
|
|
43
|
-
}
|
|
44
|
-
}];
|
|
45
|
-
var DATA = {
|
|
46
|
-
sourceField: 'VALUE'
|
|
47
|
-
};
|
|
48
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
49
|
-
expect(RESULT).toEqual({
|
|
50
|
-
sourceField: 'VALUE',
|
|
51
|
-
testField: undefined
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
it('should handle a nested source field', function () {
|
|
55
|
-
var PAGES = [];
|
|
56
|
-
var COMPONENTS = [{
|
|
57
|
-
fieldId: 'testField',
|
|
58
|
-
source: {
|
|
59
|
-
field: 'nested.sourceField'
|
|
60
|
-
}
|
|
61
|
-
}];
|
|
62
|
-
var DATA = {
|
|
63
|
-
nested: {
|
|
64
|
-
sourceField: 'VALUE'
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
68
|
-
expect(RESULT).toEqual({
|
|
69
|
-
nested: {
|
|
70
|
-
sourceField: 'VALUE'
|
|
71
|
-
},
|
|
72
|
-
testField: 'VALUE'
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
it('should handle a missing nested source field', function () {
|
|
76
|
-
var PAGES = [];
|
|
77
|
-
var COMPONENTS = [{
|
|
78
|
-
fieldId: 'testField',
|
|
79
|
-
source: {
|
|
80
|
-
field: 'nested.otherSourceField'
|
|
81
|
-
}
|
|
82
|
-
}];
|
|
83
|
-
var DATA = {
|
|
84
|
-
nested: {
|
|
85
|
-
sourceField: 'VALUE'
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
89
|
-
expect(RESULT).toEqual({
|
|
90
|
-
nested: {
|
|
91
|
-
sourceField: 'VALUE'
|
|
92
|
-
},
|
|
93
|
-
testField: undefined
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
it('should handle an entirely missing nested source field', function () {
|
|
97
|
-
var PAGES = [];
|
|
98
|
-
var COMPONENTS = [{
|
|
99
|
-
fieldId: 'testField',
|
|
100
|
-
source: {
|
|
101
|
-
field: 'otherNested.sourceField'
|
|
102
|
-
}
|
|
103
|
-
}];
|
|
104
|
-
var DATA = {
|
|
105
|
-
nested: {
|
|
106
|
-
sourceField: 'VALUE'
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
110
|
-
expect(RESULT).toEqual({
|
|
111
|
-
nested: {
|
|
112
|
-
sourceField: 'VALUE'
|
|
113
|
-
},
|
|
114
|
-
testField: undefined
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
it('should handle sources within pages', function () {
|
|
118
|
-
var PAGES = [{
|
|
119
|
-
components: [{
|
|
120
|
-
fieldId: 'pageField',
|
|
121
|
-
source: {
|
|
122
|
-
field: 'pageSourceField'
|
|
123
|
-
}
|
|
124
|
-
}]
|
|
125
|
-
}, {
|
|
126
|
-
components: [{
|
|
127
|
-
fieldId: 'secondPageField',
|
|
128
|
-
source: {
|
|
129
|
-
field: 'secondPageSourceField'
|
|
130
|
-
}
|
|
131
|
-
}]
|
|
132
|
-
}];
|
|
133
|
-
var COMPONENTS = [{
|
|
134
|
-
fieldId: 'testField',
|
|
135
|
-
source: {
|
|
136
|
-
field: 'nested.sourceField'
|
|
137
|
-
}
|
|
138
|
-
}];
|
|
139
|
-
var DATA = {
|
|
140
|
-
nested: {
|
|
141
|
-
sourceField: 'VALUE'
|
|
142
|
-
},
|
|
143
|
-
pageSourceField: 'PAGE 1',
|
|
144
|
-
secondPageSourceField: 'Bob'
|
|
145
|
-
};
|
|
146
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
147
|
-
expect(RESULT).toEqual({
|
|
148
|
-
nested: {
|
|
149
|
-
sourceField: 'VALUE'
|
|
150
|
-
},
|
|
151
|
-
pageSourceField: 'PAGE 1',
|
|
152
|
-
secondPageSourceField: 'Bob',
|
|
153
|
-
testField: 'VALUE',
|
|
154
|
-
pageField: 'PAGE 1',
|
|
155
|
-
secondPageField: 'Bob'
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
it('should ignore sources within pages that reference a top-level component', function () {
|
|
159
|
-
var PAGES = [{
|
|
160
|
-
components: [{
|
|
161
|
-
fieldId: 'pageField',
|
|
162
|
-
use: 'testField',
|
|
163
|
-
source: {
|
|
164
|
-
field: 'pageSourceField'
|
|
165
|
-
}
|
|
166
|
-
}]
|
|
167
|
-
}, {
|
|
168
|
-
components: [{
|
|
169
|
-
fieldId: 'secondPageField',
|
|
170
|
-
source: {
|
|
171
|
-
field: 'secondPageSourceField'
|
|
172
|
-
}
|
|
173
|
-
}]
|
|
174
|
-
}];
|
|
175
|
-
var COMPONENTS = [{
|
|
176
|
-
fieldId: 'testField',
|
|
177
|
-
source: {
|
|
178
|
-
field: 'nested.sourceField'
|
|
179
|
-
}
|
|
180
|
-
}];
|
|
181
|
-
var DATA = {
|
|
182
|
-
nested: {
|
|
183
|
-
sourceField: 'VALUE'
|
|
184
|
-
},
|
|
185
|
-
pageSourceField: 'PAGE 1',
|
|
186
|
-
secondPageSourceField: 'Bob'
|
|
187
|
-
};
|
|
188
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
189
|
-
expect(RESULT).toEqual({
|
|
190
|
-
nested: {
|
|
191
|
-
sourceField: 'VALUE'
|
|
192
|
-
},
|
|
193
|
-
pageSourceField: 'PAGE 1',
|
|
194
|
-
secondPageSourceField: 'Bob',
|
|
195
|
-
testField: 'VALUE',
|
|
196
|
-
secondPageField: 'Bob'
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
it('should populate data for the user profile configuration and source', function () {
|
|
200
|
-
var pages = _userProfile.default.pages,
|
|
201
|
-
components = _userProfile.default.components;
|
|
202
|
-
var RESULT = (0, _setupFormData.default)(pages, components, _userProfileData.default); // It should produce an aggregation of the original source data (USER_PROFILE_DATA)
|
|
203
|
-
// and data calculated for the fields, based on that source data.
|
|
204
|
-
|
|
205
|
-
expect(RESULT).toEqual(_objectSpread(_objectSpread({}, _userProfileData.default), {}, {
|
|
206
|
-
firstName: _userProfileData.default.currentUser.givenName,
|
|
207
|
-
surname: _userProfileData.default.currentUser.familyName,
|
|
208
|
-
team: _userProfileData.default.userDetails.defaultteam,
|
|
209
|
-
staffGradeId: _userProfileData.default.userDetails.gradeid,
|
|
210
|
-
linemanagerEmail: _userProfileData.default.userDetails.linemanagerEmail,
|
|
211
|
-
delegateEmails: _userProfileData.default.userDetails.delegateEmails
|
|
212
|
-
}));
|
|
213
|
-
});
|
|
214
|
-
it('should handle a default value field', function () {
|
|
215
|
-
var PAGES = [];
|
|
216
|
-
var COMPONENTS = [{
|
|
217
|
-
fieldId: 'testField',
|
|
218
|
-
type: 'text',
|
|
219
|
-
defaultValue: 'VALUE'
|
|
220
|
-
}];
|
|
221
|
-
var DATA = {};
|
|
222
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
223
|
-
expect(RESULT).toEqual({
|
|
224
|
-
testField: 'VALUE'
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
it('should ignore a default value when a value already exists in data', function () {
|
|
228
|
-
var PAGES = [];
|
|
229
|
-
var COMPONENTS = [{
|
|
230
|
-
fieldId: 'testField',
|
|
231
|
-
type: 'text',
|
|
232
|
-
defaultValue: 'VALUE'
|
|
233
|
-
}];
|
|
234
|
-
var DATA = {
|
|
235
|
-
testField: 'EXISTING_VALUE'
|
|
236
|
-
};
|
|
237
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
238
|
-
expect(RESULT).toEqual({
|
|
239
|
-
testField: 'EXISTING_VALUE'
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
it('should handle default values within pages', function () {
|
|
243
|
-
var PAGES = [{
|
|
244
|
-
components: [{
|
|
245
|
-
fieldId: 'pageField',
|
|
246
|
-
type: 'text',
|
|
247
|
-
defaultValue: 'VALUE'
|
|
248
|
-
}]
|
|
249
|
-
}];
|
|
250
|
-
var COMPONENTS = [];
|
|
251
|
-
var DATA = {};
|
|
252
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
253
|
-
expect(RESULT).toEqual({
|
|
254
|
-
pageField: 'VALUE'
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
it('should ignore default values within pages when a value already exists in data', function () {
|
|
258
|
-
var PAGES = [{
|
|
259
|
-
components: [{
|
|
260
|
-
fieldId: 'pageField',
|
|
261
|
-
type: 'text',
|
|
262
|
-
defaultValue: 'VALUE'
|
|
263
|
-
}]
|
|
264
|
-
}];
|
|
265
|
-
var COMPONENTS = [];
|
|
266
|
-
var DATA = {
|
|
267
|
-
pageField: 'EXISTING_VALUE'
|
|
268
|
-
};
|
|
269
|
-
var RESULT = (0, _setupFormData.default)(PAGES, COMPONENTS, DATA);
|
|
270
|
-
expect(RESULT).toEqual({
|
|
271
|
-
pageField: 'EXISTING_VALUE'
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
});
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _models = require("../../models");
|
|
4
|
-
|
|
5
|
-
var _setupRefDataUrlForComponent = _interopRequireDefault(require("./setupRefDataUrlForComponent"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
// Local imports
|
|
10
|
-
describe('utils', function () {
|
|
11
|
-
describe('Data', function () {
|
|
12
|
-
describe('setupRefDataUrlForComponent', function () {
|
|
13
|
-
var DATA = {
|
|
14
|
-
urls: {
|
|
15
|
-
refData: '/ref-data'
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
it('can handle a null component', function () {
|
|
19
|
-
expect((0, _setupRefDataUrlForComponent.default)(null, DATA)).toBeNull();
|
|
20
|
-
});
|
|
21
|
-
it('can handle an undefined component', function () {
|
|
22
|
-
expect((0, _setupRefDataUrlForComponent.default)(undefined, DATA)).toBeUndefined();
|
|
23
|
-
});
|
|
24
|
-
it('can handle a component with no data property', function () {
|
|
25
|
-
var COMPONENT = {
|
|
26
|
-
id: 'component'
|
|
27
|
-
};
|
|
28
|
-
expect((0, _setupRefDataUrlForComponent.default)(COMPONENT, DATA)).toEqual(COMPONENT);
|
|
29
|
-
});
|
|
30
|
-
it('can handle a component with no data.url property', function () {
|
|
31
|
-
var COMPONENT = {
|
|
32
|
-
id: 'component',
|
|
33
|
-
data: {
|
|
34
|
-
options: []
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
expect((0, _setupRefDataUrlForComponent.default)(COMPONENT, DATA)).toEqual(COMPONENT);
|
|
38
|
-
});
|
|
39
|
-
it('should appropriately update the component URL', function () {
|
|
40
|
-
var COMPONENT = {
|
|
41
|
-
id: 'component',
|
|
42
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
43
|
-
data: {
|
|
44
|
-
url: '${urls.refData}/v1/teams'
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
expect((0, _setupRefDataUrlForComponent.default)(COMPONENT, DATA)).toEqual({
|
|
48
|
-
id: COMPONENT.id,
|
|
49
|
-
data: {
|
|
50
|
-
url: "".concat(DATA.urls.refData, "/v1/teams")
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
it('should leave a URL alone that does not require replacement', function () {
|
|
55
|
-
var COMPONENT = {
|
|
56
|
-
id: 'component',
|
|
57
|
-
data: {
|
|
58
|
-
url: '/somewhere-else/v1/teams'
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
expect((0, _setupRefDataUrlForComponent.default)(COMPONENT, DATA)).toEqual({
|
|
62
|
-
id: COMPONENT.id,
|
|
63
|
-
data: {
|
|
64
|
-
url: COMPONENT.data.url
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
it('should appropriately handle a missing value in the data', function () {
|
|
69
|
-
var COMPONENT = {
|
|
70
|
-
id: 'component',
|
|
71
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
72
|
-
data: {
|
|
73
|
-
url: '${urls.referenceData}/v1/teams'
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
expect((0, _setupRefDataUrlForComponent.default)(COMPONENT, DATA)).toEqual({
|
|
77
|
-
id: COMPONENT.id,
|
|
78
|
-
data: {
|
|
79
|
-
url: '/v1/teams'
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
it('should appropriately update the component URLs within a container', function () {
|
|
84
|
-
var COMPONENT = {
|
|
85
|
-
id: 'component',
|
|
86
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
87
|
-
data: {
|
|
88
|
-
url: '${urls.refData}/v1/teams'
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
var CONTAINER = {
|
|
92
|
-
id: 'container',
|
|
93
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
94
|
-
components: [COMPONENT]
|
|
95
|
-
};
|
|
96
|
-
expect((0, _setupRefDataUrlForComponent.default)(CONTAINER, DATA)).toEqual({
|
|
97
|
-
id: CONTAINER.id,
|
|
98
|
-
type: CONTAINER.type,
|
|
99
|
-
components: [{
|
|
100
|
-
id: COMPONENT.id,
|
|
101
|
-
data: {
|
|
102
|
-
url: "".concat(DATA.urls.refData, "/v1/teams")
|
|
103
|
-
}
|
|
104
|
-
}]
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
it('should appropriately update the component URLs within a collection', function () {
|
|
108
|
-
var COMPONENT = {
|
|
109
|
-
id: 'component',
|
|
110
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
111
|
-
data: {
|
|
112
|
-
url: '${urls.refData}/v1/teams'
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
var COLLECTION = {
|
|
116
|
-
id: 'container',
|
|
117
|
-
type: _models.ComponentTypes.COLLECTION,
|
|
118
|
-
item: [COMPONENT]
|
|
119
|
-
};
|
|
120
|
-
expect((0, _setupRefDataUrlForComponent.default)(COLLECTION, DATA)).toEqual({
|
|
121
|
-
id: COLLECTION.id,
|
|
122
|
-
type: COLLECTION.type,
|
|
123
|
-
item: [{
|
|
124
|
-
id: COMPONENT.id,
|
|
125
|
-
data: {
|
|
126
|
-
url: "".concat(DATA.urls.refData, "/v1/teams")
|
|
127
|
-
}
|
|
128
|
-
}]
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
});
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _getFormPage = _interopRequireDefault(require("./getFormPage"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
|
|
11
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
|
|
13
|
-
describe('utils', function () {
|
|
14
|
-
describe('FormPage', function () {
|
|
15
|
-
describe('getFormPage', function () {
|
|
16
|
-
var FORM_COMPONENTS = [{
|
|
17
|
-
id: 'a',
|
|
18
|
-
fieldId: 'a',
|
|
19
|
-
label: 'Alpha',
|
|
20
|
-
type: 'text'
|
|
21
|
-
}, {
|
|
22
|
-
id: 'b',
|
|
23
|
-
fieldId: 'b',
|
|
24
|
-
label: 'Bravo',
|
|
25
|
-
type: 'text'
|
|
26
|
-
}, // eslint-disable-next-line no-template-curly-in-string
|
|
27
|
-
{
|
|
28
|
-
id: 'c',
|
|
29
|
-
fieldId: 'c',
|
|
30
|
-
label: 'Charlie',
|
|
31
|
-
type: 'radios',
|
|
32
|
-
data: {
|
|
33
|
-
url: '${urls.refData}/v3/charlies'
|
|
34
|
-
}
|
|
35
|
-
}, // eslint-disable-next-line no-template-curly-in-string
|
|
36
|
-
{
|
|
37
|
-
id: 'd',
|
|
38
|
-
fieldId: 'd',
|
|
39
|
-
label: 'Roger ${currentUser.firstname}',
|
|
40
|
-
type: 'text'
|
|
41
|
-
}, // eslint-disable-next-line no-template-curly-in-string
|
|
42
|
-
{
|
|
43
|
-
id: 'e',
|
|
44
|
-
fieldId: 'e',
|
|
45
|
-
label: 'Bravo ${currentUser.surname}',
|
|
46
|
-
type: 'text'
|
|
47
|
-
}];
|
|
48
|
-
var FORM_DATA = {
|
|
49
|
-
urls: {
|
|
50
|
-
refData: 'https://ho.gov.uk/ref-data/'
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
it('should handle null or undefined pageOptions', function () {
|
|
54
|
-
expect((0, _getFormPage.default)(null, FORM_COMPONENTS, FORM_DATA)).toBeNull();
|
|
55
|
-
expect((0, _getFormPage.default)(undefined, FORM_COMPONENTS, FORM_DATA)).toBeNull();
|
|
56
|
-
});
|
|
57
|
-
it('should handle a page not using any form components', function () {
|
|
58
|
-
var PAGE = {
|
|
59
|
-
title: 'Page',
|
|
60
|
-
components: [{
|
|
61
|
-
type: 'heading',
|
|
62
|
-
size: 'l',
|
|
63
|
-
content: 'Page heading'
|
|
64
|
-
}]
|
|
65
|
-
};
|
|
66
|
-
expect((0, _getFormPage.default)(PAGE, FORM_COMPONENTS, FORM_DATA)).toEqual({
|
|
67
|
-
title: PAGE.title,
|
|
68
|
-
components: PAGE.components,
|
|
69
|
-
formData: FORM_DATA
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
it('should handle a page with inline strings and convert them to paragraphs', function () {
|
|
73
|
-
var PAGE = {
|
|
74
|
-
title: 'Page',
|
|
75
|
-
components: ["Opening paragraph", {
|
|
76
|
-
type: 'heading',
|
|
77
|
-
size: 'l',
|
|
78
|
-
content: 'Page heading'
|
|
79
|
-
}, "Closing paragraph"]
|
|
80
|
-
};
|
|
81
|
-
expect((0, _getFormPage.default)(PAGE, FORM_COMPONENTS, FORM_DATA)).toEqual({
|
|
82
|
-
title: PAGE.title,
|
|
83
|
-
components: [{
|
|
84
|
-
type: 'html',
|
|
85
|
-
tagName: 'p',
|
|
86
|
-
content: PAGE.components[0]
|
|
87
|
-
}, _objectSpread(_objectSpread({}, PAGE.components[1]), {}, {
|
|
88
|
-
full_path: PAGE.components[1].fieldId
|
|
89
|
-
}), {
|
|
90
|
-
type: 'html',
|
|
91
|
-
tagName: 'p',
|
|
92
|
-
content: PAGE.components[2]
|
|
93
|
-
}],
|
|
94
|
-
formData: FORM_DATA
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
it('should handle a page that references a form-level component', function () {
|
|
98
|
-
var PAGE = {
|
|
99
|
-
title: 'Page',
|
|
100
|
-
components: ["Opening paragraph", {
|
|
101
|
-
type: 'heading',
|
|
102
|
-
size: 'l',
|
|
103
|
-
content: 'Page heading'
|
|
104
|
-
}, "Closing paragraph", {
|
|
105
|
-
use: 'a'
|
|
106
|
-
}]
|
|
107
|
-
};
|
|
108
|
-
var A = FORM_COMPONENTS[0];
|
|
109
|
-
expect((0, _getFormPage.default)(PAGE, FORM_COMPONENTS, FORM_DATA)).toEqual({
|
|
110
|
-
title: PAGE.title,
|
|
111
|
-
components: [{
|
|
112
|
-
type: 'html',
|
|
113
|
-
tagName: 'p',
|
|
114
|
-
content: PAGE.components[0]
|
|
115
|
-
}, _objectSpread(_objectSpread({}, PAGE.components[1]), {}, {
|
|
116
|
-
full_path: PAGE.components[1].fieldId
|
|
117
|
-
}), {
|
|
118
|
-
type: 'html',
|
|
119
|
-
tagName: 'p',
|
|
120
|
-
content: PAGE.components[2]
|
|
121
|
-
}, _objectSpread(_objectSpread({
|
|
122
|
-
use: 'a'
|
|
123
|
-
}, A), {}, {
|
|
124
|
-
cya_label: A.label,
|
|
125
|
-
full_path: A.fieldId
|
|
126
|
-
})],
|
|
127
|
-
formData: FORM_DATA
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
it('should handle a page that references a form-level component with a data url', function () {
|
|
131
|
-
var PAGE = {
|
|
132
|
-
title: 'Page',
|
|
133
|
-
components: ["Opening paragraph", {
|
|
134
|
-
type: 'heading',
|
|
135
|
-
size: 'l',
|
|
136
|
-
content: 'Page heading'
|
|
137
|
-
}, "Closing paragraph", {
|
|
138
|
-
use: 'c'
|
|
139
|
-
}]
|
|
140
|
-
};
|
|
141
|
-
var C = FORM_COMPONENTS[2];
|
|
142
|
-
expect((0, _getFormPage.default)(PAGE, FORM_COMPONENTS, FORM_DATA)).toEqual({
|
|
143
|
-
title: PAGE.title,
|
|
144
|
-
components: [{
|
|
145
|
-
type: 'html',
|
|
146
|
-
tagName: 'p',
|
|
147
|
-
content: PAGE.components[0]
|
|
148
|
-
}, _objectSpread(_objectSpread({}, PAGE.components[1]), {}, {
|
|
149
|
-
full_path: PAGE.components[1].fieldId
|
|
150
|
-
}), {
|
|
151
|
-
type: 'html',
|
|
152
|
-
tagName: 'p',
|
|
153
|
-
content: PAGE.components[2]
|
|
154
|
-
}, _objectSpread(_objectSpread({
|
|
155
|
-
use: 'c'
|
|
156
|
-
}, C), {}, {
|
|
157
|
-
cya_label: C.label,
|
|
158
|
-
data: {
|
|
159
|
-
url: "".concat(FORM_DATA.urls.refData, "/v3/charlies")
|
|
160
|
-
},
|
|
161
|
-
full_path: C.fieldId
|
|
162
|
-
})],
|
|
163
|
-
formData: FORM_DATA
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
it('should handle a page that references a form-level component with a data url without an environment context', function () {
|
|
167
|
-
var PAGE = {
|
|
168
|
-
title: 'Page',
|
|
169
|
-
components: ["Opening paragraph", {
|
|
170
|
-
type: 'heading',
|
|
171
|
-
size: 'l',
|
|
172
|
-
content: 'Page heading'
|
|
173
|
-
}, "Closing paragraph", {
|
|
174
|
-
use: 'c'
|
|
175
|
-
}]
|
|
176
|
-
};
|
|
177
|
-
var C = FORM_COMPONENTS[2];
|
|
178
|
-
expect((0, _getFormPage.default)(PAGE, FORM_COMPONENTS, {})).toEqual({
|
|
179
|
-
title: PAGE.title,
|
|
180
|
-
components: [{
|
|
181
|
-
type: 'html',
|
|
182
|
-
tagName: 'p',
|
|
183
|
-
content: PAGE.components[0]
|
|
184
|
-
}, _objectSpread(_objectSpread({}, PAGE.components[1]), {}, {
|
|
185
|
-
full_path: PAGE.components[1].fieldId
|
|
186
|
-
}), {
|
|
187
|
-
type: 'html',
|
|
188
|
-
tagName: 'p',
|
|
189
|
-
content: PAGE.components[2]
|
|
190
|
-
}, // eslint-disable-next-line no-template-curly-in-string
|
|
191
|
-
_objectSpread(_objectSpread({
|
|
192
|
-
use: 'c'
|
|
193
|
-
}, C), {}, {
|
|
194
|
-
cya_label: C.label,
|
|
195
|
-
full_path: C.fieldId,
|
|
196
|
-
data: {
|
|
197
|
-
url: '/v3/charlies'
|
|
198
|
-
}
|
|
199
|
-
})],
|
|
200
|
-
formData: {}
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
});
|