@ukhomeoffice/cop-react-form-renderer 5.14.0 → 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 +65 -106
- package/dist/hooks/useHooks.js +2 -5
- package/dist/hooks/useRefData.js +30 -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
|
@@ -4,30 +4,28 @@ var _react = require("@testing-library/react");
|
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _setupTests = require("../../../setupTests");
|
|
6
6
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
7
|
-
function _interopRequireDefault(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var LABEL = 'label';
|
|
19
|
-
var OPTIONS = [{
|
|
7
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
// Global imports
|
|
9
|
+
|
|
10
|
+
// Local imports
|
|
11
|
+
|
|
12
|
+
describe('utils.Component.get', () => {
|
|
13
|
+
it('should return an appropriately rendered checkboxes component', () => {
|
|
14
|
+
const ID = 'test-id';
|
|
15
|
+
const FIELD_ID = 'field-id';
|
|
16
|
+
const LABEL = 'label';
|
|
17
|
+
const OPTIONS = [{
|
|
20
18
|
value: 'a',
|
|
21
19
|
label: 'Alpha'
|
|
22
20
|
}, {
|
|
23
21
|
value: 'b',
|
|
24
22
|
label: 'Bravo'
|
|
25
23
|
}];
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const ON_CHANGE_CALLS = [];
|
|
25
|
+
const ON_CHANGE = e => {
|
|
28
26
|
ON_CHANGE_CALLS.push(e.target);
|
|
29
27
|
};
|
|
30
|
-
|
|
28
|
+
const COMPONENT = {
|
|
31
29
|
type: _models.ComponentTypes.CHECKBOXES,
|
|
32
30
|
id: ID,
|
|
33
31
|
fieldId: FIELD_ID,
|
|
@@ -38,16 +36,14 @@ describe('utils.Component.get', function () {
|
|
|
38
36
|
onChange: ON_CHANGE,
|
|
39
37
|
'data-testid': ID
|
|
40
38
|
};
|
|
41
|
-
|
|
42
|
-
container
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
formGroup = _getAllByTestId2[0],
|
|
46
|
-
checkboxes = _getAllByTestId2[1];
|
|
39
|
+
const {
|
|
40
|
+
container
|
|
41
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
42
|
+
const [formGroup, checkboxes] = (0, _react.getAllByTestId)(container, ID);
|
|
47
43
|
expect(formGroup.tagName).toEqual('DIV');
|
|
48
44
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
49
|
-
|
|
50
|
-
formGroup.childNodes.forEach(
|
|
45
|
+
let label;
|
|
46
|
+
formGroup.childNodes.forEach(node => {
|
|
51
47
|
// Check if it's an element.
|
|
52
48
|
if (node instanceof Element) {
|
|
53
49
|
if (node.tagName === 'LABEL') {
|
|
@@ -61,22 +57,20 @@ describe('utils.Component.get', function () {
|
|
|
61
57
|
expect(checkboxes.tagName).toEqual('DIV');
|
|
62
58
|
expect(checkboxes.classList).toContain('govuk-checkboxes');
|
|
63
59
|
expect(checkboxes.childNodes.length).toEqual(OPTIONS.length);
|
|
64
|
-
|
|
65
|
-
OPTIONS.forEach(
|
|
66
|
-
|
|
60
|
+
const checkboxItems = [];
|
|
61
|
+
OPTIONS.forEach((_, index) => {
|
|
62
|
+
const checkbox = checkboxes.childNodes[index];
|
|
67
63
|
expect(checkbox instanceof Element).toBeTruthy();
|
|
68
64
|
if (checkbox instanceof Element) {
|
|
69
65
|
checkboxItems.push(checkbox);
|
|
70
66
|
}
|
|
71
67
|
});
|
|
72
68
|
expect(checkboxItems.length).toEqual(OPTIONS.length);
|
|
73
|
-
OPTIONS.forEach(
|
|
74
|
-
|
|
69
|
+
OPTIONS.forEach((option, index) => {
|
|
70
|
+
const checkbox = checkboxItems[index];
|
|
75
71
|
expect(checkbox.tagName).toEqual('DIV');
|
|
76
72
|
expect(checkbox.classList).toContain('govuk-checkboxes__item');
|
|
77
|
-
|
|
78
|
-
input = _checkbox$childNodes[0],
|
|
79
|
-
inputLabel = _checkbox$childNodes[1];
|
|
73
|
+
const [input, inputLabel] = checkbox.childNodes;
|
|
80
74
|
expect(input.tagName).toEqual('INPUT');
|
|
81
75
|
expect(input.type).toEqual('checkbox');
|
|
82
76
|
expect(inputLabel.textContent).toEqual(option.label);
|
|
@@ -100,16 +94,16 @@ describe('utils.Component.get', function () {
|
|
|
100
94
|
value: [OPTIONS[1].value]
|
|
101
95
|
});
|
|
102
96
|
});
|
|
103
|
-
it('should return an appropriately rendered checkboxes component with a nested component',
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
it('should return an appropriately rendered checkboxes component with a nested component', () => {
|
|
98
|
+
const ID = 'test-id';
|
|
99
|
+
const FIELD_ID = 'field-id';
|
|
100
|
+
const LABEL = 'label';
|
|
101
|
+
const NESTED = {
|
|
108
102
|
id: 'charle',
|
|
109
103
|
fieldId: 'charle',
|
|
110
104
|
type: 'text'
|
|
111
105
|
};
|
|
112
|
-
|
|
106
|
+
const OPTIONS = [{
|
|
113
107
|
value: 'a',
|
|
114
108
|
label: 'Alpha',
|
|
115
109
|
nested: [NESTED]
|
|
@@ -117,11 +111,11 @@ describe('utils.Component.get', function () {
|
|
|
117
111
|
value: 'b',
|
|
118
112
|
label: 'Bravo'
|
|
119
113
|
}];
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
const ON_CHANGE_CALLS = [];
|
|
115
|
+
const ON_CHANGE = e => {
|
|
122
116
|
ON_CHANGE_CALLS.push(e.target);
|
|
123
117
|
};
|
|
124
|
-
|
|
118
|
+
const COMPONENT = {
|
|
125
119
|
type: _models.ComponentTypes.CHECKBOXES,
|
|
126
120
|
id: ID,
|
|
127
121
|
fieldId: FIELD_ID,
|
|
@@ -133,16 +127,14 @@ describe('utils.Component.get', function () {
|
|
|
133
127
|
onChange: ON_CHANGE,
|
|
134
128
|
'data-testid': ID
|
|
135
129
|
};
|
|
136
|
-
|
|
137
|
-
container
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
formGroup = _getAllByTestId4[0],
|
|
141
|
-
checkboxes = _getAllByTestId4[1];
|
|
130
|
+
const {
|
|
131
|
+
container
|
|
132
|
+
} = (0, _setupTests.renderWithValidation)((0, _getComponent.default)(COMPONENT));
|
|
133
|
+
const [formGroup, checkboxes] = (0, _react.getAllByTestId)(container, ID);
|
|
142
134
|
expect(formGroup.tagName).toEqual('DIV');
|
|
143
135
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
144
|
-
|
|
145
|
-
formGroup.childNodes.forEach(
|
|
136
|
+
let label;
|
|
137
|
+
formGroup.childNodes.forEach(node => {
|
|
146
138
|
// Check if it's an element.
|
|
147
139
|
if (node instanceof Element) {
|
|
148
140
|
if (node.tagName === 'LABEL') {
|
|
@@ -3,23 +3,21 @@
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
6
|
-
function _interopRequireDefault(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var ON_CHANGE_CALLS = [];
|
|
19
|
-
var ON_CHANGE = function ON_CHANGE(e) {
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
// Global imports
|
|
8
|
+
|
|
9
|
+
// Local imports
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered date component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const ON_CHANGE_CALLS = [];
|
|
17
|
+
const ON_CHANGE = e => {
|
|
20
18
|
ON_CHANGE_CALLS.push(e.target);
|
|
21
19
|
};
|
|
22
|
-
|
|
20
|
+
const COMPONENT = {
|
|
23
21
|
type: _models.ComponentTypes.DATE,
|
|
24
22
|
id: ID,
|
|
25
23
|
fieldId: FIELD_ID,
|
|
@@ -27,55 +25,53 @@ describe('utils.Component.get', function () {
|
|
|
27
25
|
onChange: ON_CHANGE,
|
|
28
26
|
'data-testid': ID
|
|
29
27
|
};
|
|
30
|
-
|
|
31
|
-
container
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
formGroup = _getAllByTestId2[0],
|
|
35
|
-
dateinput = _getAllByTestId2[1];
|
|
28
|
+
const {
|
|
29
|
+
container
|
|
30
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
31
|
+
const [formGroup, dateinput] = (0, _react.getAllByTestId)(container, ID);
|
|
36
32
|
expect(formGroup.tagName).toEqual('DIV');
|
|
37
33
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
38
|
-
|
|
34
|
+
const label = formGroup.childNodes[0];
|
|
39
35
|
expect(label.innerHTML).toContain(LABEL);
|
|
40
36
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
41
37
|
expect(dateinput.tagName).toEqual('DIV');
|
|
42
38
|
expect(dateinput.classList).toContain('govuk-date-input');
|
|
43
39
|
expect(dateinput.id).toEqual(ID);
|
|
44
|
-
|
|
40
|
+
const dayitem = dateinput.childNodes[0];
|
|
45
41
|
expect(dayitem.tagName).toEqual('DIV');
|
|
46
42
|
expect(dayitem.classList).toContain('govuk-date-input__item');
|
|
47
|
-
|
|
43
|
+
const daylabel = dayitem.childNodes[0];
|
|
48
44
|
expect(daylabel.tagName).toEqual('LABEL');
|
|
49
45
|
expect(daylabel.classList).toContain('govuk-label');
|
|
50
46
|
expect(daylabel.textContent).toEqual('Day');
|
|
51
|
-
|
|
47
|
+
const dayinput = dayitem.childNodes[1];
|
|
52
48
|
expect(dayinput.tagName).toEqual('INPUT');
|
|
53
|
-
expect(dayinput.id).toEqual(
|
|
54
|
-
|
|
49
|
+
expect(dayinput.id).toEqual(`${ID}-day`);
|
|
50
|
+
const monthitem = dateinput.childNodes[1];
|
|
55
51
|
expect(monthitem.tagName).toEqual('DIV');
|
|
56
52
|
expect(monthitem.classList).toContain('govuk-date-input__item');
|
|
57
|
-
|
|
53
|
+
const monthlabel = monthitem.childNodes[0];
|
|
58
54
|
expect(monthlabel.tagName).toEqual('LABEL');
|
|
59
55
|
expect(monthlabel.classList).toContain('govuk-label');
|
|
60
56
|
expect(monthlabel.textContent).toEqual('Month');
|
|
61
|
-
|
|
57
|
+
const monthinput = monthitem.childNodes[1];
|
|
62
58
|
expect(monthinput.tagName).toEqual('INPUT');
|
|
63
|
-
expect(monthinput.id).toEqual(
|
|
64
|
-
|
|
59
|
+
expect(monthinput.id).toEqual(`${ID}-month`);
|
|
60
|
+
const yearitem = dateinput.childNodes[2];
|
|
65
61
|
expect(yearitem.tagName).toEqual('DIV');
|
|
66
62
|
expect(yearitem.classList).toContain('govuk-date-input__item');
|
|
67
|
-
|
|
63
|
+
const yearlabel = yearitem.childNodes[0];
|
|
68
64
|
expect(yearlabel.tagName).toEqual('LABEL');
|
|
69
65
|
expect(yearlabel.classList).toContain('govuk-label');
|
|
70
66
|
expect(yearlabel.textContent).toEqual('Year');
|
|
71
|
-
|
|
67
|
+
const yearinput = yearitem.childNodes[1];
|
|
72
68
|
expect(yearinput.tagName).toEqual('INPUT');
|
|
73
|
-
expect(yearinput.id).toEqual(
|
|
69
|
+
expect(yearinput.id).toEqual(`${ID}-year`);
|
|
74
70
|
|
|
75
71
|
// Add something to the day and make sure it fires.
|
|
76
72
|
_react.fireEvent.change(dayinput, {
|
|
77
73
|
target: {
|
|
78
|
-
name:
|
|
74
|
+
name: `${FIELD_ID}-day`,
|
|
79
75
|
value: '5'
|
|
80
76
|
}
|
|
81
77
|
});
|
|
@@ -87,7 +83,7 @@ describe('utils.Component.get', function () {
|
|
|
87
83
|
// And now the month...
|
|
88
84
|
_react.fireEvent.change(monthinput, {
|
|
89
85
|
target: {
|
|
90
|
-
name:
|
|
86
|
+
name: `${FIELD_ID}-month`,
|
|
91
87
|
value: '11'
|
|
92
88
|
}
|
|
93
89
|
});
|
|
@@ -99,7 +95,7 @@ describe('utils.Component.get', function () {
|
|
|
99
95
|
// And finally the year.
|
|
100
96
|
_react.fireEvent.change(yearinput, {
|
|
101
97
|
target: {
|
|
102
|
-
name:
|
|
98
|
+
name: `${FIELD_ID}-year`,
|
|
103
99
|
value: '2022'
|
|
104
100
|
}
|
|
105
101
|
});
|
|
@@ -3,45 +3,47 @@
|
|
|
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 a details component containing basic text',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return a details component containing basic text', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const CONTENT = 'Details content';
|
|
15
|
+
const SUMMARY = 'Details Summary';
|
|
16
|
+
const COMPONENT = {
|
|
17
17
|
type: _models.ComponentTypes.DETAILS,
|
|
18
18
|
content: CONTENT,
|
|
19
19
|
summary: SUMMARY,
|
|
20
20
|
'data-testid': ID
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
container
|
|
24
|
-
|
|
22
|
+
const {
|
|
23
|
+
container
|
|
24
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
25
|
+
const details = container.querySelector('details');
|
|
25
26
|
expect(details.classList).toContain('hods-details');
|
|
26
27
|
expect(details.childNodes[0].textContent).toEqual(SUMMARY);
|
|
27
28
|
expect(details.childNodes[1].textContent).toEqual(CONTENT);
|
|
28
29
|
});
|
|
29
|
-
it('should return a details component containing multiple html components',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
it('should return a details component containing multiple html components', () => {
|
|
31
|
+
const ID = 'test-id';
|
|
32
|
+
const CONTENT = '<p>this is the content</p><ol><li>one</li><li>two</li></ol><p>second section of content</p>';
|
|
33
|
+
const SUMMARY = 'Details Summary';
|
|
34
|
+
const COMPONENT = {
|
|
34
35
|
type: _models.ComponentTypes.DETAILS,
|
|
35
36
|
content: CONTENT,
|
|
36
37
|
summary: SUMMARY,
|
|
37
38
|
tagName: 'div',
|
|
38
39
|
'data-testid': ID
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
-
container
|
|
42
|
-
|
|
41
|
+
const {
|
|
42
|
+
container
|
|
43
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
44
|
+
const details = container.querySelector('details');
|
|
43
45
|
expect(details.classList).toContain('hods-details');
|
|
44
|
-
|
|
46
|
+
const content = details.childNodes[1].childNodes[0].childNodes;
|
|
45
47
|
expect(content[0].textContent).toEqual('this is the content');
|
|
46
48
|
expect(content[0].tagName).toEqual('P');
|
|
47
49
|
expect(content[1].childNodes[0].textContent).toEqual('one');
|
|
@@ -3,23 +3,21 @@
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
4
|
var _models = require("../../../models");
|
|
5
5
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
6
|
-
function _interopRequireDefault(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var ON_CHANGE_CALLS = [];
|
|
19
|
-
var ON_CHANGE = function ON_CHANGE(e) {
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
// Global imports
|
|
8
|
+
|
|
9
|
+
// Local imports
|
|
10
|
+
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered email component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const FIELD_ID = 'field-id';
|
|
15
|
+
const LABEL = 'label';
|
|
16
|
+
const ON_CHANGE_CALLS = [];
|
|
17
|
+
const ON_CHANGE = e => {
|
|
20
18
|
ON_CHANGE_CALLS.push(e.target);
|
|
21
19
|
};
|
|
22
|
-
|
|
20
|
+
const COMPONENT = {
|
|
23
21
|
type: _models.ComponentTypes.EMAIL,
|
|
24
22
|
id: ID,
|
|
25
23
|
fieldId: FIELD_ID,
|
|
@@ -27,16 +25,14 @@ describe('utils.Component.get', function () {
|
|
|
27
25
|
onChange: ON_CHANGE,
|
|
28
26
|
'data-testid': ID
|
|
29
27
|
};
|
|
30
|
-
|
|
31
|
-
container
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
formGroup = _getAllByTestId2[0],
|
|
35
|
-
input = _getAllByTestId2[1];
|
|
28
|
+
const {
|
|
29
|
+
container
|
|
30
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
31
|
+
const [formGroup, input] = (0, _react.getAllByTestId)(container, ID);
|
|
36
32
|
expect(formGroup.tagName).toEqual('DIV');
|
|
37
33
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
38
|
-
|
|
39
|
-
formGroup.childNodes.forEach(
|
|
34
|
+
let label;
|
|
35
|
+
formGroup.childNodes.forEach(node => {
|
|
40
36
|
// Check if it's an element.
|
|
41
37
|
if (node instanceof Element && node.tagName === 'LABEL') {
|
|
42
38
|
label = node;
|
|
@@ -4,23 +4,21 @@ var _react = require("@testing-library/react");
|
|
|
4
4
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
5
5
|
var _models = require("../../../models");
|
|
6
6
|
var _getComponent = _interopRequireDefault(require("../getComponent"));
|
|
7
|
-
function _interopRequireDefault(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var ON_CHANGE_CALLS = [];
|
|
20
|
-
var ON_CHANGE = function ON_CHANGE(e) {
|
|
7
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
// Global imports
|
|
9
|
+
|
|
10
|
+
// Local imports
|
|
11
|
+
|
|
12
|
+
describe('utils.Component.get', () => {
|
|
13
|
+
it('should return an appropriately rendered file component', () => {
|
|
14
|
+
const ID = 'test-id';
|
|
15
|
+
const FIELD_ID = 'field-id';
|
|
16
|
+
const LABEL = 'label';
|
|
17
|
+
const ON_CHANGE_CALLS = [];
|
|
18
|
+
const ON_CHANGE = e => {
|
|
21
19
|
ON_CHANGE_CALLS.push(e.target);
|
|
22
20
|
};
|
|
23
|
-
|
|
21
|
+
const COMPONENT = {
|
|
24
22
|
type: _models.ComponentTypes.FILE,
|
|
25
23
|
id: ID,
|
|
26
24
|
fieldId: FIELD_ID,
|
|
@@ -28,16 +26,14 @@ describe('utils.Component.get', function () {
|
|
|
28
26
|
onChange: ON_CHANGE,
|
|
29
27
|
'data-testid': ID
|
|
30
28
|
};
|
|
31
|
-
|
|
32
|
-
container
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
formGroup = _getAllByTestId2[0],
|
|
36
|
-
input = _getAllByTestId2[1];
|
|
29
|
+
const {
|
|
30
|
+
container
|
|
31
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
32
|
+
const [formGroup, input] = (0, _react.getAllByTestId)(container, ID);
|
|
37
33
|
expect(formGroup.tagName).toEqual('DIV');
|
|
38
34
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
39
|
-
|
|
40
|
-
formGroup.childNodes.forEach(
|
|
35
|
+
let label;
|
|
36
|
+
formGroup.childNodes.forEach(node => {
|
|
41
37
|
// Check if it's an element.
|
|
42
38
|
if (node instanceof Element && node.tagName === 'LABEL') {
|
|
43
39
|
label = node;
|
|
@@ -48,12 +44,12 @@ describe('utils.Component.get', function () {
|
|
|
48
44
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
49
45
|
expect(input.tagName).toEqual('INPUT');
|
|
50
46
|
expect(input.classList).toContain('hods-file-upload__select');
|
|
51
|
-
expect(input.id).toEqual(
|
|
52
|
-
|
|
47
|
+
expect(input.id).toEqual(`${ID}-select`);
|
|
48
|
+
const str = JSON.stringify({
|
|
53
49
|
alpha: 'bravo'
|
|
54
50
|
});
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
const blob = new Blob([str]);
|
|
52
|
+
const FILE = new File([blob], 'test.json', {
|
|
57
53
|
type: 'application/JSON'
|
|
58
54
|
});
|
|
59
55
|
_userEvent.default.upload(input, FILE);
|
|
@@ -3,27 +3,28 @@
|
|
|
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 heading component',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered heading component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const SIZE = 'm';
|
|
15
|
+
const CONTENT = 'Heading text';
|
|
16
|
+
const COMPONENT = {
|
|
17
17
|
type: _models.ComponentTypes.HEADING,
|
|
18
18
|
size: SIZE,
|
|
19
19
|
content: CONTENT,
|
|
20
20
|
'data-testid': ID
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
container
|
|
24
|
-
|
|
22
|
+
const {
|
|
23
|
+
container
|
|
24
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
25
|
+
const heading = (0, _react.getByTestId)(container, ID);
|
|
25
26
|
expect(heading.innerHTML).toContain(CONTENT);
|
|
26
27
|
expect(heading.tagName).toEqual('H2');
|
|
27
|
-
expect(heading.classList).toContain(
|
|
28
|
+
expect(heading.classList).toContain(`govuk-heading-${SIZE}`);
|
|
28
29
|
});
|
|
29
30
|
});
|
|
@@ -3,37 +3,39 @@
|
|
|
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 a p tag by default for an HTML component',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return a p tag by default for an HTML component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const CONTENT = 'HTML content';
|
|
15
|
+
const COMPONENT = {
|
|
16
16
|
type: _models.ComponentTypes.HTML,
|
|
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 p = (0, _react.getByTestId)(container, ID);
|
|
23
24
|
expect(p.innerHTML).toContain(CONTENT);
|
|
24
25
|
expect(p.tagName).toEqual('P');
|
|
25
26
|
});
|
|
26
|
-
it('should return an appropriate tag for an HTML component',
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
it('should return an appropriate tag for an HTML component', () => {
|
|
28
|
+
const ID = 'test-id';
|
|
29
|
+
const TAG_NAME = 'hr';
|
|
30
|
+
const COMPONENT = {
|
|
30
31
|
type: _models.ComponentTypes.HTML,
|
|
31
32
|
tagName: TAG_NAME,
|
|
32
33
|
'data-testid': ID
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
-
container
|
|
36
|
-
|
|
35
|
+
const {
|
|
36
|
+
container
|
|
37
|
+
} = (0, _react.render)((0, _getComponent.default)(COMPONENT));
|
|
38
|
+
const hr = (0, _react.getByTestId)(container, ID);
|
|
37
39
|
expect(hr.tagName).toEqual('HR');
|
|
38
40
|
});
|
|
39
41
|
});
|
|
@@ -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 inset-text component',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
describe('utils.Component.get', () => {
|
|
12
|
+
it('should return an appropriately rendered inset-text component', () => {
|
|
13
|
+
const ID = 'test-id';
|
|
14
|
+
const CONTENT = 'Inset text';
|
|
15
|
+
const COMPONENT = {
|
|
16
16
|
type: _models.ComponentTypes.INSET_TEXT,
|
|
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 insetText = (0, _react.getByTestId)(container, ID);
|
|
23
24
|
expect(insetText.innerHTML).toContain(CONTENT);
|
|
24
25
|
expect(insetText.tagName).toEqual('DIV');
|
|
25
26
|
expect(insetText.classList).toContain('govuk-inset-text');
|