@ukhomeoffice/cop-react-form-renderer 6.13.2 → 6.14.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/README.md +8 -0
- package/dist/components/CheckYourAnswers/Answer.js +12 -11
- package/dist/components/CheckYourAnswers/Answer.test.js +132 -181
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +98 -133
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +544 -939
- package/dist/components/CheckYourAnswers/index.js +1 -1
- package/dist/components/CollectionPage/CollectionPage.js +62 -60
- package/dist/components/CollectionPage/CollectionPage.test.js +315 -365
- package/dist/components/CollectionPage/index.js +1 -1
- package/dist/components/CollectionSummary/BannerStrip.js +14 -14
- package/dist/components/CollectionSummary/BannerStrip.test.js +79 -74
- package/dist/components/CollectionSummary/CollectionSummary.js +81 -99
- package/dist/components/CollectionSummary/CollectionSummary.test.js +182 -166
- package/dist/components/CollectionSummary/Confirmation.js +15 -13
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +47 -48
- package/dist/components/CollectionSummary/RenderListView.scss +4 -0
- package/dist/components/CollectionSummary/RenderListView.test.js +133 -98
- package/dist/components/CollectionSummary/SummaryCard.js +110 -148
- package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
- package/dist/components/CollectionSummary/SummaryCardButtons.js +71 -0
- package/dist/components/CollectionSummary/SummaryCardButtons.test.js +85 -0
- package/dist/components/CollectionSummary/SummaryCardDetails.js +59 -76
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +170 -180
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +63 -75
- package/dist/components/CollectionSummary/index.js +1 -1
- package/dist/components/FormComponent/Collection.js +67 -102
- package/dist/components/FormComponent/Collection.test.js +907 -1080
- package/dist/components/FormComponent/Container.js +35 -29
- package/dist/components/FormComponent/Container.test.js +378 -409
- package/dist/components/FormComponent/FormComponent.js +59 -63
- 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 +99 -88
- package/dist/components/FormPage/FormPage.test.js +173 -164
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +138 -174
- package/dist/components/FormRenderer/FormRenderer.test.js +732 -1114
- 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 +22 -25
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
- package/dist/components/FormRenderer/helpers/getCYA.js +4 -6
- 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 +14 -25
- 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 +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +6 -6
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +104 -98
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +44 -51
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +68 -74
- package/dist/components/FormRenderer/helpers/index.js +2 -2
- package/dist/components/FormRenderer/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +43 -44
- package/dist/components/FormRenderer/onCYAAction.test.js +126 -133
- package/dist/components/FormRenderer/onPageAction.js +26 -35
- package/dist/components/FormRenderer/onPageAction.test.js +177 -186
- package/dist/components/FormRenderer/onTaskAction.js +11 -12
- package/dist/components/FormRenderer/onTaskAction.test.js +63 -68
- package/dist/components/PageActions/ActionButton.js +14 -14
- 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 +10 -18
- package/dist/components/SummaryList/GroupAction.test.js +38 -34
- package/dist/components/SummaryList/RowAction.js +12 -17
- package/dist/components/SummaryList/RowAction.test.js +38 -34
- package/dist/components/SummaryList/SummaryList.js +23 -25
- package/dist/components/SummaryList/SummaryList.test.js +162 -189
- package/dist/components/SummaryList/SummaryListHeadingRow.js +7 -5
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
- package/dist/components/SummaryList/SummaryListRow.js +7 -5
- package/dist/components/SummaryList/SummaryListTitleRow.js +6 -4
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +23 -23
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +23 -23
- 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 +56 -79
- package/dist/components/TaskList/TaskList.test.js +149 -149
- package/dist/components/TaskList/TaskState.js +8 -6
- package/dist/components/TaskList/TaskState.test.js +53 -46
- package/dist/components/TaskList/index.js +1 -1
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +56 -79
- 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 +57 -69
- 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 +25 -37
- 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 +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +12 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +32 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +15 -28
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +41 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +7 -7
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +27 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +48 -52
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +79 -93
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -14
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +146 -98
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +14 -19
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +69 -73
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +7 -8
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +15 -16
- package/dist/utils/CheckYourAnswers/index.js +2 -2
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +5 -5
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -19
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +48 -39
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
- package/dist/utils/CollectionPage/getErrorsForCollection.js +20 -21
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
- package/dist/utils/CollectionPage/getQuickEditPage.js +22 -23
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +17 -18
- package/dist/utils/CollectionPage/index.js +2 -2
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +18 -18
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
- package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +25 -25
- package/dist/utils/Component/addShowWhen.js +5 -6
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +12 -15
- package/dist/utils/Component/applyToComponentTree.test.js +28 -31
- package/dist/utils/Component/cleanAttributes.js +12 -11
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +6 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
- package/dist/utils/Component/getComponent.js +81 -83
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +41 -58
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +24 -34
- 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 +21 -26
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +11 -10
- 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 +201 -174
- 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 +32 -39
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +21 -30
- 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 +16 -20
- 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 +23 -28
- package/dist/utils/Component/setupContainerComponentsPath.test.js +12 -12
- package/dist/utils/Component/showComponent.js +2 -2
- 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 +17 -26
- 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 +12 -15
- 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 +14 -15
- package/dist/utils/Container/setupNesting.test.js +20 -23
- package/dist/utils/Container/showContainer.js +4 -8
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +30 -44
- package/dist/utils/Data/applyFormula.test.js +21 -21
- package/dist/utils/Data/deleteValues.js +4 -8
- package/dist/utils/Data/deleteValues.test.js +11 -11
- package/dist/utils/Data/getAutocompleteSource.js +19 -27
- package/dist/utils/Data/getAutocompleteSource.test.js +76 -81
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +13 -13
- package/dist/utils/Data/getOptions.js +57 -30
- package/dist/utils/Data/getOptions.test.js +75 -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 -12
- package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
- package/dist/utils/Data/refDataToOptions.js +9 -10
- 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 +13 -20
- package/dist/utils/Data/setupFormData.test.js +48 -47
- package/dist/utils/Data/setupRefDataUrlForComponent.js +11 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +25 -25
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -8
- package/dist/utils/FormPage/applyConditionalProperties.test.js +14 -15
- package/dist/utils/FormPage/getConditionalText.js +4 -4
- package/dist/utils/FormPage/getConditionalText.test.js +30 -30
- package/dist/utils/FormPage/getFormPage.js +16 -12
- package/dist/utils/FormPage/getFormPage.test.js +23 -24
- package/dist/utils/FormPage/getFormPages.js +8 -11
- package/dist/utils/FormPage/getFormPages.test.js +15 -16
- package/dist/utils/FormPage/getPageActions.js +10 -13
- 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 +2 -2
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +25 -22
- package/dist/utils/FormPage/useComponent.test.js +79 -44
- 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 +5 -6
- 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 +23 -24
- package/dist/utils/Hub/index.js +2 -2
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- 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 +12 -13
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +70 -33
- package/dist/utils/Meta/index.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.js +3 -3
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/deleteValueInFormData.js +2 -2
- package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
- package/dist/utils/Operate/getFirstOf.js +6 -6
- package/dist/utils/Operate/getFirstOf.test.js +32 -32
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +11 -11
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/getLength.js +9 -9
- package/dist/utils/Operate/getLength.test.js +19 -19
- package/dist/utils/Operate/index.js +2 -2
- package/dist/utils/Operate/persistValueInFormData.js +4 -4
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +8 -8
- package/dist/utils/Operate/runPageOperations.test.js +24 -25
- package/dist/utils/Operate/setValueInFormData.js +3 -3
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +7 -7
- package/dist/utils/Operate/shouldRun.test.js +22 -24
- 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 -4
- 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 +8 -12
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -38
- 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 +3 -3
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +4 -4
- 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 +35 -36
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- 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 +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +2 -2
- package/dist/utils/Validate/validateCollection.js +18 -23
- package/dist/utils/Validate/validateCollection.test.js +75 -67
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +179 -154
- package/dist/utils/Validate/validateContainer.js +14 -17
- package/dist/utils/Validate/validateContainer.test.js +59 -53
- package/dist/utils/Validate/validateDate.js +16 -22
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +8 -9
- package/dist/utils/Validate/validateEmail.test.js +29 -26
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +13 -18
- package/dist/utils/Validate/validatePage.test.js +198 -195
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +15 -15
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +4 -6
- 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 +5 -6
- package/package.json +5 -5
|
@@ -9,23 +9,20 @@ var _elevateNestedComponents = _interopRequireDefault(require("../Component/elev
|
|
|
9
9
|
var _getCYARow = _interopRequireDefault(require("./getCYARow"));
|
|
10
10
|
var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
|
|
11
11
|
var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
|
|
12
|
-
function _interopRequireDefault(
|
|
13
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
-
function _defineProperty(
|
|
17
|
-
function _toPropertyKey(
|
|
18
|
-
function _toPrimitive(
|
|
19
|
-
|
|
15
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Local imports
|
|
18
|
+
const getCYARowsForContainer = (page, container, formData, onAction, fnOverride) => {
|
|
20
19
|
if ((0, _showComponentCYA.default)(container, _objectSpread(_objectSpread({}, page.formData), formData))) {
|
|
21
|
-
|
|
22
|
-
return allComponents.filter(
|
|
23
|
-
|
|
24
|
-
}).flatMap(function (component) {
|
|
25
|
-
var fd = formData ? formData[component.fieldId] : undefined;
|
|
20
|
+
const allComponents = (0, _elevateNestedComponents.default)(container.components.filter(component => component.show_on_cya === undefined || component.show_on_cya), formData);
|
|
21
|
+
return allComponents.filter(c => (0, _showComponentCYA.default)(c, _objectSpread(_objectSpread({}, page.formData), formData))).flatMap(component => {
|
|
22
|
+
const fd = formData ? formData[component.fieldId] : undefined;
|
|
26
23
|
if (typeof fnOverride === 'function') {
|
|
27
|
-
|
|
28
|
-
formData
|
|
24
|
+
const overrideRows = fnOverride(_objectSpread(_objectSpread({}, page), {}, {
|
|
25
|
+
formData
|
|
29
26
|
}), component, onAction);
|
|
30
27
|
if (overrideRows) {
|
|
31
28
|
return overrideRows;
|
|
@@ -38,7 +35,7 @@ var getCYARowsForContainer = function getCYARowsForContainer(page, container, fo
|
|
|
38
35
|
return (0, _getCYARowsForCollection.default)(page, component, fd, onAction, fnOverride);
|
|
39
36
|
}
|
|
40
37
|
return (0, _getCYARow.default)(_objectSpread(_objectSpread({}, page), {}, {
|
|
41
|
-
formData
|
|
38
|
+
formData
|
|
42
39
|
}), component, onAction);
|
|
43
40
|
});
|
|
44
41
|
}
|
|
@@ -3,33 +3,31 @@
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
4
|
var _setupTests = require("../../setupTests");
|
|
5
5
|
var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
|
|
6
|
-
function _interopRequireDefault(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
it('should get an appropriate row for a container with a single readonly text component', function () {
|
|
15
|
-
var FORM_DATA = {
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
// Local imports
|
|
8
|
+
|
|
9
|
+
describe('utils.CheckYourAnswers.getCYARowsForContainer', () => {
|
|
10
|
+
const OUTER_ID = 'a';
|
|
11
|
+
const INNER_ID = 'b';
|
|
12
|
+
it('should get an appropriate row for a container with a single readonly text component', () => {
|
|
13
|
+
const FORM_DATA = {
|
|
16
14
|
container: {
|
|
17
15
|
a: 'Bravo'
|
|
18
16
|
}
|
|
19
17
|
};
|
|
20
|
-
|
|
18
|
+
const PAGE = {
|
|
21
19
|
id: 'page',
|
|
22
20
|
formData: FORM_DATA,
|
|
23
21
|
cya_link: {}
|
|
24
22
|
};
|
|
25
|
-
|
|
23
|
+
const COMPONENT = {
|
|
26
24
|
type: 'text',
|
|
27
25
|
readonly: true,
|
|
28
26
|
id: 'a',
|
|
29
27
|
fieldId: 'a',
|
|
30
28
|
label: 'Alpha'
|
|
31
29
|
};
|
|
32
|
-
|
|
30
|
+
const CONTAINER = {
|
|
33
31
|
id: 'container',
|
|
34
32
|
fieldId: 'container',
|
|
35
33
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -37,10 +35,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
37
35
|
value: FORM_DATA.container,
|
|
38
36
|
formData: FORM_DATA
|
|
39
37
|
};
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const ON_ACTION = () => {};
|
|
39
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
42
40
|
expect(ROWS.length).toEqual(1);
|
|
43
|
-
ROWS.forEach(
|
|
41
|
+
ROWS.forEach((row, index) => {
|
|
44
42
|
(0, _setupTests.expectObjectLike)(row, {
|
|
45
43
|
pageId: PAGE.id,
|
|
46
44
|
fieldId: CONTAINER.components[index].fieldId,
|
|
@@ -51,31 +49,31 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
51
49
|
});
|
|
52
50
|
});
|
|
53
51
|
});
|
|
54
|
-
it('should get appropriate rows for a container with two editable text components',
|
|
55
|
-
|
|
52
|
+
it('should get appropriate rows for a container with two editable text components', () => {
|
|
53
|
+
const FORM_DATA = {
|
|
56
54
|
container: {
|
|
57
55
|
a: 'Alpha Charlie',
|
|
58
56
|
b: 'Bravo Charlie'
|
|
59
57
|
}
|
|
60
58
|
};
|
|
61
|
-
|
|
59
|
+
const PAGE = {
|
|
62
60
|
id: 'page',
|
|
63
61
|
formData: FORM_DATA,
|
|
64
62
|
cya_link: {}
|
|
65
63
|
};
|
|
66
|
-
|
|
64
|
+
const COMPONENT_A = {
|
|
67
65
|
type: 'text',
|
|
68
66
|
id: 'a',
|
|
69
67
|
fieldId: 'a',
|
|
70
68
|
label: 'Alpha'
|
|
71
69
|
};
|
|
72
|
-
|
|
70
|
+
const COMPONENT_B = {
|
|
73
71
|
type: 'text',
|
|
74
72
|
id: 'b',
|
|
75
73
|
fieldId: 'b',
|
|
76
74
|
label: 'Bravo'
|
|
77
75
|
};
|
|
78
|
-
|
|
76
|
+
const CONTAINER = {
|
|
79
77
|
id: 'container',
|
|
80
78
|
fieldId: 'container',
|
|
81
79
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -83,10 +81,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
83
81
|
value: FORM_DATA.container,
|
|
84
82
|
formData: FORM_DATA
|
|
85
83
|
};
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
const ON_ACTION = () => {};
|
|
85
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
88
86
|
expect(ROWS.length).toEqual(2);
|
|
89
|
-
ROWS.forEach(
|
|
87
|
+
ROWS.forEach((row, index) => {
|
|
90
88
|
(0, _setupTests.expectObjectLike)(row, {
|
|
91
89
|
pageId: PAGE.id,
|
|
92
90
|
fieldId: CONTAINER.components[index].fieldId,
|
|
@@ -99,35 +97,35 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
99
97
|
});
|
|
100
98
|
});
|
|
101
99
|
});
|
|
102
|
-
it("should filter out any components that shouldn't be shown",
|
|
103
|
-
|
|
100
|
+
it("should filter out any components that shouldn't be shown", () => {
|
|
101
|
+
const FORM_DATA = {
|
|
104
102
|
container: {
|
|
105
103
|
a: 'Alpha Charlie',
|
|
106
104
|
b: 'Bravo Charlie'
|
|
107
105
|
}
|
|
108
106
|
};
|
|
109
|
-
|
|
107
|
+
const PAGE = {
|
|
110
108
|
id: 'page',
|
|
111
109
|
formData: FORM_DATA,
|
|
112
110
|
cya_link: {}
|
|
113
111
|
};
|
|
114
|
-
|
|
112
|
+
const COMPONENT_A = {
|
|
115
113
|
type: 'text',
|
|
116
114
|
id: 'a',
|
|
117
115
|
fieldId: 'a',
|
|
118
116
|
label: 'Alpha'
|
|
119
117
|
};
|
|
120
|
-
|
|
118
|
+
const COMPONENT_B = {
|
|
121
119
|
type: 'text',
|
|
122
120
|
id: 'b',
|
|
123
121
|
fieldId: 'b',
|
|
124
122
|
label: 'Bravo'
|
|
125
123
|
};
|
|
126
|
-
|
|
124
|
+
const COMPONENT_C = {
|
|
127
125
|
type: 'heading',
|
|
128
126
|
content: 'Heading component'
|
|
129
127
|
};
|
|
130
|
-
|
|
128
|
+
const CONTAINER = {
|
|
131
129
|
id: 'container',
|
|
132
130
|
fieldId: 'container',
|
|
133
131
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -135,10 +133,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
135
133
|
value: FORM_DATA.container,
|
|
136
134
|
formData: FORM_DATA
|
|
137
135
|
};
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
const ON_ACTION = () => {};
|
|
137
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
140
138
|
expect(ROWS.length).toEqual(2);
|
|
141
|
-
ROWS.forEach(
|
|
139
|
+
ROWS.forEach((row, index) => {
|
|
142
140
|
(0, _setupTests.expectObjectLike)(row, {
|
|
143
141
|
pageId: PAGE.id,
|
|
144
142
|
fieldId: CONTAINER.components[index].fieldId,
|
|
@@ -151,27 +149,69 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
151
149
|
});
|
|
152
150
|
});
|
|
153
151
|
});
|
|
154
|
-
it('should
|
|
155
|
-
|
|
152
|
+
it('should not display nested input components when passed a value of false for "show_on_cya" at the parent component level', () => {
|
|
153
|
+
const FORM_DATA = {
|
|
154
|
+
container: {
|
|
155
|
+
topLevelInput: 'A',
|
|
156
|
+
nestedInput: 'Bravo'
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const PAGE = {
|
|
160
|
+
id: 'page',
|
|
161
|
+
formData: FORM_DATA,
|
|
162
|
+
cya_link: {}
|
|
163
|
+
};
|
|
164
|
+
const NESTED_COMPONENT = {
|
|
165
|
+
type: 'text',
|
|
166
|
+
id: 'nestedInput',
|
|
167
|
+
fieldId: 'nestedInput',
|
|
168
|
+
label: 'Nested input',
|
|
169
|
+
value: 'Bravo'
|
|
170
|
+
};
|
|
171
|
+
const COMPONENT = {
|
|
172
|
+
type: 'checkboxes',
|
|
173
|
+
id: 'topLevelInput',
|
|
174
|
+
fieldId: 'topLevelInput',
|
|
175
|
+
label: 'Top level input',
|
|
176
|
+
show_on_cya: false,
|
|
177
|
+
options: [{
|
|
178
|
+
value: 'A',
|
|
179
|
+
label: 'Option Alpha',
|
|
180
|
+
nested: [NESTED_COMPONENT]
|
|
181
|
+
}]
|
|
182
|
+
};
|
|
183
|
+
const CONTAINER = {
|
|
184
|
+
id: 'container',
|
|
185
|
+
fieldId: 'container',
|
|
186
|
+
type: _models.ComponentTypes.CONTAINER,
|
|
187
|
+
components: [COMPONENT],
|
|
188
|
+
value: FORM_DATA
|
|
189
|
+
};
|
|
190
|
+
const ON_ACTION = () => {};
|
|
191
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
192
|
+
expect(ROWS.length).toEqual(0);
|
|
193
|
+
});
|
|
194
|
+
it('should get an appropriate row for a container with a single readonly text component inside a nested container', () => {
|
|
195
|
+
const FORM_DATA = {
|
|
156
196
|
container: {
|
|
157
197
|
nested: {
|
|
158
198
|
a: 'Bravo'
|
|
159
199
|
}
|
|
160
200
|
}
|
|
161
201
|
};
|
|
162
|
-
|
|
202
|
+
const PAGE = {
|
|
163
203
|
id: 'page',
|
|
164
204
|
formData: FORM_DATA,
|
|
165
205
|
cya_link: {}
|
|
166
206
|
};
|
|
167
|
-
|
|
207
|
+
const COMPONENT = {
|
|
168
208
|
type: 'text',
|
|
169
209
|
readonly: true,
|
|
170
210
|
id: 'a',
|
|
171
211
|
fieldId: 'a',
|
|
172
212
|
label: 'Alpha'
|
|
173
213
|
};
|
|
174
|
-
|
|
214
|
+
const NESTED_CONTAINER = {
|
|
175
215
|
id: 'nested',
|
|
176
216
|
fieldId: 'nested',
|
|
177
217
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -179,7 +219,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
179
219
|
value: FORM_DATA.container.nested,
|
|
180
220
|
formData: FORM_DATA
|
|
181
221
|
};
|
|
182
|
-
|
|
222
|
+
const CONTAINER = {
|
|
183
223
|
id: 'container',
|
|
184
224
|
fieldId: 'container',
|
|
185
225
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -187,10 +227,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
187
227
|
value: FORM_DATA.container,
|
|
188
228
|
formData: FORM_DATA
|
|
189
229
|
};
|
|
190
|
-
|
|
191
|
-
|
|
230
|
+
const ON_ACTION = () => {};
|
|
231
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
192
232
|
expect(ROWS.length).toEqual(1);
|
|
193
|
-
ROWS.forEach(
|
|
233
|
+
ROWS.forEach((row, index) => {
|
|
194
234
|
(0, _setupTests.expectObjectLike)(row, {
|
|
195
235
|
pageId: PAGE.id,
|
|
196
236
|
fieldId: NESTED_CONTAINER.components[index].fieldId,
|
|
@@ -201,36 +241,36 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
201
241
|
});
|
|
202
242
|
});
|
|
203
243
|
});
|
|
204
|
-
it('should get an appropriate row for a container with a single readonly text component inside a nested container but no formData',
|
|
205
|
-
|
|
206
|
-
|
|
244
|
+
it('should get an appropriate row for a container with a single readonly text component inside a nested container but no formData', () => {
|
|
245
|
+
const FORM_DATA = undefined;
|
|
246
|
+
const PAGE = {
|
|
207
247
|
id: 'page',
|
|
208
248
|
formData: FORM_DATA,
|
|
209
249
|
cya_link: {}
|
|
210
250
|
};
|
|
211
|
-
|
|
251
|
+
const COMPONENT = {
|
|
212
252
|
type: 'text',
|
|
213
253
|
readonly: true,
|
|
214
254
|
id: 'a',
|
|
215
255
|
fieldId: 'a',
|
|
216
256
|
label: 'Alpha'
|
|
217
257
|
};
|
|
218
|
-
|
|
258
|
+
const NESTED_CONTAINER = {
|
|
219
259
|
id: 'nested',
|
|
220
260
|
fieldId: 'nested',
|
|
221
261
|
type: _models.ComponentTypes.CONTAINER,
|
|
222
262
|
components: [COMPONENT]
|
|
223
263
|
};
|
|
224
|
-
|
|
264
|
+
const CONTAINER = {
|
|
225
265
|
id: 'container',
|
|
226
266
|
fieldId: 'container',
|
|
227
267
|
type: _models.ComponentTypes.CONTAINER,
|
|
228
268
|
components: [NESTED_CONTAINER]
|
|
229
269
|
};
|
|
230
|
-
|
|
231
|
-
|
|
270
|
+
const ON_ACTION = () => {};
|
|
271
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, undefined, ON_ACTION);
|
|
232
272
|
expect(ROWS.length).toEqual(1);
|
|
233
|
-
ROWS.forEach(
|
|
273
|
+
ROWS.forEach((row, index) => {
|
|
234
274
|
(0, _setupTests.expectObjectLike)(row, {
|
|
235
275
|
pageId: PAGE.id,
|
|
236
276
|
fieldId: NESTED_CONTAINER.components[index].fieldId,
|
|
@@ -241,15 +281,21 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
241
281
|
});
|
|
242
282
|
});
|
|
243
283
|
});
|
|
244
|
-
it('should get an appropriate row for a collection with a single text component inside a container',
|
|
245
|
-
|
|
246
|
-
|
|
284
|
+
it('should get an appropriate row for a collection with a single text component inside a container', () => {
|
|
285
|
+
const FORM_DATA = {
|
|
286
|
+
[OUTER_ID]: [{
|
|
287
|
+
[INNER_ID]: 'Bravo'
|
|
288
|
+
}, {
|
|
289
|
+
[INNER_ID]: 'Charlie'
|
|
290
|
+
}]
|
|
291
|
+
};
|
|
292
|
+
const PAGE = {
|
|
247
293
|
id: 'page',
|
|
248
294
|
formData: FORM_DATA,
|
|
249
295
|
cya_link: {},
|
|
250
296
|
collection: 'collectionName'
|
|
251
297
|
};
|
|
252
|
-
|
|
298
|
+
const COLLECTION_COMPONENT = {
|
|
253
299
|
type: 'collection',
|
|
254
300
|
id: OUTER_ID,
|
|
255
301
|
fieldId: OUTER_ID,
|
|
@@ -261,7 +307,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
261
307
|
type: 'text'
|
|
262
308
|
}]
|
|
263
309
|
};
|
|
264
|
-
|
|
310
|
+
const CONTAINER = {
|
|
265
311
|
id: 'container',
|
|
266
312
|
fieldId: 'container',
|
|
267
313
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -269,9 +315,9 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
269
315
|
value: FORM_DATA.container,
|
|
270
316
|
formData: FORM_DATA
|
|
271
317
|
};
|
|
272
|
-
|
|
318
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA, () => {});
|
|
273
319
|
expect(ROWS.length).toEqual(4);
|
|
274
|
-
|
|
320
|
+
const checkTitleRow = (index, row) => {
|
|
275
321
|
expect(row).toEqual({
|
|
276
322
|
pageId: PAGE.id,
|
|
277
323
|
fieldId: CONTAINER.components[0].fieldId,
|
|
@@ -281,7 +327,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
281
327
|
type: 'title'
|
|
282
328
|
});
|
|
283
329
|
};
|
|
284
|
-
|
|
330
|
+
const checkValueRow = (index, row, value) => {
|
|
285
331
|
(0, _setupTests.expectObjectLike)(row, {
|
|
286
332
|
pageId: PAGE.id,
|
|
287
333
|
fieldId: INNER_ID,
|
|
@@ -294,7 +340,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
294
340
|
label: INNER_ID,
|
|
295
341
|
type: 'text'
|
|
296
342
|
},
|
|
297
|
-
value
|
|
343
|
+
value,
|
|
298
344
|
full_path: "".concat(OUTER_ID, "[").concat(index, "].").concat(INNER_ID)
|
|
299
345
|
});
|
|
300
346
|
};
|
|
@@ -303,23 +349,27 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
303
349
|
checkTitleRow(1, ROWS[2]);
|
|
304
350
|
checkValueRow(1, ROWS[3], 'Charlie');
|
|
305
351
|
});
|
|
306
|
-
it('should conditionally show an appropriate row for a single text component inside a container belonging to a partial-collection',
|
|
307
|
-
|
|
352
|
+
it('should conditionally show an appropriate row for a single text component inside a container belonging to a partial-collection', () => {
|
|
353
|
+
const FORM_DATA = {
|
|
308
354
|
collectionName: [{
|
|
309
|
-
container:
|
|
355
|
+
container: {
|
|
356
|
+
[INNER_ID]: 'Bravo'
|
|
357
|
+
},
|
|
310
358
|
other_data: true
|
|
311
359
|
}, {
|
|
312
|
-
container:
|
|
360
|
+
container: {
|
|
361
|
+
[INNER_ID]: 'Charlie'
|
|
362
|
+
},
|
|
313
363
|
other_data: false
|
|
314
364
|
}]
|
|
315
365
|
};
|
|
316
|
-
|
|
366
|
+
const PAGE = {
|
|
317
367
|
id: 'page',
|
|
318
368
|
formData: FORM_DATA,
|
|
319
369
|
cya_link: {},
|
|
320
370
|
collection: 'collectionName'
|
|
321
371
|
};
|
|
322
|
-
|
|
372
|
+
const CONTAINER = {
|
|
323
373
|
id: 'container',
|
|
324
374
|
fieldId: 'container',
|
|
325
375
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -336,27 +386,27 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
336
386
|
value: true
|
|
337
387
|
}
|
|
338
388
|
};
|
|
339
|
-
expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[0],
|
|
340
|
-
expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[1],
|
|
389
|
+
expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[0], () => {}).length).toEqual(1);
|
|
390
|
+
expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[1], () => {})).toBeFalsy();
|
|
341
391
|
});
|
|
342
|
-
it('should get the appropriate number for rows components with nested components inside a container',
|
|
343
|
-
|
|
392
|
+
it('should get the appropriate number for rows components with nested components inside a container', () => {
|
|
393
|
+
const FORM_DATA = {
|
|
344
394
|
container: {
|
|
345
395
|
a: 'B',
|
|
346
396
|
nested: 'Bravo'
|
|
347
397
|
}
|
|
348
398
|
};
|
|
349
|
-
|
|
399
|
+
const PAGE = {
|
|
350
400
|
id: 'page',
|
|
351
401
|
formData: FORM_DATA,
|
|
352
402
|
cya_link: {}
|
|
353
403
|
};
|
|
354
|
-
|
|
404
|
+
const NESTED_COMPONENT = {
|
|
355
405
|
id: 'nested',
|
|
356
406
|
fieldId: 'nested',
|
|
357
407
|
type: _models.ComponentTypes.TEXT
|
|
358
408
|
};
|
|
359
|
-
|
|
409
|
+
const COMPONENT = {
|
|
360
410
|
type: 'radios',
|
|
361
411
|
id: 'a',
|
|
362
412
|
fieldId: 'a',
|
|
@@ -372,7 +422,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
372
422
|
}]
|
|
373
423
|
}
|
|
374
424
|
};
|
|
375
|
-
|
|
425
|
+
const CONTAINER = {
|
|
376
426
|
id: 'container',
|
|
377
427
|
fieldId: 'container',
|
|
378
428
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -380,35 +430,35 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
380
430
|
value: FORM_DATA.container,
|
|
381
431
|
formData: FORM_DATA
|
|
382
432
|
};
|
|
383
|
-
|
|
384
|
-
|
|
433
|
+
const ON_ACTION = () => {};
|
|
434
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
385
435
|
expect(ROWS.length).toEqual(2);
|
|
386
436
|
});
|
|
387
|
-
it('should ignore the result of the override function if it returns nullish',
|
|
388
|
-
|
|
437
|
+
it('should ignore the result of the override function if it returns nullish', () => {
|
|
438
|
+
const FORM_DATA = {
|
|
389
439
|
container: {
|
|
390
440
|
a: 'Alpha Charlie',
|
|
391
441
|
b: 'Bravo Charlie'
|
|
392
442
|
}
|
|
393
443
|
};
|
|
394
|
-
|
|
444
|
+
const PAGE = {
|
|
395
445
|
id: 'page',
|
|
396
446
|
formData: FORM_DATA,
|
|
397
447
|
cya_link: {}
|
|
398
448
|
};
|
|
399
|
-
|
|
449
|
+
const COMPONENT_A = {
|
|
400
450
|
type: 'text',
|
|
401
451
|
id: 'a',
|
|
402
452
|
fieldId: 'a',
|
|
403
453
|
label: 'Alpha'
|
|
404
454
|
};
|
|
405
|
-
|
|
455
|
+
const COMPONENT_B = {
|
|
406
456
|
type: 'text',
|
|
407
457
|
id: 'b',
|
|
408
458
|
fieldId: 'b',
|
|
409
459
|
label: 'Bravo'
|
|
410
460
|
};
|
|
411
|
-
|
|
461
|
+
const CONTAINER = {
|
|
412
462
|
id: 'container',
|
|
413
463
|
fieldId: 'container',
|
|
414
464
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -416,12 +466,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
416
466
|
value: FORM_DATA.container,
|
|
417
467
|
formData: FORM_DATA
|
|
418
468
|
};
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
return null;
|
|
422
|
-
});
|
|
469
|
+
const ON_ACTION = () => {};
|
|
470
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION, () => null);
|
|
423
471
|
expect(ROWS.length).toEqual(2);
|
|
424
|
-
ROWS.forEach(
|
|
472
|
+
ROWS.forEach((row, index) => {
|
|
425
473
|
(0, _setupTests.expectObjectLike)(row, {
|
|
426
474
|
pageId: PAGE.id,
|
|
427
475
|
fieldId: CONTAINER.components[index].fieldId,
|
|
@@ -434,31 +482,31 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
434
482
|
});
|
|
435
483
|
});
|
|
436
484
|
});
|
|
437
|
-
it('should use rows produced by the override function if provided',
|
|
438
|
-
|
|
485
|
+
it('should use rows produced by the override function if provided', () => {
|
|
486
|
+
const FORM_DATA = {
|
|
439
487
|
container: {
|
|
440
488
|
a: 'Alpha Charlie',
|
|
441
489
|
b: 'Bravo Charlie'
|
|
442
490
|
}
|
|
443
491
|
};
|
|
444
|
-
|
|
492
|
+
const PAGE = {
|
|
445
493
|
id: 'page',
|
|
446
494
|
formData: FORM_DATA,
|
|
447
495
|
cya_link: {}
|
|
448
496
|
};
|
|
449
|
-
|
|
497
|
+
const COMPONENT_A = {
|
|
450
498
|
type: 'text',
|
|
451
499
|
id: 'a',
|
|
452
500
|
fieldId: 'a',
|
|
453
501
|
label: 'Alpha'
|
|
454
502
|
};
|
|
455
|
-
|
|
503
|
+
const COMPONENT_B = {
|
|
456
504
|
type: 'text',
|
|
457
505
|
id: 'b',
|
|
458
506
|
fieldId: 'b',
|
|
459
507
|
label: 'Bravo'
|
|
460
508
|
};
|
|
461
|
-
|
|
509
|
+
const CONTAINER = {
|
|
462
510
|
id: 'container',
|
|
463
511
|
fieldId: 'container',
|
|
464
512
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -466,16 +514,16 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
466
514
|
value: FORM_DATA.container,
|
|
467
515
|
formData: FORM_DATA
|
|
468
516
|
};
|
|
469
|
-
|
|
517
|
+
const ON_ACTION = () => {};
|
|
470
518
|
// eslint-disable-next-line arrow-body-style
|
|
471
|
-
|
|
519
|
+
const OVERRIDE = (page, comp) => {
|
|
472
520
|
// This will be called for each component in the container,
|
|
473
521
|
// returning a custom row object.
|
|
474
522
|
return {
|
|
475
523
|
key: "CustomRowFor".concat(comp.label)
|
|
476
524
|
};
|
|
477
525
|
};
|
|
478
|
-
|
|
526
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION, OVERRIDE);
|
|
479
527
|
expect(ROWS.length).toEqual(2);
|
|
480
528
|
expect(ROWS).toEqual([{
|
|
481
529
|
key: 'CustomRowForAlpha'
|