@ukhomeoffice/cop-react-form-renderer 5.14.2 → 5.14.4
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 +15 -15
- package/dist/components/CheckYourAnswers/Answer.test.js +94 -128
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +99 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +291 -501
- package/dist/components/CheckYourAnswers/index.js +2 -3
- package/dist/components/CollectionPage/CollectionPage.js +64 -58
- package/dist/components/CollectionPage/CollectionPage.test.js +212 -238
- package/dist/components/CollectionPage/index.js +2 -3
- package/dist/components/FormComponent/Collection.js +77 -113
- package/dist/components/FormComponent/Collection.test.js +688 -787
- package/dist/components/FormComponent/Container.js +44 -43
- package/dist/components/FormComponent/Container.test.js +316 -346
- package/dist/components/FormComponent/FormComponent.js +58 -64
- package/dist/components/FormComponent/FormComponent.test.js +180 -219
- package/dist/components/FormComponent/helpers/addLabel.js +5 -9
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +2 -3
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +2 -2
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
- package/dist/components/FormComponent/helpers/index.js +5 -5
- package/dist/components/FormComponent/index.js +2 -3
- package/dist/components/FormPage/FormPage.js +65 -79
- package/dist/components/FormPage/FormPage.test.js +134 -170
- package/dist/components/FormPage/index.js +2 -3
- package/dist/components/FormRenderer/FormRenderer.js +151 -193
- package/dist/components/FormRenderer/FormRenderer.test.js +598 -920
- package/dist/components/FormRenderer/handlers/cyaAction.js +4 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +2 -5
- package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
- package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
- package/dist/components/FormRenderer/handlers/index.js +3 -4
- package/dist/components/FormRenderer/handlers/navigate.js +5 -6
- package/dist/components/FormRenderer/handlers/submissionError.js +2 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.js +2 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +10 -10
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +2 -5
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +19 -27
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +17 -17
- package/dist/components/FormRenderer/helpers/getCYA.js +6 -9
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -10
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +19 -34
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +3 -6
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -13
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +12 -13
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +98 -92
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +66 -66
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +72 -79
- package/dist/components/FormRenderer/helpers/index.js +3 -4
- package/dist/components/FormRenderer/index.js +2 -3
- package/dist/components/FormRenderer/onCYAAction.js +52 -62
- package/dist/components/FormRenderer/onCYAAction.test.js +146 -138
- package/dist/components/FormRenderer/onPageAction.js +48 -47
- package/dist/components/FormRenderer/onPageAction.test.js +219 -205
- package/dist/components/FormRenderer/onTaskAction.js +12 -17
- package/dist/components/FormRenderer/onTaskAction.test.js +94 -89
- package/dist/components/PageActions/ActionButton.js +15 -19
- package/dist/components/PageActions/ActionButton.test.js +58 -79
- package/dist/components/PageActions/PageActions.js +12 -13
- package/dist/components/PageActions/PageActions.test.js +88 -116
- package/dist/components/PageActions/index.js +2 -3
- package/dist/components/SummaryList/GroupAction.js +15 -23
- package/dist/components/SummaryList/GroupAction.test.js +41 -37
- package/dist/components/SummaryList/RowAction.js +14 -19
- package/dist/components/SummaryList/RowAction.test.js +41 -37
- package/dist/components/SummaryList/SummaryList.js +25 -30
- package/dist/components/SummaryList/SummaryList.test.js +160 -182
- package/dist/components/SummaryList/SummaryListHeadingRow.js +9 -8
- package/dist/components/SummaryList/SummaryListRow.js +9 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +8 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -8
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -8
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/index.js +2 -2
- package/dist/components/SummaryList/index.js +2 -3
- package/dist/components/TaskList/Task.js +22 -33
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +46 -75
- package/dist/components/TaskList/TaskList.test.js +118 -113
- package/dist/components/TaskList/TaskState.js +9 -9
- package/dist/components/TaskList/TaskState.test.js +56 -49
- package/dist/components/TaskList/index.js +2 -3
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +59 -85
- package/dist/context/HooksContext/HooksContext.test.js +28 -36
- package/dist/context/HooksContext/index.js +4 -6
- package/dist/context/ValidationContext/ValidationContext.js +35 -76
- package/dist/context/ValidationContext/ValidationContext.test.js +50 -61
- package/dist/context/ValidationContext/index.js +4 -6
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +17 -43
- package/dist/hooks/useGetRequest.js +61 -106
- package/dist/hooks/useHooks.js +2 -5
- package/dist/hooks/useRefData.js +29 -45
- package/dist/hooks/useValidation.js +2 -5
- package/dist/index.js +15 -17
- package/dist/models/CollectionLabels.js +2 -3
- package/dist/models/ComponentTypes.js +25 -26
- package/dist/models/EventTypes.js +5 -6
- package/dist/models/FormPages.js +5 -6
- package/dist/models/FormTypes.js +9 -10
- package/dist/models/HubFormats.js +4 -5
- package/dist/models/PageAction.js +45 -42
- package/dist/models/TaskStates.js +30 -31
- package/dist/models/index.js +11 -12
- package/dist/setupTests.js +20 -24
- package/dist/utils/CheckYourAnswers/getCYAAction.js +6 -7
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +18 -20
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +21 -23
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +18 -20
- package/dist/utils/CheckYourAnswers/getCYARow.js +8 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +72 -72
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +20 -27
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +41 -47
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +72 -75
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +71 -78
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +133 -114
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +27 -23
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +16 -23
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +77 -83
- package/dist/utils/CheckYourAnswers/index.js +3 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +7 -9
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +9 -16
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +19 -20
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +4 -8
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +15 -15
- package/dist/utils/CollectionPage/index.js +3 -4
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -29
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +15 -15
- package/dist/utils/Component/addShowWhen.js +5 -10
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +20 -22
- package/dist/utils/Component/applyToComponentTree.test.js +28 -33
- package/dist/utils/Component/cleanAttributes.js +11 -16
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +7 -9
- package/dist/utils/Component/elevateNestedComponents.test.js +19 -19
- package/dist/utils/Component/getComponent.js +91 -99
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +51 -63
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +41 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -37
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +12 -11
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +24 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +59 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +35 -41
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +24 -32
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
- package/dist/utils/Component/getDefaultValue.js +7 -9
- package/dist/utils/Component/getDefaultValue.test.js +14 -14
- package/dist/utils/Component/index.js +3 -4
- package/dist/utils/Component/isEditable.js +3 -7
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -3
- package/dist/utils/Component/optionIsSelected.test.js +10 -10
- package/dist/utils/Component/setupContainerComponentsPath.js +30 -33
- package/dist/utils/Component/setupContainerComponentsPath.test.js +16 -16
- package/dist/utils/Component/showComponent.js +4 -6
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +6 -6
- package/dist/utils/Condition/index.js +3 -4
- package/dist/utils/Condition/meetsAllConditions.js +9 -10
- package/dist/utils/Condition/meetsAllConditions.test.js +18 -18
- package/dist/utils/Condition/meetsCondition.js +19 -27
- package/dist/utils/Condition/meetsCondition.test.js +377 -377
- package/dist/utils/Condition/meetsOneCondition.js +7 -8
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +15 -21
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +5 -8
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +3 -4
- package/dist/utils/Container/setupNesting.js +17 -24
- package/dist/utils/Container/setupNesting.test.js +28 -31
- package/dist/utils/Container/showContainer.js +5 -10
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +41 -52
- package/dist/utils/Data/applyFormula.test.js +26 -26
- package/dist/utils/Data/getAutocompleteSource.js +11 -14
- package/dist/utils/Data/getAutocompleteSource.test.js +59 -59
- package/dist/utils/Data/getDataPath.js +21 -32
- package/dist/utils/Data/getDataPath.test.js +20 -20
- package/dist/utils/Data/getOptions.js +22 -28
- package/dist/utils/Data/getOptions.test.js +21 -21
- package/dist/utils/Data/getSourceData.js +7 -21
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +3 -4
- package/dist/utils/Data/refDataToOptions.js +12 -17
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +8 -10
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +32 -48
- package/dist/utils/Data/setupFormData.test.js +99 -98
- package/dist/utils/Data/setupRefDataUrlForComponent.js +22 -30
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +28 -28
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -12
- package/dist/utils/FormPage/applyConditionalProperties.test.js +16 -19
- package/dist/utils/FormPage/getFormPage.js +17 -19
- package/dist/utils/FormPage/getFormPage.test.js +49 -48
- package/dist/utils/FormPage/getFormPages.js +9 -15
- package/dist/utils/FormPage/getFormPages.test.js +22 -25
- package/dist/utils/FormPage/getPageActions.js +11 -19
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +6 -9
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -4
- package/dist/utils/FormPage/showFormPage.js +5 -10
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +4 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +21 -29
- package/dist/utils/FormPage/useComponent.test.js +71 -73
- package/dist/utils/Format/formatData.js +2 -3
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -9
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +7 -10
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -7
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +3 -4
- package/dist/utils/Hub/getFormHub.js +3 -4
- package/dist/utils/Hub/getFormHub.test.js +29 -32
- package/dist/utils/Hub/index.js +3 -4
- package/dist/utils/Meta/constants.js +2 -4
- package/dist/utils/Meta/documents/getDocuments.js +2 -6
- package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
- package/dist/utils/Meta/documents/index.js +3 -4
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -19
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +69 -35
- package/dist/utils/Meta/index.js +3 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +5 -6
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/getFirstOf.js +9 -10
- package/dist/utils/Operate/getFirstOf.test.js +33 -33
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +13 -14
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/index.js +3 -4
- package/dist/utils/Operate/persistValueInFormData.js +7 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +10 -11
- package/dist/utils/Operate/runPageOperations.test.js +36 -37
- package/dist/utils/Operate/setValueInFormData.js +6 -7
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +9 -10
- package/dist/utils/Operate/shouldRun.test.js +22 -28
- package/dist/utils/Validate/additional/conditionallyRequired.js +5 -7
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -9
- package/dist/utils/Validate/additional/index.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeAfter.js +4 -5
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +4 -5
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -14
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +34 -38
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +3 -4
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +5 -6
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +6 -7
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +3 -4
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +2 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +3 -4
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeShorterThan.js +2 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +4 -7
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +2 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +4 -7
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -25
- package/dist/utils/Validate/index.js +3 -4
- package/dist/utils/Validate/validateCollection.js +22 -29
- package/dist/utils/Validate/validateCollection.test.js +85 -77
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +169 -147
- package/dist/utils/Validate/validateContainer.js +16 -22
- package/dist/utils/Validate/validateContainer.test.js +52 -48
- package/dist/utils/Validate/validateDate.js +14 -21
- package/dist/utils/Validate/validateDate.test.js +28 -29
- package/dist/utils/Validate/validateEmail.js +8 -11
- package/dist/utils/Validate/validateEmail.test.js +26 -26
- package/dist/utils/Validate/validateMultifile.js +6 -10
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +20 -22
- package/dist/utils/Validate/validatePage.test.js +146 -143
- package/dist/utils/Validate/validateRegex.js +6 -10
- package/dist/utils/Validate/validateRegex.test.js +17 -17
- package/dist/utils/Validate/validateRequired.js +6 -9
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +6 -9
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +8 -16
- package/dist/utils/Validate/validateTime.test.js +15 -15
- package/dist/utils/index.js +10 -12
- package/package.json +9 -6
|
@@ -3,23 +3,24 @@
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
6
|
-
function _interopRequireDefault(
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
7
|
// Global imports
|
|
8
8
|
|
|
9
9
|
// Local imports
|
|
10
10
|
|
|
11
|
-
describe('utils.Component.get',
|
|
12
|
-
it('should return an appropriately rendered warning-text component',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered warning-text component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const CONTENT = 'Warning Text';
|
|
15
|
+
const COMPONENT = {
|
|
16
16
|
type: _models.ComponentTypes.WARNING,
|
|
17
17
|
content: CONTENT,
|
|
18
18
|
'data-testid': ID
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
container
|
|
22
|
-
|
|
20
|
+
const {
|
|
21
|
+
container
|
|
22
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
23
|
+
const warningText = (0, _react.getByTestId)(container, ID);
|
|
23
24
|
expect(warningText.innerHTML).toContain(CONTENT);
|
|
24
25
|
expect(warningText.tagName).toEqual('DIV');
|
|
25
26
|
expect(warningText.classList).toContain('govuk-warning-text');
|
|
@@ -5,13 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _models = require("../../models");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var getDefaultValue = function getDefaultValue(component) {
|
|
8
|
+
const DEFAULT_VALUES = {
|
|
9
|
+
[_models.ComponentTypes.COLLECTION]: [],
|
|
10
|
+
[_models.ComponentTypes.CONTAINER]: {},
|
|
11
|
+
[_models.ComponentTypes.FILE]: {}
|
|
12
|
+
};
|
|
13
|
+
const getDefaultValue = component => {
|
|
15
14
|
if (!component) {
|
|
16
15
|
return '';
|
|
17
16
|
}
|
|
@@ -23,5 +22,4 @@ var getDefaultValue = function getDefaultValue(component) {
|
|
|
23
22
|
}
|
|
24
23
|
return DEFAULT_VALUES[component.type] || '';
|
|
25
24
|
};
|
|
26
|
-
var _default = getDefaultValue;
|
|
27
|
-
exports.default = _default;
|
|
25
|
+
var _default = exports.default = getDefaultValue;
|
|
@@ -2,57 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
4
|
var _getDefaultValue = _interopRequireDefault(require("./getDefaultValue"));
|
|
5
|
-
function _interopRequireDefault(
|
|
6
|
-
describe('utils.Component.defaultValue',
|
|
7
|
-
it('should return an empty string if the component is undefined',
|
|
5
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
describe('utils.Component.defaultValue', () => {
|
|
7
|
+
it('should return an empty string if the component is undefined', () => {
|
|
8
8
|
expect((0, _getDefaultValue.default)(undefined)).toEqual('');
|
|
9
9
|
});
|
|
10
|
-
it('should return an empty string if the component is null',
|
|
10
|
+
it('should return an empty string if the component is null', () => {
|
|
11
11
|
expect((0, _getDefaultValue.default)(null)).toEqual('');
|
|
12
12
|
});
|
|
13
|
-
it('should return an empty string if the component has no type',
|
|
13
|
+
it('should return an empty string if the component has no type', () => {
|
|
14
14
|
expect((0, _getDefaultValue.default)({})).toEqual('');
|
|
15
15
|
});
|
|
16
|
-
it('should return an empty string if the component type is null',
|
|
16
|
+
it('should return an empty string if the component type is null', () => {
|
|
17
17
|
expect((0, _getDefaultValue.default)({
|
|
18
18
|
type: null
|
|
19
19
|
})).toEqual('');
|
|
20
20
|
});
|
|
21
|
-
it('should return an empty string if the component type is undefined',
|
|
21
|
+
it('should return an empty string if the component type is undefined', () => {
|
|
22
22
|
expect((0, _getDefaultValue.default)({
|
|
23
23
|
type: undefined
|
|
24
24
|
})).toEqual('');
|
|
25
25
|
});
|
|
26
|
-
it(
|
|
26
|
+
it(`should return an empty array if the component type is 'collection'`, () => {
|
|
27
27
|
expect((0, _getDefaultValue.default)({
|
|
28
28
|
type: _models.ComponentTypes.COLLECTION
|
|
29
29
|
})).toEqual([]);
|
|
30
30
|
});
|
|
31
|
-
it(
|
|
31
|
+
it(`should return an empty object if the component type is 'container'`, () => {
|
|
32
32
|
expect((0, _getDefaultValue.default)({
|
|
33
33
|
type: _models.ComponentTypes.CONTAINER
|
|
34
34
|
})).toEqual({});
|
|
35
35
|
});
|
|
36
|
-
it(
|
|
36
|
+
it(`should return an empty object if the component type is 'file'`, () => {
|
|
37
37
|
expect((0, _getDefaultValue.default)({
|
|
38
38
|
type: _models.ComponentTypes.FILE
|
|
39
39
|
})).toEqual({});
|
|
40
40
|
});
|
|
41
|
-
it('should return defaultValue if the component has defaultValue prop',
|
|
41
|
+
it('should return defaultValue if the component has defaultValue prop', () => {
|
|
42
42
|
expect((0, _getDefaultValue.default)({
|
|
43
43
|
type: _models.ComponentTypes.AUTOCOMPLETE,
|
|
44
44
|
defaultValue: 'test'
|
|
45
45
|
})).toEqual('test');
|
|
46
46
|
});
|
|
47
|
-
it('should return defaultObjectValue if the component has defaultObjectValue prop',
|
|
47
|
+
it('should return defaultObjectValue if the component has defaultObjectValue prop', () => {
|
|
48
48
|
expect((0, _getDefaultValue.default)({
|
|
49
49
|
type: _models.ComponentTypes.AUTOCOMPLETE,
|
|
50
50
|
defaultObjectValue: 'test'
|
|
51
51
|
})).toEqual('test');
|
|
52
52
|
});
|
|
53
|
-
Object.values(_models.ComponentTypes).forEach(
|
|
53
|
+
Object.values(_models.ComponentTypes).forEach(value => {
|
|
54
54
|
if (![_models.ComponentTypes.COLLECTION, _models.ComponentTypes.CONTAINER, _models.ComponentTypes.FILE].includes(value)) {
|
|
55
|
-
it(
|
|
55
|
+
it(`should return an empty object if the component type is '${value}'`, () => {
|
|
56
56
|
expect((0, _getDefaultValue.default)({
|
|
57
57
|
type: _models.ComponentTypes.TEXT
|
|
58
58
|
})).toEqual('');
|
|
@@ -12,8 +12,8 @@ var _isEditable = _interopRequireDefault(require("./isEditable"));
|
|
|
12
12
|
var _setupContainerComponentsPath = _interopRequireDefault(require("./setupContainerComponentsPath"));
|
|
13
13
|
var _showComponent = _interopRequireDefault(require("./showComponent"));
|
|
14
14
|
var _wrapInFormGroup = _interopRequireDefault(require("./wrapInFormGroup"));
|
|
15
|
-
function _interopRequireDefault(
|
|
16
|
-
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
const Component = {
|
|
17
17
|
clean: _cleanAttributes.default,
|
|
18
18
|
defaultValue: _getDefaultValue.default,
|
|
19
19
|
editable: _isEditable.default,
|
|
@@ -23,5 +23,4 @@ var Component = {
|
|
|
23
23
|
show: _showComponent.default,
|
|
24
24
|
wrap: _wrapInFormGroup.default
|
|
25
25
|
};
|
|
26
|
-
var _default = Component;
|
|
27
|
-
exports.default = _default;
|
|
26
|
+
var _default = exports.default = Component;
|
|
@@ -7,10 +7,6 @@ exports.default = exports.EDITABLE_TYPES = void 0;
|
|
|
7
7
|
var _models = require("../../models");
|
|
8
8
|
// Local imports
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
return EDITABLE_TYPES.includes(options === null || options === void 0 ? void 0 : options.type) || (options === null || options === void 0 ? void 0 : options.isEditable) || false;
|
|
14
|
-
};
|
|
15
|
-
var _default = isEditable;
|
|
16
|
-
exports.default = _default;
|
|
10
|
+
const EDITABLE_TYPES = exports.EDITABLE_TYPES = [_models.ComponentTypes.AUTOCOMPLETE, _models.ComponentTypes.CALCULATION, _models.ComponentTypes.CHECKBOXES, _models.ComponentTypes.DATE, _models.ComponentTypes.EMAIL, _models.ComponentTypes.FILE, _models.ComponentTypes.MULTI_FILE, _models.ComponentTypes.PHONE_NUMBER, _models.ComponentTypes.RADIOS, _models.ComponentTypes.SELECT, _models.ComponentTypes.TEXT, _models.ComponentTypes.TEXT_AREA, _models.ComponentTypes.TIME];
|
|
11
|
+
const isEditable = options => EDITABLE_TYPES.includes(options?.type) || options?.isEditable || false;
|
|
12
|
+
var _default = exports.default = isEditable;
|
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
3
|
var _isEditable = _interopRequireWildcard(require("./isEditable"));
|
|
5
|
-
function _getRequireWildcardCache(
|
|
6
|
-
function _interopRequireWildcard(
|
|
4
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
5
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
7
6
|
// Local imports
|
|
8
7
|
|
|
9
|
-
describe('utils',
|
|
10
|
-
describe('Component',
|
|
11
|
-
describe('isEditable',
|
|
12
|
-
_isEditable.EDITABLE_TYPES.forEach(
|
|
13
|
-
it(
|
|
14
|
-
|
|
15
|
-
type
|
|
8
|
+
describe('utils', () => {
|
|
9
|
+
describe('Component', () => {
|
|
10
|
+
describe('isEditable', () => {
|
|
11
|
+
_isEditable.EDITABLE_TYPES.forEach(type => {
|
|
12
|
+
it(`should return true for a type of '${type}'`, () => {
|
|
13
|
+
const OPTIONS = {
|
|
14
|
+
type
|
|
16
15
|
};
|
|
17
16
|
expect((0, _isEditable.default)(OPTIONS)).toEqual(true);
|
|
18
17
|
});
|
|
19
18
|
});
|
|
20
|
-
it('should return false if options is undefined',
|
|
19
|
+
it('should return false if options is undefined', () => {
|
|
21
20
|
expect((0, _isEditable.default)(undefined)).toEqual(false);
|
|
22
21
|
});
|
|
23
|
-
it('should return false if options is null',
|
|
22
|
+
it('should return false if options is null', () => {
|
|
24
23
|
expect((0, _isEditable.default)(null)).toEqual(false);
|
|
25
24
|
});
|
|
26
|
-
it('should return false if options has no type',
|
|
25
|
+
it('should return false if options has no type', () => {
|
|
27
26
|
expect((0, _isEditable.default)({
|
|
28
27
|
bob: 'Bob'
|
|
29
28
|
})).toEqual(false);
|
|
30
29
|
});
|
|
31
|
-
it(
|
|
30
|
+
it(`should return false if options has a type of 'hidden'`, () => {
|
|
32
31
|
expect((0, _isEditable.default)({
|
|
33
32
|
type: 'hidden'
|
|
34
33
|
})).toEqual(false);
|
|
35
34
|
});
|
|
36
|
-
it(
|
|
35
|
+
it(`should return true if options has 'isEditable' set to true`, () => {
|
|
37
36
|
expect((0, _isEditable.default)({
|
|
38
37
|
isEditable: true
|
|
39
38
|
})).toEqual(true);
|
|
@@ -12,11 +12,10 @@ exports.default = void 0;
|
|
|
12
12
|
*
|
|
13
13
|
* @returns A boolean of whether the option is selected.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
const optionIsSelected = (componentValue, option) => {
|
|
16
16
|
if (Array.isArray(componentValue)) {
|
|
17
17
|
return componentValue.includes(option.value);
|
|
18
18
|
}
|
|
19
19
|
return componentValue === option.value;
|
|
20
20
|
};
|
|
21
|
-
var _default = optionIsSelected;
|
|
22
|
-
exports.default = _default;
|
|
21
|
+
var _default = exports.default = optionIsSelected;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _optionIsSelected = _interopRequireDefault(require("./optionIsSelected"));
|
|
4
|
-
function _interopRequireDefault(
|
|
4
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
5
5
|
// Local imports
|
|
6
6
|
|
|
7
|
-
describe('utils.Component.isSelected',
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
describe('utils.Component.isSelected', () => {
|
|
8
|
+
const SELECTED_VALUE = 'selectedValue';
|
|
9
|
+
const NOT_SELECTED_VALUE = 'notSelectedValue';
|
|
10
|
+
const OPTIONS = [{
|
|
11
11
|
value: SELECTED_VALUE
|
|
12
12
|
}, {
|
|
13
13
|
value: NOT_SELECTED_VALUE
|
|
14
14
|
}];
|
|
15
|
-
|
|
15
|
+
const COMPONENT = {
|
|
16
16
|
id: 'a',
|
|
17
17
|
fieldId: 'a',
|
|
18
18
|
data: {
|
|
19
19
|
options: OPTIONS
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
it('should properly identify which option is selected for checkboxes',
|
|
23
|
-
|
|
22
|
+
it('should properly identify which option is selected for checkboxes', () => {
|
|
23
|
+
const PAGE = {
|
|
24
24
|
formData: {
|
|
25
25
|
a: [SELECTED_VALUE]
|
|
26
26
|
}
|
|
@@ -29,8 +29,8 @@ describe('utils.Component.isSelected', function () {
|
|
|
29
29
|
expect((0, _optionIsSelected.default)(PAGE.formData[COMPONENT.id], OPTIONS[0])).toEqual(true);
|
|
30
30
|
expect((0, _optionIsSelected.default)(PAGE.formData[COMPONENT.id], OPTIONS[1])).toEqual(false);
|
|
31
31
|
});
|
|
32
|
-
it('should properly identify which option is selected for radios',
|
|
33
|
-
|
|
32
|
+
it('should properly identify which option is selected for radios', () => {
|
|
33
|
+
const PAGE = {
|
|
34
34
|
formData: {
|
|
35
35
|
a: SELECTED_VALUE
|
|
36
36
|
}
|
|
@@ -5,36 +5,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _showComponentCYA = require("../CheckYourAnswers/showComponentCYA");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
var _default = setupContainerComponentsPath;
|
|
40
|
-
exports.default = _default;
|
|
8
|
+
const setupContainerComponentsPath = container => ({
|
|
9
|
+
...container,
|
|
10
|
+
components: container.components.map(component => {
|
|
11
|
+
if (Array.isArray(component.components)) {
|
|
12
|
+
return {
|
|
13
|
+
...component,
|
|
14
|
+
components: component.components.map(c => {
|
|
15
|
+
if (!_showComponentCYA.EXCLUDE_FROM_CYA.includes(c.type)) {
|
|
16
|
+
return {
|
|
17
|
+
...c,
|
|
18
|
+
...(!c.full_path && {
|
|
19
|
+
full_path: `${component.full_path || `${container.full_path}.${component.fieldId}`}.${c.fieldId}`
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
;
|
|
24
|
+
return null;
|
|
25
|
+
}).filter(c => !!c)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
;
|
|
29
|
+
return {
|
|
30
|
+
...component,
|
|
31
|
+
...(!component.full_path && {
|
|
32
|
+
full_path: `${container.full_path || container.fieldId}.${component.fieldId}`
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
var _default = exports.default = setupContainerComponentsPath;
|
|
@@ -2,75 +2,75 @@
|
|
|
2
2
|
|
|
3
3
|
var _setupTests = require("../../setupTests");
|
|
4
4
|
var _setupContainerComponentsPath = _interopRequireDefault(require("./setupContainerComponentsPath"));
|
|
5
|
-
function _interopRequireDefault(
|
|
6
|
-
describe('utils.CheckYourAnswers.setupContainerComponentsPath',
|
|
7
|
-
it('should setup the full_path attribute for components within a container',
|
|
8
|
-
|
|
5
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
describe('utils.CheckYourAnswers.setupContainerComponentsPath', () => {
|
|
7
|
+
it('should setup the full_path attribute for components within a container', () => {
|
|
8
|
+
const COMPONENT_1 = {
|
|
9
9
|
id: 'checkboxes1',
|
|
10
10
|
fieldId: 'checkboxes1',
|
|
11
11
|
type: 'checkboxes',
|
|
12
12
|
label: 'Alpha'
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
const COMPONENT_2 = {
|
|
15
15
|
id: 'checkboxes2',
|
|
16
16
|
fieldId: 'checkboxes2',
|
|
17
17
|
type: 'checkboxes',
|
|
18
18
|
label: 'Bravo'
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
const CONTAINER = {
|
|
21
21
|
id: 'test-container',
|
|
22
22
|
fieldId: 'test-container',
|
|
23
23
|
type: 'container',
|
|
24
24
|
full_path: 'test-container',
|
|
25
25
|
components: [COMPONENT_1, COMPONENT_2]
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
const container = (0, _setupContainerComponentsPath.default)(CONTAINER);
|
|
28
28
|
(0, _setupTests.expectObjectLike)(container.components[0], {
|
|
29
29
|
id: COMPONENT_1.id,
|
|
30
30
|
fieldId: COMPONENT_1.fieldId,
|
|
31
|
-
full_path:
|
|
31
|
+
full_path: `${CONTAINER.fieldId}.${COMPONENT_1.fieldId}`,
|
|
32
32
|
type: COMPONENT_1.type,
|
|
33
33
|
label: COMPONENT_1.label
|
|
34
34
|
});
|
|
35
35
|
(0, _setupTests.expectObjectLike)(container.components[1], {
|
|
36
36
|
id: COMPONENT_2.id,
|
|
37
37
|
fieldId: COMPONENT_2.fieldId,
|
|
38
|
-
full_path:
|
|
38
|
+
full_path: `${CONTAINER.fieldId}.${COMPONENT_2.fieldId}`,
|
|
39
39
|
type: COMPONENT_2.type,
|
|
40
40
|
label: COMPONENT_2.label
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
|
-
it('should setup the full_path attribute for components when the container full_path property is missing',
|
|
44
|
-
|
|
43
|
+
it('should setup the full_path attribute for components when the container full_path property is missing', () => {
|
|
44
|
+
const COMPONENT_1 = {
|
|
45
45
|
id: 'checkboxes1',
|
|
46
46
|
fieldId: 'checkboxes1',
|
|
47
47
|
type: 'checkboxes',
|
|
48
48
|
label: 'Alpha'
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
const COMPONENT_2 = {
|
|
51
51
|
id: 'checkboxes2',
|
|
52
52
|
fieldId: 'checkboxes2',
|
|
53
53
|
type: 'checkboxes',
|
|
54
54
|
label: 'Bravo'
|
|
55
55
|
};
|
|
56
|
-
|
|
56
|
+
const CONTAINER = {
|
|
57
57
|
id: 'test-container',
|
|
58
58
|
fieldId: 'test-container',
|
|
59
59
|
type: 'container',
|
|
60
60
|
components: [COMPONENT_1, COMPONENT_2]
|
|
61
61
|
};
|
|
62
|
-
|
|
62
|
+
const container = (0, _setupContainerComponentsPath.default)(CONTAINER);
|
|
63
63
|
(0, _setupTests.expectObjectLike)(container.components[0], {
|
|
64
64
|
id: COMPONENT_1.id,
|
|
65
65
|
fieldId: COMPONENT_1.fieldId,
|
|
66
|
-
full_path:
|
|
66
|
+
full_path: `${CONTAINER.fieldId}.${COMPONENT_1.fieldId}`,
|
|
67
67
|
type: COMPONENT_1.type,
|
|
68
68
|
label: COMPONENT_1.label
|
|
69
69
|
});
|
|
70
70
|
(0, _setupTests.expectObjectLike)(container.components[1], {
|
|
71
71
|
id: COMPONENT_2.id,
|
|
72
72
|
fieldId: COMPONENT_2.fieldId,
|
|
73
|
-
full_path:
|
|
73
|
+
full_path: `${CONTAINER.fieldId}.${COMPONENT_2.fieldId}`,
|
|
74
74
|
type: COMPONENT_2.type,
|
|
75
75
|
label: COMPONENT_2.label
|
|
76
76
|
});
|
|
@@ -5,21 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _Condition = _interopRequireDefault(require("../Condition"));
|
|
8
|
-
function _interopRequireDefault(
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
// Local imports
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
var _component$show_when;
|
|
11
|
+
const showComponent = (component, data) => {
|
|
13
12
|
if (!component) {
|
|
14
13
|
return false;
|
|
15
14
|
}
|
|
16
15
|
if (component.hidden && component.disabled) {
|
|
17
16
|
return false;
|
|
18
17
|
}
|
|
19
|
-
if (
|
|
18
|
+
if (component.show_when?.type === "or") {
|
|
20
19
|
return _Condition.default.meetsOne(component, data);
|
|
21
20
|
}
|
|
22
21
|
return _Condition.default.meetsAll(component, data);
|
|
23
22
|
};
|
|
24
|
-
var _default = showComponent;
|
|
25
|
-
exports.default = _default;
|
|
23
|
+
var _default = exports.default = showComponent;
|
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _showComponent = _interopRequireDefault(require("./showComponent"));
|
|
4
|
-
function _interopRequireDefault(
|
|
4
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
5
5
|
// Local imports
|
|
6
6
|
|
|
7
|
-
describe('utils',
|
|
8
|
-
describe('Component',
|
|
9
|
-
describe('show',
|
|
10
|
-
it('should not show when there are no options',
|
|
7
|
+
describe('utils', () => {
|
|
8
|
+
describe('Component', () => {
|
|
9
|
+
describe('show', () => {
|
|
10
|
+
it('should not show when there are no options', () => {
|
|
11
11
|
expect((0, _showComponent.default)(null, null)).toBeFalsy();
|
|
12
12
|
});
|
|
13
|
-
it('should not show when hidden and disabled',
|
|
13
|
+
it('should not show when hidden and disabled', () => {
|
|
14
14
|
expect((0, _showComponent.default)({
|
|
15
15
|
hidden: true,
|
|
16
16
|
disabled: true
|
|
17
17
|
}, null)).toBeFalsy();
|
|
18
18
|
});
|
|
19
|
-
it('should show when hidden but not disabled',
|
|
19
|
+
it('should show when hidden but not disabled', () => {
|
|
20
20
|
expect((0, _showComponent.default)({
|
|
21
21
|
hidden: true
|
|
22
22
|
}, null)).toBeTruthy();
|
|
23
23
|
});
|
|
24
|
-
it('should show when disabled but not hidden',
|
|
24
|
+
it('should show when disabled but not hidden', () => {
|
|
25
25
|
expect((0, _showComponent.default)({
|
|
26
26
|
disabled: true
|
|
27
27
|
}, null)).toBeTruthy();
|
|
28
28
|
});
|
|
29
|
-
it('should show when a single show_when condition is met',
|
|
30
|
-
|
|
29
|
+
it('should show when a single show_when condition is met', () => {
|
|
30
|
+
const COMPONENT = {
|
|
31
31
|
show_when: {
|
|
32
32
|
field: 'alpha',
|
|
33
33
|
op: 'eq',
|
|
34
34
|
value: 'bravo'
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
const DATA = {
|
|
38
38
|
alpha: 'bravo'
|
|
39
39
|
};
|
|
40
40
|
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
|
|
41
41
|
});
|
|
42
|
-
it('should not show when a single show_when condition is not met',
|
|
43
|
-
|
|
42
|
+
it('should not show when a single show_when condition is not met', () => {
|
|
43
|
+
const COMPONENT = {
|
|
44
44
|
show_when: {
|
|
45
45
|
field: 'alpha',
|
|
46
46
|
op: 'eq',
|
|
47
47
|
value: 'bravo'
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
const DATA = {
|
|
51
51
|
alpha: 'charlie'
|
|
52
52
|
};
|
|
53
53
|
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeFalsy();
|
|
54
54
|
});
|
|
55
|
-
it('should show when multiple show_when conditions are met',
|
|
56
|
-
|
|
55
|
+
it('should show when multiple show_when conditions are met', () => {
|
|
56
|
+
const COMPONENT = {
|
|
57
57
|
show_when: [{
|
|
58
58
|
field: 'alpha',
|
|
59
59
|
op: 'eq',
|
|
@@ -64,14 +64,14 @@ describe('utils', function () {
|
|
|
64
64
|
value: 'delta'
|
|
65
65
|
}]
|
|
66
66
|
};
|
|
67
|
-
|
|
67
|
+
const DATA = {
|
|
68
68
|
alpha: 'bravo',
|
|
69
69
|
charlie: 'delta'
|
|
70
70
|
};
|
|
71
71
|
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
|
|
72
72
|
});
|
|
73
|
-
it('should not show when one of multiple show_when conditions is not met',
|
|
74
|
-
|
|
73
|
+
it('should not show when one of multiple show_when conditions is not met', () => {
|
|
74
|
+
const COMPONENT = {
|
|
75
75
|
show_when: [{
|
|
76
76
|
field: 'alpha',
|
|
77
77
|
op: 'eq',
|
|
@@ -82,14 +82,14 @@ describe('utils', function () {
|
|
|
82
82
|
value: 'delta'
|
|
83
83
|
}]
|
|
84
84
|
};
|
|
85
|
-
|
|
85
|
+
const DATA = {
|
|
86
86
|
alpha: 'bravo',
|
|
87
87
|
charlie: 'echo'
|
|
88
88
|
};
|
|
89
89
|
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeFalsy();
|
|
90
90
|
});
|
|
91
|
-
it('SHOULD be shown when the component has multiple show_when conditions, with type "or" provided and ALL are matched',
|
|
92
|
-
|
|
91
|
+
it('SHOULD be shown when the component has multiple show_when conditions, with type "or" provided and ALL are matched', () => {
|
|
92
|
+
const COMPONENT = {
|
|
93
93
|
show_when: {
|
|
94
94
|
"type": "or",
|
|
95
95
|
"conditions": [{
|
|
@@ -103,14 +103,14 @@ describe('utils', function () {
|
|
|
103
103
|
}]
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
|
|
106
|
+
const DATA = {
|
|
107
107
|
alpha: 'Alpha',
|
|
108
108
|
bravo: 'Bravo'
|
|
109
109
|
};
|
|
110
110
|
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
|
|
111
111
|
});
|
|
112
|
-
it('SHOULD be shown when the component has multiple show_when conditions, with type "or" provided and at least ONE is matched',
|
|
113
|
-
|
|
112
|
+
it('SHOULD be shown when the component has multiple show_when conditions, with type "or" provided and at least ONE is matched', () => {
|
|
113
|
+
const COMPONENT = {
|
|
114
114
|
show_when: {
|
|
115
115
|
"type": "or",
|
|
116
116
|
"conditions": [{
|
|
@@ -124,14 +124,14 @@ describe('utils', function () {
|
|
|
124
124
|
}]
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
-
|
|
127
|
+
const DATA = {
|
|
128
128
|
alpha: 'Alpha',
|
|
129
129
|
bravo: 'Bravo'
|
|
130
130
|
};
|
|
131
131
|
expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
|
|
132
132
|
});
|
|
133
|
-
it('should NOT be shown when the component has multiple show_when conditions, with type "or" provided and NONE are matched',
|
|
134
|
-
|
|
133
|
+
it('should NOT be shown when the component has multiple show_when conditions, with type "or" provided and NONE are matched', () => {
|
|
134
|
+
const COMPONENT = {
|
|
135
135
|
show_when: {
|
|
136
136
|
"type": "or",
|
|
137
137
|
"conditions": [{
|
|
@@ -145,7 +145,7 @@ describe('utils', function () {
|
|
|
145
145
|
}]
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
|
|
148
|
+
const DATA = {
|
|
149
149
|
alpha: 'Alpha',
|
|
150
150
|
bravo: 'Bravo'
|
|
151
151
|
};
|