@ukhomeoffice/cop-react-form-renderer 5.90.0 → 5.90.1
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 +132 -181
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +106 -142
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +563 -941
- package/dist/components/CheckYourAnswers/index.js +1 -1
- package/dist/components/CollectionPage/CollectionPage.js +76 -66
- package/dist/components/CollectionPage/CollectionPage.test.js +318 -369
- package/dist/components/CollectionPage/index.js +1 -1
- package/dist/components/CollectionSummary/BannerStrip.js +15 -15
- package/dist/components/CollectionSummary/BannerStrip.test.js +83 -79
- package/dist/components/CollectionSummary/CollectionSummary.js +109 -131
- package/dist/components/CollectionSummary/CollectionSummary.test.js +198 -180
- package/dist/components/CollectionSummary/Confirmation.js +15 -13
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +47 -55
- package/dist/components/CollectionSummary/RenderListView.test.js +82 -81
- package/dist/components/CollectionSummary/SummaryCard.js +121 -157
- package/dist/components/CollectionSummary/SummaryCard.test.js +970 -1000
- package/dist/components/CollectionSummary/SummaryCardDetails.js +103 -94
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +187 -195
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +64 -76
- package/dist/components/CollectionSummary/index.js +1 -1
- package/dist/components/FormComponent/Collection.js +81 -117
- package/dist/components/FormComponent/Collection.test.js +910 -1082
- package/dist/components/FormComponent/Container.js +43 -38
- package/dist/components/FormComponent/Container.test.js +379 -411
- package/dist/components/FormComponent/FormComponent.js +71 -74
- package/dist/components/FormComponent/FormComponent.test.js +354 -415
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- 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 +1 -1
- package/dist/components/FormPage/FormPage.js +71 -87
- package/dist/components/FormPage/FormPage.test.js +133 -170
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +153 -198
- package/dist/components/FormRenderer/FormRenderer.test.js +731 -1116
- package/dist/components/FormRenderer/handlers/cyaAction.js +3 -3
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- 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 +2 -2
- package/dist/components/FormRenderer/handlers/navigate.js +4 -4
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +16 -16
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +27 -30
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
- package/dist/components/FormRenderer/helpers/getCYA.js +5 -7
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +6 -8
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +18 -32
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +8 -11
- 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 +104 -98
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +65 -64
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +72 -79
- package/dist/components/FormRenderer/helpers/index.js +2 -2
- package/dist/components/FormRenderer/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +61 -54
- package/dist/components/FormRenderer/onCYAAction.test.js +165 -153
- package/dist/components/FormRenderer/onPageAction.js +45 -41
- package/dist/components/FormRenderer/onPageAction.test.js +225 -210
- package/dist/components/FormRenderer/onTaskAction.js +11 -15
- package/dist/components/FormRenderer/onTaskAction.test.js +94 -89
- package/dist/components/PageActions/ActionButton.js +13 -16
- package/dist/components/PageActions/ActionButton.test.js +57 -79
- package/dist/components/PageActions/PageActions.js +11 -11
- package/dist/components/PageActions/PageActions.test.js +87 -116
- package/dist/components/PageActions/index.js +1 -1
- package/dist/components/SummaryList/GroupAction.js +13 -21
- package/dist/components/SummaryList/GroupAction.test.js +41 -37
- package/dist/components/SummaryList/RowAction.js +12 -17
- package/dist/components/SummaryList/RowAction.test.js +41 -37
- package/dist/components/SummaryList/SummaryList.js +23 -28
- package/dist/components/SummaryList/SummaryList.test.js +179 -206
- package/dist/components/SummaryList/SummaryListHeadingRow.js +8 -6
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
- package/dist/components/SummaryList/SummaryListRow.js +8 -6
- package/dist/components/SummaryList/SummaryListTitleRow.js +7 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +4 -6
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +4 -6
- 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 +1 -1
- package/dist/components/TaskList/Task.js +20 -30
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +53 -84
- package/dist/components/TaskList/TaskList.test.js +150 -150
- package/dist/components/TaskList/TaskState.js +8 -6
- package/dist/components/TaskList/TaskState.test.js +56 -49
- package/dist/components/TaskList/index.js +1 -1
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +58 -81
- package/dist/context/HooksContext/HooksContext.test.js +27 -36
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +44 -95
- package/dist/context/ValidationContext/ValidationContext.test.js +58 -70
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +15 -41
- package/dist/hooks/useGetRequest.js +62 -98
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +28 -41
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +14 -15
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +44 -38
- package/dist/models/TaskStates.js +29 -28
- package/dist/models/index.js +10 -10
- package/dist/setupTests.js +31 -32
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +17 -27
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +34 -36
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +20 -34
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +43 -45
- package/dist/utils/CheckYourAnswers/getCYARow.js +8 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -25
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +39 -45
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +72 -75
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +100 -105
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +218 -182
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +26 -21
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +15 -21
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +77 -83
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +13 -13
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +14 -19
- package/dist/utils/CheckYourAnswers/index.js +2 -2
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +6 -6
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +3 -3
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +21 -22
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +15 -24
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +52 -43
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +3 -3
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -12
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -13
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
- package/dist/utils/CollectionPage/getErrorsForCollection.js +25 -26
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
- package/dist/utils/CollectionPage/getQuickEditPage.js +37 -32
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +18 -22
- package/dist/utils/CollectionPage/index.js +2 -2
- package/dist/utils/CollectionPage/mergeCollectionPages.js +37 -42
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +26 -22
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
- package/dist/utils/CollectionPage/setCollectionPageData.js +13 -19
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +26 -26
- package/dist/utils/Component/addShowWhen.js +4 -8
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +19 -20
- package/dist/utils/Component/applyToComponentTree.test.js +28 -33
- package/dist/utils/Component/cleanAttributes.js +10 -13
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +6 -7
- package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
- package/dist/utils/Component/getComponent.js +90 -97
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +50 -63
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +30 -40
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +22 -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 +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +58 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +34 -41
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +23 -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 +13 -13
- package/dist/utils/Component/getDefaultValueFromConfig.js +24 -24
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +32 -32
- package/dist/utils/Component/index.js +2 -2
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -4
- package/dist/utils/Component/optionIsSelected.test.js +12 -12
- package/dist/utils/Component/setupContainerComponentsPath.js +29 -31
- package/dist/utils/Component/setupContainerComponentsPath.test.js +16 -16
- package/dist/utils/Component/showComponent.js +3 -4
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +4 -4
- package/dist/utils/Condition/index.js +2 -2
- package/dist/utils/Condition/meetsAllConditions.js +9 -9
- package/dist/utils/Condition/meetsAllConditions.test.js +21 -21
- package/dist/utils/Condition/meetsCondition.js +20 -31
- package/dist/utils/Condition/meetsCondition.test.js +403 -403
- package/dist/utils/Condition/meetsOneCondition.js +6 -6
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +14 -19
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +4 -6
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +2 -2
- package/dist/utils/Container/setupNesting.js +16 -22
- package/dist/utils/Container/setupNesting.test.js +28 -31
- package/dist/utils/Container/showContainer.js +4 -8
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +40 -50
- package/dist/utils/Data/applyFormula.test.js +26 -26
- package/dist/utils/Data/deleteValues.js +4 -8
- package/dist/utils/Data/deleteValues.test.js +11 -11
- package/dist/utils/Data/getAutocompleteSource.js +20 -29
- package/dist/utils/Data/getAutocompleteSource.test.js +81 -87
- package/dist/utils/Data/getDataPath.js +20 -30
- package/dist/utils/Data/getDataPath.test.js +20 -20
- package/dist/utils/Data/getOptions.js +27 -34
- package/dist/utils/Data/getOptions.test.js +28 -28
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +2 -2
- package/dist/utils/Data/nestInRefdataOptions.js +9 -16
- package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
- package/dist/utils/Data/refDataToOptions.js +11 -15
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +14 -22
- package/dist/utils/Data/setupFormData.test.js +52 -51
- package/dist/utils/Data/setupRefDataUrlForComponent.js +21 -28
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +28 -28
- package/dist/utils/FormPage/applyConditionalProperties.js +6 -10
- package/dist/utils/FormPage/applyConditionalProperties.test.js +16 -19
- package/dist/utils/FormPage/getConditionalText.js +4 -4
- package/dist/utils/FormPage/getConditionalText.test.js +35 -35
- package/dist/utils/FormPage/getFormPage.js +16 -17
- package/dist/utils/FormPage/getFormPage.test.js +49 -48
- package/dist/utils/FormPage/getFormPages.js +8 -13
- package/dist/utils/FormPage/getFormPages.test.js +22 -25
- package/dist/utils/FormPage/getPageActions.js +10 -17
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -5
- package/dist/utils/FormPage/showFormPage.js +4 -8
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +3 -3
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +21 -28
- package/dist/utils/FormPage/useComponent.test.js +78 -80
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -7
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +2 -2
- package/dist/utils/Hub/getFormHub.js +2 -2
- package/dist/utils/Hub/getFormHub.test.js +29 -32
- package/dist/utils/Hub/index.js +2 -2
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +15 -17
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +69 -35
- package/dist/utils/Meta/index.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.js +4 -4
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/deleteValueInFormData.js +3 -3
- package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
- package/dist/utils/Operate/getFirstOf.js +8 -8
- package/dist/utils/Operate/getFirstOf.test.js +33 -33
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +12 -12
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/getLength.js +11 -11
- package/dist/utils/Operate/getLength.test.js +19 -19
- package/dist/utils/Operate/index.js +2 -2
- package/dist/utils/Operate/persistValueInFormData.js +6 -6
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +9 -9
- package/dist/utils/Operate/runPageOperations.test.js +36 -37
- package/dist/utils/Operate/setValueInFormData.js +5 -5
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +8 -8
- package/dist/utils/Operate/shouldRun.test.js +22 -28
- package/dist/utils/Validate/additional/conditionallyPermittedChange.js +1 -1
- package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +15 -15
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -5
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -8
- package/dist/utils/Validate/additional/index.test.js +22 -22
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -3
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -3
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +9 -14
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +38 -42
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +4 -4
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -5
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeOneOf.js +1 -1
- package/dist/utils/Validate/additional/mustBeOneOf.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +5 -5
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +36 -40
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +3 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +15 -15
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +3 -5
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +11 -24
- package/dist/utils/Validate/index.js +2 -2
- package/dist/utils/Validate/validateCollection.js +21 -27
- package/dist/utils/Validate/validateCollection.test.js +85 -77
- package/dist/utils/Validate/validateComponent.js +22 -23
- package/dist/utils/Validate/validateComponent.test.js +188 -165
- package/dist/utils/Validate/validateContainer.js +16 -21
- package/dist/utils/Validate/validateContainer.test.js +62 -56
- package/dist/utils/Validate/validateDate.js +17 -23
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +7 -9
- package/dist/utils/Validate/validateEmail.test.js +26 -26
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +20 -24
- package/dist/utils/Validate/validatePage.test.js +227 -215
- package/dist/utils/Validate/validateRegex.js +5 -8
- package/dist/utils/Validate/validateRegex.test.js +17 -17
- package/dist/utils/Validate/validateRequired.js +5 -7
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +5 -7
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +12 -19
- package/dist/utils/Validate/validateTime.test.js +27 -27
- package/dist/utils/index.js +8 -10
- package/package.json +3 -2
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getCYARowsForCollectionPage = _interopRequireDefault(require("./getCYARowsForCollectionPage"));
|
|
4
|
-
function _interopRequireDefault(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
|
|
11
|
-
describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
12
|
-
var TEXT_COMP = {
|
|
4
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
5
|
+
// Local imports
|
|
6
|
+
|
|
7
|
+
describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
8
|
+
const TEXT_COMP = {
|
|
13
9
|
id: 'testText',
|
|
14
10
|
fieldId: 'testText',
|
|
15
11
|
label: 'Test text',
|
|
16
12
|
type: 'text'
|
|
17
13
|
};
|
|
18
|
-
|
|
14
|
+
const DATE_COMP = {
|
|
19
15
|
id: 'testDate',
|
|
20
16
|
fieldId: 'testDate',
|
|
21
17
|
label: 'Test date',
|
|
22
18
|
type: 'date'
|
|
23
19
|
};
|
|
24
|
-
|
|
20
|
+
const PAGES = [{
|
|
25
21
|
id: 'page1',
|
|
26
22
|
collection: {
|
|
27
23
|
name: 'collection'
|
|
@@ -34,7 +30,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
34
30
|
},
|
|
35
31
|
components: [DATE_COMP]
|
|
36
32
|
}];
|
|
37
|
-
|
|
33
|
+
const MASTER_PAGE = {
|
|
38
34
|
id: 'page1',
|
|
39
35
|
collection: {
|
|
40
36
|
name: 'collection',
|
|
@@ -55,112 +51,121 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
55
51
|
},
|
|
56
52
|
childPages: PAGES
|
|
57
53
|
};
|
|
58
|
-
it('should return no rows for a collection if it does not exist in formData',
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
it('should return no rows for a collection if it does not exist in formData', () => {
|
|
55
|
+
const FORM_DATA = {};
|
|
56
|
+
const PAGE = {
|
|
57
|
+
...MASTER_PAGE,
|
|
61
58
|
formData: FORM_DATA
|
|
62
|
-
}
|
|
63
|
-
|
|
59
|
+
};
|
|
60
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
64
61
|
expect(ROWS.length).toEqual(0);
|
|
65
62
|
});
|
|
66
|
-
it('should return no rows for a collection if it has no entries',
|
|
67
|
-
|
|
63
|
+
it('should return no rows for a collection if it has no entries', () => {
|
|
64
|
+
const FORM_DATA = {
|
|
68
65
|
collection: []
|
|
69
66
|
};
|
|
70
|
-
|
|
67
|
+
const PAGE = {
|
|
68
|
+
...MASTER_PAGE,
|
|
71
69
|
formData: FORM_DATA
|
|
72
|
-
}
|
|
73
|
-
|
|
70
|
+
};
|
|
71
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
74
72
|
expect(ROWS.length).toEqual(0);
|
|
75
73
|
});
|
|
76
|
-
it('should accept the hideNameFromCYA collection flag',
|
|
77
|
-
|
|
74
|
+
it('should accept the hideNameFromCYA collection flag', () => {
|
|
75
|
+
const FORM_DATA = {
|
|
78
76
|
collection: [{
|
|
79
77
|
testText: 'hello'
|
|
80
78
|
}]
|
|
81
79
|
};
|
|
82
|
-
|
|
80
|
+
const PAGE = {
|
|
81
|
+
...MASTER_PAGE,
|
|
83
82
|
formData: FORM_DATA,
|
|
84
|
-
collection:
|
|
83
|
+
collection: {
|
|
84
|
+
...MASTER_PAGE.collection,
|
|
85
85
|
hideNameFromCYA: true
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const TITLE_FIELD_ID = `${PAGE.collection.name}Title`;
|
|
89
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
90
90
|
expect(ROWS[0].fieldId).not.toEqual(TITLE_FIELD_ID);
|
|
91
91
|
});
|
|
92
|
-
it('should format titles correctly when collection.labels.item is specified',
|
|
93
|
-
|
|
92
|
+
it('should format titles correctly when collection.labels.item is specified', () => {
|
|
93
|
+
const FORM_DATA = {
|
|
94
94
|
collection: [{
|
|
95
95
|
id: '01',
|
|
96
96
|
testText: 'value'
|
|
97
97
|
}]
|
|
98
98
|
};
|
|
99
|
-
|
|
99
|
+
const PAGE = {
|
|
100
|
+
...MASTER_PAGE,
|
|
100
101
|
formData: FORM_DATA
|
|
101
|
-
}
|
|
102
|
-
|
|
102
|
+
};
|
|
103
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
103
104
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
104
105
|
expect(ROWS[1].key).toEqual('Collection entry 1');
|
|
105
106
|
});
|
|
106
|
-
it('should hide titles when hideItemTitles is true',
|
|
107
|
-
|
|
107
|
+
it('should hide titles when hideItemTitles is true', () => {
|
|
108
|
+
const FORM_DATA = {
|
|
108
109
|
collection: [{
|
|
109
110
|
id: '01',
|
|
110
111
|
testText: 'value'
|
|
111
112
|
}]
|
|
112
113
|
};
|
|
113
|
-
|
|
114
|
+
const PAGE = {
|
|
115
|
+
...MASTER_PAGE,
|
|
114
116
|
formData: FORM_DATA,
|
|
115
|
-
collection:
|
|
117
|
+
collection: {
|
|
118
|
+
...MASTER_PAGE.collection,
|
|
116
119
|
hideItemTitles: true
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
120
123
|
expect(ROWS.length).toEqual(6); // Collection title, NO item title, action rows & component rows
|
|
121
124
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
var FORM_DATA = {
|
|
125
|
+
it('should hide titles when hideItemTitles is a show_when that is true', () => {
|
|
126
|
+
const FORM_DATA = {
|
|
125
127
|
shouldShow: false,
|
|
126
128
|
collection: [{
|
|
127
129
|
id: '01',
|
|
128
130
|
testText: 'value'
|
|
129
131
|
}]
|
|
130
132
|
};
|
|
131
|
-
|
|
133
|
+
const PAGE = {
|
|
134
|
+
...MASTER_PAGE,
|
|
132
135
|
formData: FORM_DATA,
|
|
133
|
-
collection:
|
|
136
|
+
collection: {
|
|
137
|
+
...MASTER_PAGE.collection,
|
|
134
138
|
hideItemTitles: [{
|
|
135
139
|
field: 'shouldShow',
|
|
136
140
|
op: '=',
|
|
137
141
|
value: false
|
|
138
142
|
}]
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
142
146
|
expect(ROWS.length).toEqual(6); // Collection title, NO item title, action rows & component rows
|
|
143
147
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
var FORM_DATA = {
|
|
148
|
+
it('should provide default titles if collection.labels.item is not specified', () => {
|
|
149
|
+
const FORM_DATA = {
|
|
147
150
|
collection: [{
|
|
148
151
|
id: '01',
|
|
149
152
|
testText: 'value'
|
|
150
153
|
}]
|
|
151
154
|
};
|
|
152
|
-
|
|
153
|
-
|
|
155
|
+
const PAGE = {
|
|
156
|
+
...MASTER_PAGE,
|
|
157
|
+
collection: {
|
|
158
|
+
...MASTER_PAGE.collection,
|
|
154
159
|
labels: {}
|
|
155
|
-
}
|
|
160
|
+
},
|
|
156
161
|
formData: FORM_DATA
|
|
157
|
-
}
|
|
158
|
-
|
|
162
|
+
};
|
|
163
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
159
164
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
160
165
|
expect(ROWS[1].key).toEqual('Item 1');
|
|
161
166
|
});
|
|
162
|
-
it('should return correctly formatted rows for mutliple entries',
|
|
163
|
-
|
|
167
|
+
it('should return correctly formatted rows for mutliple entries', () => {
|
|
168
|
+
const FORM_DATA = {
|
|
164
169
|
collection: [{
|
|
165
170
|
id: '01',
|
|
166
171
|
testText: 'value'
|
|
@@ -169,10 +174,11 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
169
174
|
testText: 'value'
|
|
170
175
|
}]
|
|
171
176
|
};
|
|
172
|
-
|
|
177
|
+
const PAGE = {
|
|
178
|
+
...MASTER_PAGE,
|
|
173
179
|
formData: FORM_DATA
|
|
174
|
-
}
|
|
175
|
-
|
|
180
|
+
};
|
|
181
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
176
182
|
expect(ROWS.length).toEqual(13); // Title row + component row for each item
|
|
177
183
|
expect(ROWS[0]).toMatchObject({
|
|
178
184
|
type: 'heading',
|
|
@@ -209,20 +215,22 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
209
215
|
key: 'Test date'
|
|
210
216
|
});
|
|
211
217
|
});
|
|
212
|
-
it('should use values from top-level formData if they don\'t exist in the item',
|
|
213
|
-
|
|
218
|
+
it('should use values from top-level formData if they don\'t exist in the item', () => {
|
|
219
|
+
const FORM_DATA = {
|
|
214
220
|
testText: 'value',
|
|
215
221
|
collection: [{
|
|
216
222
|
id: '01'
|
|
217
223
|
}]
|
|
218
224
|
};
|
|
219
|
-
|
|
220
|
-
|
|
225
|
+
const PAGE = {
|
|
226
|
+
...MASTER_PAGE,
|
|
227
|
+
childPages: [{
|
|
228
|
+
...PAGES[0],
|
|
221
229
|
formData: FORM_DATA
|
|
222
|
-
}
|
|
230
|
+
}, PAGES[1]],
|
|
223
231
|
formData: FORM_DATA
|
|
224
|
-
}
|
|
225
|
-
|
|
232
|
+
};
|
|
233
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
226
234
|
expect(ROWS.length).toEqual(7); // Title row + component row for each item
|
|
227
235
|
expect(ROWS[0]).toMatchObject({
|
|
228
236
|
type: 'heading',
|
|
@@ -244,8 +252,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
244
252
|
key: 'Test date'
|
|
245
253
|
});
|
|
246
254
|
});
|
|
247
|
-
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined',
|
|
248
|
-
|
|
255
|
+
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined', () => {
|
|
256
|
+
const FORM_DATA = {
|
|
249
257
|
collectionActiveId: '02',
|
|
250
258
|
collection: [{
|
|
251
259
|
id: '01',
|
|
@@ -255,13 +263,15 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
255
263
|
testText: 'value'
|
|
256
264
|
}]
|
|
257
265
|
};
|
|
258
|
-
|
|
259
|
-
|
|
266
|
+
const PAGE = {
|
|
267
|
+
...MASTER_PAGE,
|
|
268
|
+
collection: {
|
|
269
|
+
...MASTER_PAGE.collection,
|
|
260
270
|
onlyShowActiveEntryOnCYA: true
|
|
261
|
-
}
|
|
271
|
+
},
|
|
262
272
|
formData: FORM_DATA
|
|
263
|
-
}
|
|
264
|
-
|
|
273
|
+
};
|
|
274
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
265
275
|
expect(ROWS.length).toEqual(7); // Title row + component row for only the active item.
|
|
266
276
|
expect(ROWS[0]).toMatchObject({
|
|
267
277
|
type: 'heading',
|
|
@@ -283,8 +293,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
283
293
|
key: 'Test date'
|
|
284
294
|
});
|
|
285
295
|
});
|
|
286
|
-
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is an array',
|
|
287
|
-
|
|
296
|
+
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is an array', () => {
|
|
297
|
+
const FORM_DATA = {
|
|
288
298
|
text: 'blue',
|
|
289
299
|
collectionActiveId: '02',
|
|
290
300
|
collection: [{
|
|
@@ -295,17 +305,19 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
295
305
|
testText: 'value'
|
|
296
306
|
}]
|
|
297
307
|
};
|
|
298
|
-
|
|
299
|
-
|
|
308
|
+
const PAGE = {
|
|
309
|
+
...MASTER_PAGE,
|
|
310
|
+
collection: {
|
|
311
|
+
...MASTER_PAGE.collection,
|
|
300
312
|
onlyShowActiveEntryOnCYA: [{
|
|
301
313
|
field: 'text',
|
|
302
314
|
op: 'eq',
|
|
303
315
|
value: 'blue'
|
|
304
316
|
}]
|
|
305
|
-
}
|
|
317
|
+
},
|
|
306
318
|
formData: FORM_DATA
|
|
307
|
-
}
|
|
308
|
-
|
|
319
|
+
};
|
|
320
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
309
321
|
expect(ROWS.length).toEqual(7); // Title row + component row for only the active item.
|
|
310
322
|
expect(ROWS[0]).toMatchObject({
|
|
311
323
|
type: 'heading',
|
|
@@ -327,8 +339,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
327
339
|
key: 'Test date'
|
|
328
340
|
});
|
|
329
341
|
});
|
|
330
|
-
it('should exclude components that should not be shown',
|
|
331
|
-
|
|
342
|
+
it('should exclude components that should not be shown', () => {
|
|
343
|
+
const FD = {
|
|
332
344
|
collection: [{
|
|
333
345
|
id: '01',
|
|
334
346
|
otherField: 'yes',
|
|
@@ -339,12 +351,14 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
339
351
|
testText: 'testing'
|
|
340
352
|
}]
|
|
341
353
|
};
|
|
342
|
-
|
|
354
|
+
const PAGE = {
|
|
355
|
+
...MASTER_PAGE,
|
|
343
356
|
collection: {
|
|
344
357
|
name: 'collection'
|
|
345
358
|
},
|
|
346
359
|
formData: FD,
|
|
347
|
-
childPages: [
|
|
360
|
+
childPages: [{
|
|
361
|
+
...PAGES[0],
|
|
348
362
|
components: [{
|
|
349
363
|
id: 'testText',
|
|
350
364
|
fieldId: 'testText',
|
|
@@ -356,9 +370,9 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
356
370
|
value: "yes"
|
|
357
371
|
}
|
|
358
372
|
}]
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
373
|
+
}]
|
|
374
|
+
};
|
|
375
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
|
|
362
376
|
expect(ROWS.length).toEqual(4);
|
|
363
377
|
expect(ROWS[0]).toMatchObject({
|
|
364
378
|
type: 'heading',
|
|
@@ -377,28 +391,30 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
377
391
|
key: 'Test text'
|
|
378
392
|
});
|
|
379
393
|
});
|
|
380
|
-
it('should exclude pages that should not be shown',
|
|
381
|
-
|
|
394
|
+
it('should exclude pages that should not be shown', () => {
|
|
395
|
+
const FD = {
|
|
382
396
|
collection: [{
|
|
383
397
|
id: '01',
|
|
384
398
|
otherField: 'yes',
|
|
385
399
|
testText: 'testing'
|
|
386
400
|
}]
|
|
387
401
|
};
|
|
388
|
-
|
|
402
|
+
const PAGE = {
|
|
403
|
+
...MASTER_PAGE,
|
|
389
404
|
collection: {
|
|
390
405
|
name: 'collection'
|
|
391
406
|
},
|
|
392
407
|
formData: FD,
|
|
393
|
-
childPages: [
|
|
408
|
+
childPages: [{
|
|
409
|
+
...PAGES[0],
|
|
394
410
|
show_when: {
|
|
395
411
|
field: "otherField",
|
|
396
412
|
op: "!=",
|
|
397
413
|
value: "yes"
|
|
398
414
|
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
415
|
+
}, PAGES[1]]
|
|
416
|
+
};
|
|
417
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
|
|
402
418
|
expect(ROWS.length).toEqual(3); // Missing the page with the text component on.
|
|
403
419
|
expect(ROWS[0]).toMatchObject({
|
|
404
420
|
type: 'heading',
|
|
@@ -413,25 +429,28 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
413
429
|
key: 'Test date'
|
|
414
430
|
});
|
|
415
431
|
});
|
|
416
|
-
it('should include rows for custom headings',
|
|
417
|
-
|
|
432
|
+
it('should include rows for custom headings', () => {
|
|
433
|
+
const FORM_DATA = {
|
|
418
434
|
collection: [{
|
|
419
435
|
id: '01',
|
|
420
436
|
testText: 'value'
|
|
421
437
|
}]
|
|
422
438
|
};
|
|
423
|
-
|
|
439
|
+
const PAGE = {
|
|
440
|
+
...MASTER_PAGE,
|
|
424
441
|
formData: FORM_DATA,
|
|
425
|
-
childPages: [
|
|
426
|
-
|
|
442
|
+
childPages: [{
|
|
443
|
+
...PAGES[0],
|
|
444
|
+
collection: {
|
|
445
|
+
...PAGES[0].collection,
|
|
427
446
|
heading: {
|
|
428
447
|
size: 'm',
|
|
429
448
|
text: 'Custom page heading'
|
|
430
449
|
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
450
|
+
}
|
|
451
|
+
}]
|
|
452
|
+
};
|
|
453
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
435
454
|
expect(ROWS.length).toEqual(7);
|
|
436
455
|
expect(ROWS[0]).toMatchObject({
|
|
437
456
|
type: 'heading',
|
|
@@ -454,26 +473,29 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
454
473
|
key: 'Test text'
|
|
455
474
|
});
|
|
456
475
|
});
|
|
457
|
-
it('should allow interpolation of custom headings',
|
|
458
|
-
|
|
476
|
+
it('should allow interpolation of custom headings', () => {
|
|
477
|
+
const FORM_DATA = {
|
|
459
478
|
collection: [{
|
|
460
479
|
id: '01',
|
|
461
480
|
testText: 'value'
|
|
462
481
|
}]
|
|
463
482
|
};
|
|
464
|
-
|
|
483
|
+
const PAGE = {
|
|
484
|
+
...MASTER_PAGE,
|
|
465
485
|
formData: FORM_DATA,
|
|
466
|
-
childPages: [
|
|
467
|
-
|
|
486
|
+
childPages: [{
|
|
487
|
+
...PAGES[0],
|
|
488
|
+
collection: {
|
|
489
|
+
...PAGES[0].collection,
|
|
468
490
|
// eslint-disable-next-line no-template-curly-in-string
|
|
469
491
|
heading: {
|
|
470
492
|
size: 'm',
|
|
471
493
|
text: 'interpolated text: ${testText}'
|
|
472
494
|
}
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
495
|
+
}
|
|
496
|
+
}]
|
|
497
|
+
};
|
|
498
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
477
499
|
expect(ROWS.length).toEqual(7);
|
|
478
500
|
expect(ROWS[0]).toMatchObject({
|
|
479
501
|
type: 'heading',
|
|
@@ -496,126 +518,138 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
496
518
|
key: 'Test text'
|
|
497
519
|
});
|
|
498
520
|
});
|
|
499
|
-
it('should alow configuration of collection name headings',
|
|
500
|
-
|
|
521
|
+
it('should alow configuration of collection name headings', () => {
|
|
522
|
+
const FORM_DATA = {
|
|
501
523
|
collection: [{
|
|
502
524
|
id: '01',
|
|
503
525
|
testText: 'value'
|
|
504
526
|
}]
|
|
505
527
|
};
|
|
506
|
-
|
|
528
|
+
const PAGE = {
|
|
529
|
+
...MASTER_PAGE,
|
|
507
530
|
formData: FORM_DATA,
|
|
508
|
-
collection:
|
|
531
|
+
collection: {
|
|
532
|
+
...MASTER_PAGE.collection,
|
|
509
533
|
collectionHeading: {
|
|
510
534
|
text: 'Custom collection heading',
|
|
511
535
|
size: 'm',
|
|
512
536
|
changeLinkPage: PAGES[0].id
|
|
513
537
|
}
|
|
514
|
-
}
|
|
515
|
-
childPages: [
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
538
|
+
},
|
|
539
|
+
childPages: [{
|
|
540
|
+
...PAGES[0],
|
|
541
|
+
collection: {
|
|
542
|
+
...PAGES[0].collection
|
|
543
|
+
}
|
|
544
|
+
}]
|
|
545
|
+
};
|
|
546
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
520
547
|
expect(ROWS.length).toEqual(6);
|
|
521
548
|
expect(ROWS[0]).toMatchObject({
|
|
522
549
|
type: 'headingWithAction',
|
|
523
550
|
key: 'Custom collection heading'
|
|
524
551
|
});
|
|
525
552
|
});
|
|
526
|
-
it('should default to a title size of small if one is not specified',
|
|
527
|
-
|
|
553
|
+
it('should default to a title size of small if one is not specified', () => {
|
|
554
|
+
const FORM_DATA = {
|
|
528
555
|
collection: [{
|
|
529
556
|
id: '01',
|
|
530
557
|
testText: 'value'
|
|
531
558
|
}]
|
|
532
559
|
};
|
|
533
|
-
|
|
560
|
+
const PAGE = {
|
|
561
|
+
...MASTER_PAGE,
|
|
534
562
|
formData: FORM_DATA,
|
|
535
|
-
childPages: [
|
|
536
|
-
|
|
563
|
+
childPages: [{
|
|
564
|
+
...PAGES[0],
|
|
565
|
+
collection: {
|
|
566
|
+
...PAGES[0].collection,
|
|
537
567
|
heading: {
|
|
538
568
|
text: 'Custom page heading'
|
|
539
569
|
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
570
|
+
}
|
|
571
|
+
}]
|
|
572
|
+
};
|
|
573
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
544
574
|
expect(ROWS[5]).toMatchObject({
|
|
545
575
|
type: 'heading',
|
|
546
576
|
key: 'Custom page heading',
|
|
547
577
|
size: 's'
|
|
548
578
|
});
|
|
549
579
|
});
|
|
550
|
-
it('should position actions under the title if actionPosition flag is not specified',
|
|
551
|
-
|
|
580
|
+
it('should position actions under the title if actionPosition flag is not specified', () => {
|
|
581
|
+
const FORM_DATA = {
|
|
552
582
|
collection: [{
|
|
553
583
|
id: '01',
|
|
554
584
|
testText: 'value'
|
|
555
585
|
}]
|
|
556
586
|
};
|
|
557
|
-
|
|
587
|
+
const PAGE = {
|
|
588
|
+
...MASTER_PAGE,
|
|
558
589
|
formData: FORM_DATA
|
|
559
|
-
}
|
|
560
|
-
|
|
590
|
+
};
|
|
591
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
561
592
|
expect(ROWS[2].action.label).toEqual('Change');
|
|
562
593
|
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
563
594
|
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
564
595
|
});
|
|
565
|
-
it('should position actions under the title if actionPosition flag is top',
|
|
566
|
-
|
|
596
|
+
it('should position actions under the title if actionPosition flag is top', () => {
|
|
597
|
+
const FORM_DATA = {
|
|
567
598
|
collection: [{
|
|
568
599
|
id: '01',
|
|
569
600
|
testText: 'value'
|
|
570
601
|
}]
|
|
571
602
|
};
|
|
572
|
-
|
|
573
|
-
|
|
603
|
+
const PAGE = {
|
|
604
|
+
...MASTER_PAGE,
|
|
605
|
+
collection: {
|
|
606
|
+
...MASTER_PAGE.collection,
|
|
574
607
|
actionPosition: 'top'
|
|
575
|
-
}
|
|
608
|
+
},
|
|
576
609
|
formData: FORM_DATA
|
|
577
|
-
}
|
|
578
|
-
|
|
610
|
+
};
|
|
611
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
579
612
|
expect(ROWS[2].action.label).toEqual('Change');
|
|
580
613
|
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
581
614
|
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
582
615
|
});
|
|
583
|
-
it('should position actions under all other rows if actionPosition flag is bottom',
|
|
584
|
-
|
|
616
|
+
it('should position actions under all other rows if actionPosition flag is bottom', () => {
|
|
617
|
+
const FORM_DATA = {
|
|
585
618
|
collection: [{
|
|
586
619
|
id: '01',
|
|
587
620
|
testText: 'value'
|
|
588
621
|
}]
|
|
589
622
|
};
|
|
590
|
-
|
|
591
|
-
|
|
623
|
+
const PAGE = {
|
|
624
|
+
...MASTER_PAGE,
|
|
625
|
+
collection: {
|
|
626
|
+
...MASTER_PAGE.collection,
|
|
592
627
|
actionPosition: 'bottom'
|
|
593
|
-
}
|
|
628
|
+
},
|
|
594
629
|
formData: FORM_DATA
|
|
595
|
-
}
|
|
596
|
-
|
|
630
|
+
};
|
|
631
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
597
632
|
expect(ROWS[ROWS.length - 3].action.label).toEqual('Change');
|
|
598
633
|
expect(ROWS[ROWS.length - 2].action.label).toEqual('custom remove label');
|
|
599
634
|
expect(ROWS[ROWS.length - 1].action.label).toEqual('custom change label');
|
|
600
635
|
});
|
|
601
|
-
it('should ignore the result of the override function if it returns nullish',
|
|
602
|
-
|
|
636
|
+
it('should ignore the result of the override function if it returns nullish', () => {
|
|
637
|
+
const FORM_DATA = {
|
|
603
638
|
collection: [{
|
|
604
639
|
id: '01',
|
|
605
640
|
testText: 'value'
|
|
606
641
|
}]
|
|
607
642
|
};
|
|
608
|
-
|
|
643
|
+
const PAGE = {
|
|
644
|
+
...MASTER_PAGE,
|
|
609
645
|
formData: FORM_DATA
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
return null;
|
|
613
|
-
}, FORM_DATA);
|
|
646
|
+
};
|
|
647
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, () => null, FORM_DATA);
|
|
614
648
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
615
|
-
expect(ROWS[5].key).toEqual(
|
|
649
|
+
expect(ROWS[5].key).toEqual(`Test text`);
|
|
616
650
|
});
|
|
617
|
-
it('should use the rows produced by the override function if provided',
|
|
618
|
-
|
|
651
|
+
it('should use the rows produced by the override function if provided', () => {
|
|
652
|
+
const FORM_DATA = {
|
|
619
653
|
collection: [{
|
|
620
654
|
id: '01',
|
|
621
655
|
testText: 'value'
|
|
@@ -623,22 +657,23 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
623
657
|
};
|
|
624
658
|
|
|
625
659
|
// eslint-disable-next-line arrow-body-style
|
|
626
|
-
|
|
660
|
+
const OVERRIDE = (page, comp) => {
|
|
627
661
|
// This will be called for each component on the page,
|
|
628
662
|
// returning a custom row object.
|
|
629
663
|
return {
|
|
630
|
-
key:
|
|
664
|
+
key: `CustomRowFor${comp.label}`
|
|
631
665
|
};
|
|
632
666
|
};
|
|
633
|
-
|
|
667
|
+
const PAGE = {
|
|
668
|
+
...MASTER_PAGE,
|
|
634
669
|
formData: FORM_DATA
|
|
635
|
-
}
|
|
636
|
-
|
|
670
|
+
};
|
|
671
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, OVERRIDE, FORM_DATA);
|
|
637
672
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
638
|
-
expect(ROWS[5].key).toEqual(
|
|
673
|
+
expect(ROWS[5].key).toEqual(`CustomRowFor${TEXT_COMP.label}`);
|
|
639
674
|
});
|
|
640
|
-
it('should create rows for nested collections correctly',
|
|
641
|
-
|
|
675
|
+
it('should create rows for nested collections correctly', () => {
|
|
676
|
+
const CUSTOM_FORM_DATA = {
|
|
642
677
|
parentActiveId: '001',
|
|
643
678
|
childActiveId: '001',
|
|
644
679
|
parent: [{
|
|
@@ -650,7 +685,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
650
685
|
}]
|
|
651
686
|
}]
|
|
652
687
|
};
|
|
653
|
-
|
|
688
|
+
const CHILD_MASTER_PAGE = {
|
|
654
689
|
id: 'childPage',
|
|
655
690
|
collection: {
|
|
656
691
|
name: 'parent.child',
|
|
@@ -674,7 +709,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
674
709
|
components: [TEXT_COMP]
|
|
675
710
|
}]
|
|
676
711
|
};
|
|
677
|
-
|
|
712
|
+
const PARENT_MASTER_PAGE = {
|
|
678
713
|
id: 'parentPage',
|
|
679
714
|
collection: {
|
|
680
715
|
name: 'parent',
|
|
@@ -688,10 +723,11 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
688
723
|
components: [TEXT_COMP]
|
|
689
724
|
}, CHILD_MASTER_PAGE]
|
|
690
725
|
};
|
|
691
|
-
|
|
726
|
+
const PAGE = {
|
|
727
|
+
...PARENT_MASTER_PAGE,
|
|
692
728
|
formData: CUSTOM_FORM_DATA
|
|
693
|
-
}
|
|
694
|
-
|
|
729
|
+
};
|
|
730
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, CUSTOM_FORM_DATA);
|
|
695
731
|
expect(ROWS.length).toEqual(8);
|
|
696
732
|
expect(ROWS[0]).toMatchObject({
|
|
697
733
|
type: 'heading',
|
|
@@ -720,8 +756,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
720
756
|
key: 'Test text'
|
|
721
757
|
});
|
|
722
758
|
});
|
|
723
|
-
it('should create rows for the Collection component correctly',
|
|
724
|
-
|
|
759
|
+
it('should create rows for the Collection component correctly', () => {
|
|
760
|
+
const FORM_DATA = {
|
|
725
761
|
collection: [{
|
|
726
762
|
id: '01',
|
|
727
763
|
testCollection: [{
|
|
@@ -730,7 +766,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
730
766
|
otherComp: 'one'
|
|
731
767
|
}]
|
|
732
768
|
};
|
|
733
|
-
|
|
769
|
+
const COLLECTION_COMP = {
|
|
734
770
|
id: 'testCollection',
|
|
735
771
|
fieldId: 'testCollection',
|
|
736
772
|
label: 'Test collection',
|
|
@@ -747,7 +783,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
747
783
|
value: 'one'
|
|
748
784
|
}]
|
|
749
785
|
};
|
|
750
|
-
|
|
786
|
+
const MASTER_PAGE_WITH_COLLECTION = {
|
|
751
787
|
id: 'page1',
|
|
752
788
|
collection: {
|
|
753
789
|
name: 'collection',
|
|
@@ -775,7 +811,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
775
811
|
}],
|
|
776
812
|
formData: FORM_DATA
|
|
777
813
|
};
|
|
778
|
-
|
|
814
|
+
const ROWS = (0, _getCYARowsForCollectionPage.default)(MASTER_PAGE_WITH_COLLECTION, null, null, FORM_DATA);
|
|
779
815
|
expect(ROWS.length).toEqual(7); // Title row + component row for each item
|
|
780
816
|
expect(ROWS[0]).toMatchObject({
|
|
781
817
|
type: 'heading',
|