@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,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _getFormPages = _interopRequireDefault(require("./getFormPages"));
|
|
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('getFormPages', 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
|
-
}];
|
|
36
|
-
var FORM_DATA = {
|
|
37
|
-
urls: {
|
|
38
|
-
refData: 'https://ho.gov.uk/ref-data/'
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
it('should handle null or undefined pageOptions', function () {
|
|
42
|
-
expect((0, _getFormPages.default)(null, FORM_COMPONENTS, FORM_DATA)).toEqual([]);
|
|
43
|
-
expect((0, _getFormPages.default)(undefined, FORM_COMPONENTS, FORM_DATA)).toEqual([]);
|
|
44
|
-
});
|
|
45
|
-
it('should appropriately set up multiples pages with various configurations', function () {
|
|
46
|
-
var PAGE_1 = {
|
|
47
|
-
title: 'Page 1',
|
|
48
|
-
components: [{
|
|
49
|
-
type: 'heading',
|
|
50
|
-
size: 'l',
|
|
51
|
-
content: 'Page heading'
|
|
52
|
-
}]
|
|
53
|
-
};
|
|
54
|
-
var PAGE_2 = {
|
|
55
|
-
title: 'Page 2',
|
|
56
|
-
components: ["Opening paragraph", {
|
|
57
|
-
type: 'heading',
|
|
58
|
-
size: 'l',
|
|
59
|
-
content: 'Page heading'
|
|
60
|
-
}, "Closing paragraph", {
|
|
61
|
-
use: 'c'
|
|
62
|
-
}]
|
|
63
|
-
};
|
|
64
|
-
var PAGES = [PAGE_1, PAGE_2];
|
|
65
|
-
var C = FORM_COMPONENTS[2];
|
|
66
|
-
expect((0, _getFormPages.default)(PAGES, FORM_COMPONENTS, FORM_DATA)).toEqual([{
|
|
67
|
-
index: 0,
|
|
68
|
-
title: PAGE_1.title,
|
|
69
|
-
components: PAGE_1.components,
|
|
70
|
-
formData: FORM_DATA
|
|
71
|
-
}, {
|
|
72
|
-
index: 1,
|
|
73
|
-
title: PAGE_2.title,
|
|
74
|
-
components: [{
|
|
75
|
-
type: 'html',
|
|
76
|
-
tagName: 'p',
|
|
77
|
-
content: PAGE_2.components[0]
|
|
78
|
-
}, _objectSpread(_objectSpread({}, PAGE_2.components[1]), {}, {
|
|
79
|
-
full_path: PAGE_2.components[1].fieldId
|
|
80
|
-
}), {
|
|
81
|
-
type: 'html',
|
|
82
|
-
tagName: 'p',
|
|
83
|
-
content: PAGE_2.components[2]
|
|
84
|
-
}, _objectSpread(_objectSpread({
|
|
85
|
-
use: 'c'
|
|
86
|
-
}, C), {}, {
|
|
87
|
-
cya_label: C.label,
|
|
88
|
-
data: {
|
|
89
|
-
url: "".concat(FORM_DATA.urls.refData, "/v3/charlies")
|
|
90
|
-
},
|
|
91
|
-
full_path: C.fieldId
|
|
92
|
-
})],
|
|
93
|
-
formData: FORM_DATA
|
|
94
|
-
}]);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _models = require("../../models");
|
|
4
|
-
|
|
5
|
-
var _getPageActions = _interopRequireDefault(require("./getPageActions"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
// Local imports
|
|
10
|
-
describe('utils', function () {
|
|
11
|
-
describe('FormPage', function () {
|
|
12
|
-
describe('getPageActions', function () {
|
|
13
|
-
it('should handle a null or undefined page', function () {
|
|
14
|
-
expect((0, _getPageActions.default)(null)).toBeUndefined();
|
|
15
|
-
expect((0, _getPageActions.default)(undefined)).toBeUndefined();
|
|
16
|
-
});
|
|
17
|
-
it('should handle a null or undefined actions array', function () {
|
|
18
|
-
expect((0, _getPageActions.default)({
|
|
19
|
-
actions: null
|
|
20
|
-
})).toBeUndefined();
|
|
21
|
-
expect((0, _getPageActions.default)({
|
|
22
|
-
actions: undefined
|
|
23
|
-
})).toBeUndefined();
|
|
24
|
-
});
|
|
25
|
-
it('should handle an array of strings', function () {
|
|
26
|
-
var actions = [_models.PageAction.TYPES.SAVE_AND_CONTINUE, _models.PageAction.TYPES.SAVE_AND_RETURN];
|
|
27
|
-
expect((0, _getPageActions.default)({
|
|
28
|
-
actions: actions
|
|
29
|
-
})).toEqual([_models.PageAction.DEFAULTS.saveAndContinue, _models.PageAction.DEFAULTS.saveAndReturn]);
|
|
30
|
-
});
|
|
31
|
-
it('should handle a null entry in the array', function () {
|
|
32
|
-
var actions = [_models.PageAction.TYPES.SAVE_AND_CONTINUE, _models.PageAction.TYPES.SAVE_AND_RETURN, null];
|
|
33
|
-
expect((0, _getPageActions.default)({
|
|
34
|
-
actions: actions
|
|
35
|
-
})).toEqual([_models.PageAction.DEFAULTS.saveAndContinue, _models.PageAction.DEFAULTS.saveAndReturn]);
|
|
36
|
-
});
|
|
37
|
-
it('should handle an undefined entry in the array', function () {
|
|
38
|
-
var actions = [undefined, _models.PageAction.TYPES.SAVE_AND_CONTINUE, undefined, _models.PageAction.TYPES.SAVE_AND_RETURN];
|
|
39
|
-
expect((0, _getPageActions.default)({
|
|
40
|
-
actions: actions
|
|
41
|
-
})).toEqual([_models.PageAction.DEFAULTS.saveAndContinue, _models.PageAction.DEFAULTS.saveAndReturn]);
|
|
42
|
-
});
|
|
43
|
-
it('should handle an object entry in the array', function () {
|
|
44
|
-
var actions = [{
|
|
45
|
-
type: 'navigate',
|
|
46
|
-
page: 'alpha'
|
|
47
|
-
}];
|
|
48
|
-
expect((0, _getPageActions.default)({
|
|
49
|
-
actions: actions
|
|
50
|
-
})).toEqual(actions);
|
|
51
|
-
});
|
|
52
|
-
it('should convert an href to a page', function () {
|
|
53
|
-
var actions = [{
|
|
54
|
-
type: 'navigate',
|
|
55
|
-
href: '/alpha/bravo'
|
|
56
|
-
}];
|
|
57
|
-
expect((0, _getPageActions.default)({
|
|
58
|
-
actions: actions
|
|
59
|
-
})).toEqual([{
|
|
60
|
-
type: 'navigate',
|
|
61
|
-
page: 'bravo',
|
|
62
|
-
href: '/alpha/bravo'
|
|
63
|
-
}]);
|
|
64
|
-
});
|
|
65
|
-
it('should convert a url to a page', function () {
|
|
66
|
-
var actions = [{
|
|
67
|
-
type: 'navigate',
|
|
68
|
-
url: '/alpha/bravo'
|
|
69
|
-
}];
|
|
70
|
-
expect((0, _getPageActions.default)({
|
|
71
|
-
actions: actions
|
|
72
|
-
})).toEqual([{
|
|
73
|
-
type: 'navigate',
|
|
74
|
-
page: 'bravo',
|
|
75
|
-
url: '/alpha/bravo'
|
|
76
|
-
}]);
|
|
77
|
-
});
|
|
78
|
-
it('should handle an action without a page, href, or url', function () {
|
|
79
|
-
var actions = [{
|
|
80
|
-
type: 'submit',
|
|
81
|
-
label: 'Charlie'
|
|
82
|
-
}];
|
|
83
|
-
expect((0, _getPageActions.default)({
|
|
84
|
-
actions: actions
|
|
85
|
-
})).toEqual(actions);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _models = require("../../models");
|
|
4
|
-
|
|
5
|
-
var _getParagraphFromText = _interopRequireDefault(require("./getParagraphFromText"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
// Local imports
|
|
10
|
-
describe('utils', function () {
|
|
11
|
-
describe('FormPage', function () {
|
|
12
|
-
describe('getParagraphFromText', function () {
|
|
13
|
-
it('should handle text content', function () {
|
|
14
|
-
var CONTENT = 'Appropriate text content';
|
|
15
|
-
expect((0, _getParagraphFromText.default)(CONTENT)).toEqual({
|
|
16
|
-
type: _models.ComponentTypes.HTML,
|
|
17
|
-
tagName: 'p',
|
|
18
|
-
content: CONTENT
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
it('should handle undefined content', function () {
|
|
22
|
-
expect((0, _getParagraphFromText.default)(undefined)).toEqual({
|
|
23
|
-
type: _models.ComponentTypes.HTML,
|
|
24
|
-
tagName: 'p'
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _showFormPage = _interopRequireDefault(require("./showFormPage"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
describe('utils', function () {
|
|
8
|
-
describe('FormPage', function () {
|
|
9
|
-
describe('showFormPage', function () {
|
|
10
|
-
var DATA = {
|
|
11
|
-
alpha: 'Alpha',
|
|
12
|
-
bravo: 'Bravo'
|
|
13
|
-
};
|
|
14
|
-
var HTML = {
|
|
15
|
-
type: 'html',
|
|
16
|
-
tagName: 'p',
|
|
17
|
-
content: 'Alpha'
|
|
18
|
-
};
|
|
19
|
-
var INSET_TEXT = {
|
|
20
|
-
type: 'inset-text',
|
|
21
|
-
content: 'Bravo'
|
|
22
|
-
};
|
|
23
|
-
var HEADING = {
|
|
24
|
-
type: 'heading',
|
|
25
|
-
size: 'm',
|
|
26
|
-
content: 'Charlie'
|
|
27
|
-
};
|
|
28
|
-
it('should NOT be shown when the page is null', function () {
|
|
29
|
-
expect((0, _showFormPage.default)(null, DATA)).toBeFalsy();
|
|
30
|
-
});
|
|
31
|
-
it('should NOT be shown when the page has a single show_when condition that is NOT matched', function () {
|
|
32
|
-
var PAGE = {
|
|
33
|
-
show_when: {
|
|
34
|
-
field: 'charlie',
|
|
35
|
-
op: '=',
|
|
36
|
-
value: 'Charlie'
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
expect((0, _showFormPage.default)(PAGE, DATA)).toBeFalsy();
|
|
40
|
-
});
|
|
41
|
-
it('should NOT be shown when the page has a multiple show_when conditions and at least one is NOT matched', function () {
|
|
42
|
-
var PAGE = {
|
|
43
|
-
show_when: [{
|
|
44
|
-
field: 'alpha',
|
|
45
|
-
op: '=',
|
|
46
|
-
value: 'Alpha'
|
|
47
|
-
}, {
|
|
48
|
-
field: 'charlie',
|
|
49
|
-
op: '=',
|
|
50
|
-
value: 'Charlie'
|
|
51
|
-
}]
|
|
52
|
-
};
|
|
53
|
-
expect((0, _showFormPage.default)(PAGE, DATA)).toBeFalsy();
|
|
54
|
-
});
|
|
55
|
-
it('SHOULD be shown when the page has a single show_when condition that IS matched', function () {
|
|
56
|
-
var PAGE = {
|
|
57
|
-
show_when: {
|
|
58
|
-
field: 'alpha',
|
|
59
|
-
op: '=',
|
|
60
|
-
value: 'Alpha'
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
expect((0, _showFormPage.default)(PAGE, DATA)).toBeTruthy();
|
|
64
|
-
});
|
|
65
|
-
it('SHOULD be shown when the page has a multiple show_when conditions that are ALL matched', function () {
|
|
66
|
-
var PAGE = {
|
|
67
|
-
show_when: [{
|
|
68
|
-
field: 'alpha',
|
|
69
|
-
op: '=',
|
|
70
|
-
value: 'Alpha'
|
|
71
|
-
}, {
|
|
72
|
-
field: 'charlie',
|
|
73
|
-
op: '!=',
|
|
74
|
-
value: 'Charlie'
|
|
75
|
-
}]
|
|
76
|
-
};
|
|
77
|
-
expect((0, _showFormPage.default)(PAGE, DATA)).toBeTruthy();
|
|
78
|
-
});
|
|
79
|
-
it('SHOULD be shown when the page has NO show_when conditions and NO editable components', function () {
|
|
80
|
-
var PAGE = {
|
|
81
|
-
components: [HTML, INSET_TEXT, HEADING]
|
|
82
|
-
};
|
|
83
|
-
expect((0, _showFormPage.default)(PAGE, DATA)).toBeTruthy();
|
|
84
|
-
});
|
|
85
|
-
it('should NOT be shown when the page has NO show_when conditions and NO SHOWN editable components', function () {
|
|
86
|
-
var TEXT = {
|
|
87
|
-
type: 'text',
|
|
88
|
-
show_when: {
|
|
89
|
-
field: 'charlie',
|
|
90
|
-
op: '=',
|
|
91
|
-
value: 'Charlie'
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
var RADIOS = {
|
|
95
|
-
type: 'radios',
|
|
96
|
-
show_when: {
|
|
97
|
-
field: 'charlie',
|
|
98
|
-
op: '=',
|
|
99
|
-
value: 'Charlie'
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
var PAGE = {
|
|
103
|
-
components: [TEXT, RADIOS]
|
|
104
|
-
};
|
|
105
|
-
expect((0, _showFormPage.default)(PAGE, DATA)).toBeFalsy();
|
|
106
|
-
});
|
|
107
|
-
it('SHOULD be shown when the page has NO show_when conditions and AT LEAST ONE SHOWN editable components', function () {
|
|
108
|
-
var TEXT = {
|
|
109
|
-
type: 'text',
|
|
110
|
-
show_when: {
|
|
111
|
-
field: 'alpha',
|
|
112
|
-
op: '=',
|
|
113
|
-
value: 'Alpha'
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
var RADIOS = {
|
|
117
|
-
type: 'radios',
|
|
118
|
-
show_when: {
|
|
119
|
-
field: 'charlie',
|
|
120
|
-
op: '=',
|
|
121
|
-
value: 'Charlie'
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
var PAGE = {
|
|
125
|
-
components: [TEXT, RADIOS]
|
|
126
|
-
};
|
|
127
|
-
expect((0, _showFormPage.default)(PAGE, DATA)).toBeTruthy();
|
|
128
|
-
});
|
|
129
|
-
it('SHOULD be shown when the page has multiple show_when conditions, with type "or" provided and ALL are matched', function () {
|
|
130
|
-
var PAGE = {
|
|
131
|
-
show_when: {
|
|
132
|
-
"type": "or",
|
|
133
|
-
"conditions": [{
|
|
134
|
-
field: 'alpha',
|
|
135
|
-
op: '=',
|
|
136
|
-
value: 'Alpha'
|
|
137
|
-
}, {
|
|
138
|
-
field: 'bravo',
|
|
139
|
-
op: '=',
|
|
140
|
-
value: 'Bravo'
|
|
141
|
-
}]
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
expect((0, _showFormPage.default)(PAGE, DATA)).toBeTruthy();
|
|
145
|
-
});
|
|
146
|
-
it('SHOULD be shown when the page has multiple show_when conditions, with type "or" provided and at least ONE is matched', function () {
|
|
147
|
-
var PAGE = {
|
|
148
|
-
show_when: {
|
|
149
|
-
"type": "or",
|
|
150
|
-
"conditions": [{
|
|
151
|
-
field: 'alpha',
|
|
152
|
-
op: '=',
|
|
153
|
-
value: 'Alpha'
|
|
154
|
-
}, {
|
|
155
|
-
field: 'charlie',
|
|
156
|
-
op: '=',
|
|
157
|
-
value: 'Charlie'
|
|
158
|
-
}]
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
expect((0, _showFormPage.default)(PAGE, DATA)).toBeTruthy();
|
|
162
|
-
});
|
|
163
|
-
it('should NOT be shown when the page has multiple show_when conditions, with type "or" provided and NONE are matched', function () {
|
|
164
|
-
var PAGE = {
|
|
165
|
-
show_when: {
|
|
166
|
-
"type": "or",
|
|
167
|
-
"conditions": [{
|
|
168
|
-
field: 'alpha',
|
|
169
|
-
op: '!=',
|
|
170
|
-
value: 'Alpha'
|
|
171
|
-
}, {
|
|
172
|
-
field: 'charlie',
|
|
173
|
-
op: '=',
|
|
174
|
-
value: 'Charlie'
|
|
175
|
-
}]
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
expect((0, _showFormPage.default)(PAGE, DATA)).toBeFalsy();
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _showFormPageCYA = _interopRequireDefault(require("./showFormPageCYA"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
describe('utils.FormPage.showFormPageCYA', function () {
|
|
8
|
-
var DATA = {
|
|
9
|
-
alpha: 'Alpha',
|
|
10
|
-
bravo: 'Bravo'
|
|
11
|
-
};
|
|
12
|
-
it('should NOT be shown when the page is null', function () {
|
|
13
|
-
expect((0, _showFormPageCYA.default)(null, DATA)).toEqual(false);
|
|
14
|
-
});
|
|
15
|
-
it('should NOT be shown if the show_on_cya flag is false', function () {
|
|
16
|
-
var PAGE = {
|
|
17
|
-
show_on_cya: false
|
|
18
|
-
};
|
|
19
|
-
expect((0, _showFormPageCYA.default)(PAGE, DATA)).toEqual(false);
|
|
20
|
-
});
|
|
21
|
-
it('SHOULD be shown if the show_on_cya flag is true', function () {
|
|
22
|
-
var PAGE = {
|
|
23
|
-
show_on_cya: true
|
|
24
|
-
};
|
|
25
|
-
expect((0, _showFormPageCYA.default)(PAGE, DATA)).toEqual(true);
|
|
26
|
-
});
|
|
27
|
-
it('SHOULD be shown if the show_on_cya flag is missing', function () {
|
|
28
|
-
expect((0, _showFormPageCYA.default)({}, DATA)).toEqual(true);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _models = require("../../models");
|
|
4
|
-
|
|
5
|
-
var _useComponent = _interopRequireDefault(require("./useComponent"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
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; }
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
|
|
13
|
-
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; }
|
|
14
|
-
|
|
15
|
-
describe('utils', function () {
|
|
16
|
-
describe('FormPage', function () {
|
|
17
|
-
describe('useComponent', function () {
|
|
18
|
-
var ZULU = {
|
|
19
|
-
id: 'z',
|
|
20
|
-
fieldId: 'z',
|
|
21
|
-
label: 'Zulu',
|
|
22
|
-
type: _models.ComponentTypes.TEXT
|
|
23
|
-
};
|
|
24
|
-
var CONTAINER = {
|
|
25
|
-
id: 'container',
|
|
26
|
-
fieldId: 'container',
|
|
27
|
-
label: 'Container',
|
|
28
|
-
type: _models.ComponentTypes.CONTAINER,
|
|
29
|
-
components: [{
|
|
30
|
-
id: 'f',
|
|
31
|
-
fieldId: 'f',
|
|
32
|
-
label: 'Foxtrot',
|
|
33
|
-
type: _models.ComponentTypes.TEXT
|
|
34
|
-
}, ZULU]
|
|
35
|
-
};
|
|
36
|
-
var FORM_COMPONENTS = [{
|
|
37
|
-
id: 'a',
|
|
38
|
-
fieldId: 'a',
|
|
39
|
-
label: 'Alpha',
|
|
40
|
-
type: _models.ComponentTypes.TEXT
|
|
41
|
-
}, {
|
|
42
|
-
id: 'b',
|
|
43
|
-
fieldId: 'b',
|
|
44
|
-
label: 'Bravo',
|
|
45
|
-
type: _models.ComponentTypes.TEXT
|
|
46
|
-
}, {
|
|
47
|
-
id: 'c',
|
|
48
|
-
fieldId: 'c',
|
|
49
|
-
label: 'Charlie',
|
|
50
|
-
type: _models.ComponentTypes.TEXT
|
|
51
|
-
}, {
|
|
52
|
-
id: 'd',
|
|
53
|
-
fieldId: 'd',
|
|
54
|
-
cya_label: 'Delta',
|
|
55
|
-
type: _models.ComponentTypes.TEXT
|
|
56
|
-
}, CONTAINER];
|
|
57
|
-
it('should handle a null toUse configuration', function () {
|
|
58
|
-
var TO_USE = null;
|
|
59
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual({});
|
|
60
|
-
});
|
|
61
|
-
it('should handle an unrecognised component reference', function () {
|
|
62
|
-
var TO_USE = {
|
|
63
|
-
use: 'e',
|
|
64
|
-
label: 'Echo'
|
|
65
|
-
};
|
|
66
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual(TO_USE);
|
|
67
|
-
});
|
|
68
|
-
it('should use the appropriate component', function () {
|
|
69
|
-
var TO_USE = {
|
|
70
|
-
use: 'a'
|
|
71
|
-
};
|
|
72
|
-
var A = FORM_COMPONENTS[0];
|
|
73
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual(_objectSpread(_objectSpread({
|
|
74
|
-
use: 'a'
|
|
75
|
-
}, A), {}, {
|
|
76
|
-
cya_label: A.label
|
|
77
|
-
}));
|
|
78
|
-
});
|
|
79
|
-
it('should allow the fieldId to be overridden', function () {
|
|
80
|
-
var TO_USE = {
|
|
81
|
-
use: 'a',
|
|
82
|
-
fieldId: 'alpha'
|
|
83
|
-
};
|
|
84
|
-
var A = FORM_COMPONENTS[0];
|
|
85
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual(_objectSpread(_objectSpread({
|
|
86
|
-
use: 'a'
|
|
87
|
-
}, A), {}, {
|
|
88
|
-
cya_label: A.label,
|
|
89
|
-
fieldId: TO_USE.fieldId
|
|
90
|
-
}));
|
|
91
|
-
});
|
|
92
|
-
it('should allow the label to be overridden but keep the cya_label unaffected', function () {
|
|
93
|
-
var TO_USE = {
|
|
94
|
-
use: 'a',
|
|
95
|
-
label: 'Alpha foxtrot'
|
|
96
|
-
};
|
|
97
|
-
var A = FORM_COMPONENTS[0];
|
|
98
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual(_objectSpread(_objectSpread({
|
|
99
|
-
use: 'a'
|
|
100
|
-
}, A), {}, {
|
|
101
|
-
cya_label: A.label,
|
|
102
|
-
label: TO_USE.label
|
|
103
|
-
}));
|
|
104
|
-
});
|
|
105
|
-
it('should allow the form component cya_label, if label is empty', function () {
|
|
106
|
-
var TO_USE = {
|
|
107
|
-
use: 'd',
|
|
108
|
-
label: ''
|
|
109
|
-
};
|
|
110
|
-
var A = FORM_COMPONENTS[3];
|
|
111
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual(_objectSpread(_objectSpread({
|
|
112
|
-
use: 'd'
|
|
113
|
-
}, A), {}, {
|
|
114
|
-
cya_label: A.cya_label,
|
|
115
|
-
label: TO_USE.label
|
|
116
|
-
}));
|
|
117
|
-
});
|
|
118
|
-
it('should allow the form component cya_label, if label is not given', function () {
|
|
119
|
-
var TO_USE = {
|
|
120
|
-
use: 'd'
|
|
121
|
-
};
|
|
122
|
-
var A = FORM_COMPONENTS[3];
|
|
123
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual(_objectSpread(_objectSpread({
|
|
124
|
-
use: 'd'
|
|
125
|
-
}, A), {}, {
|
|
126
|
-
cya_label: A.cya_label,
|
|
127
|
-
label: TO_USE.label
|
|
128
|
-
}));
|
|
129
|
-
});
|
|
130
|
-
it('should handle a container', function () {
|
|
131
|
-
var TO_USE = {
|
|
132
|
-
use: CONTAINER.id
|
|
133
|
-
};
|
|
134
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual(_objectSpread(_objectSpread({
|
|
135
|
-
use: CONTAINER.id
|
|
136
|
-
}, CONTAINER), {}, {
|
|
137
|
-
cya_label: CONTAINER.label
|
|
138
|
-
}));
|
|
139
|
-
});
|
|
140
|
-
it('should handle a component nested inside a container', function () {
|
|
141
|
-
var ID = "".concat(CONTAINER.id, ".").concat(ZULU.id);
|
|
142
|
-
var TO_USE = {
|
|
143
|
-
use: ID
|
|
144
|
-
};
|
|
145
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual(_objectSpread(_objectSpread({
|
|
146
|
-
use: ID
|
|
147
|
-
}, CONTAINER), {}, {
|
|
148
|
-
cya_label: CONTAINER.label,
|
|
149
|
-
components: [ZULU // Foxtrot is not included
|
|
150
|
-
]
|
|
151
|
-
}));
|
|
152
|
-
});
|
|
153
|
-
it('should handle an unrecognised container reference', function () {
|
|
154
|
-
var ID = "unrecognised.".concat(ZULU.id);
|
|
155
|
-
var TO_USE = {
|
|
156
|
-
use: ID
|
|
157
|
-
};
|
|
158
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual(TO_USE);
|
|
159
|
-
});
|
|
160
|
-
it('should handle an unrecognised component within a container', function () {
|
|
161
|
-
var ID = "".concat(CONTAINER.id, ".unrecognised");
|
|
162
|
-
var TO_USE = {
|
|
163
|
-
use: ID
|
|
164
|
-
};
|
|
165
|
-
expect((0, _useComponent.default)(TO_USE, FORM_COMPONENTS)).toEqual(TO_USE);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _formatData = _interopRequireDefault(require("./formatData"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
// Local imports
|
|
8
|
-
describe('utils', function () {
|
|
9
|
-
describe('Format', function () {
|
|
10
|
-
describe('formatData', function () {
|
|
11
|
-
it('should handle no format', function () {
|
|
12
|
-
var FORMAT = null;
|
|
13
|
-
var VALUE = 'AlPhA';
|
|
14
|
-
expect((0, _formatData.default)(FORMAT, VALUE)).toEqual(VALUE);
|
|
15
|
-
});
|
|
16
|
-
it('should handle no value', function () {
|
|
17
|
-
var FORMAT = {
|
|
18
|
-
type: 'lowercase'
|
|
19
|
-
};
|
|
20
|
-
var VALUE = null;
|
|
21
|
-
expect((0, _formatData.default)(FORMAT, VALUE)).toBeNull();
|
|
22
|
-
});
|
|
23
|
-
it('should format a string as lowercase', function () {
|
|
24
|
-
var FORMAT = {
|
|
25
|
-
type: 'lowercase'
|
|
26
|
-
};
|
|
27
|
-
var VALUE = 'AlPhA';
|
|
28
|
-
expect((0, _formatData.default)(FORMAT, VALUE)).toEqual('alpha');
|
|
29
|
-
});
|
|
30
|
-
it('should format a string as uppercase', function () {
|
|
31
|
-
var FORMAT = {
|
|
32
|
-
type: 'uppercase'
|
|
33
|
-
};
|
|
34
|
-
var VALUE = 'AlPhA';
|
|
35
|
-
expect((0, _formatData.default)(FORMAT, VALUE)).toEqual('ALPHA');
|
|
36
|
-
});
|
|
37
|
-
it('should leave an unknown format type alone', function () {
|
|
38
|
-
var FORMAT = {
|
|
39
|
-
type: 'not-a-real-type'
|
|
40
|
-
};
|
|
41
|
-
var VALUE = 'AlPhA';
|
|
42
|
-
expect((0, _formatData.default)(FORMAT, VALUE)).toEqual(VALUE);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|