@ukhomeoffice/cop-react-form-renderer 6.14.0 → 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 +5 -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 +75 -97
- 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 +34 -47
- package/dist/components/CollectionSummary/RenderListView.test.js +113 -111
- package/dist/components/CollectionSummary/SummaryCard.js +101 -133
- package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
- package/dist/components/CollectionSummary/SummaryCardButtons.js +25 -30
- package/dist/components/CollectionSummary/SummaryCardButtons.test.js +30 -28
- 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 +63 -100
- 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 +70 -93
- package/dist/components/FormPage/FormPage.test.js +150 -202
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +131 -173
- 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 +76 -93
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- 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 +79 -85
- 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 -226
- 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 +35 -42
- package/dist/utils/Data/getOptions.test.js +37 -38
- 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 +12 -15
- 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 +15 -23
- package/dist/utils/FormPage/useComponent.test.js +49 -50
- 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 +7 -9
- package/dist/utils/Validate/validateEmail.test.js +27 -27
- 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 +2 -4
|
@@ -9,25 +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
|
-
|
|
23
|
-
|
|
24
|
-
return allComponents.filter(function (c) {
|
|
25
|
-
return (0, _showComponentCYA.default)(c, _objectSpread(_objectSpread({}, page.formData), formData));
|
|
26
|
-
}).flatMap(function (component) {
|
|
27
|
-
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;
|
|
28
23
|
if (typeof fnOverride === 'function') {
|
|
29
|
-
|
|
30
|
-
formData
|
|
24
|
+
const overrideRows = fnOverride(_objectSpread(_objectSpread({}, page), {}, {
|
|
25
|
+
formData
|
|
31
26
|
}), component, onAction);
|
|
32
27
|
if (overrideRows) {
|
|
33
28
|
return overrideRows;
|
|
@@ -40,7 +35,7 @@ var getCYARowsForContainer = function getCYARowsForContainer(page, container, fo
|
|
|
40
35
|
return (0, _getCYARowsForCollection.default)(page, component, fd, onAction, fnOverride);
|
|
41
36
|
}
|
|
42
37
|
return (0, _getCYARow.default)(_objectSpread(_objectSpread({}, page), {}, {
|
|
43
|
-
formData
|
|
38
|
+
formData
|
|
44
39
|
}), component, onAction);
|
|
45
40
|
});
|
|
46
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,26 +149,26 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
151
149
|
});
|
|
152
150
|
});
|
|
153
151
|
});
|
|
154
|
-
it('should not display nested input components when passed a value of false for "show_on_cya" at the parent component level',
|
|
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 = {
|
|
156
154
|
container: {
|
|
157
155
|
topLevelInput: 'A',
|
|
158
156
|
nestedInput: 'Bravo'
|
|
159
157
|
}
|
|
160
158
|
};
|
|
161
|
-
|
|
159
|
+
const PAGE = {
|
|
162
160
|
id: 'page',
|
|
163
161
|
formData: FORM_DATA,
|
|
164
162
|
cya_link: {}
|
|
165
163
|
};
|
|
166
|
-
|
|
164
|
+
const NESTED_COMPONENT = {
|
|
167
165
|
type: 'text',
|
|
168
166
|
id: 'nestedInput',
|
|
169
167
|
fieldId: 'nestedInput',
|
|
170
168
|
label: 'Nested input',
|
|
171
169
|
value: 'Bravo'
|
|
172
170
|
};
|
|
173
|
-
|
|
171
|
+
const COMPONENT = {
|
|
174
172
|
type: 'checkboxes',
|
|
175
173
|
id: 'topLevelInput',
|
|
176
174
|
fieldId: 'topLevelInput',
|
|
@@ -182,38 +180,38 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
182
180
|
nested: [NESTED_COMPONENT]
|
|
183
181
|
}]
|
|
184
182
|
};
|
|
185
|
-
|
|
183
|
+
const CONTAINER = {
|
|
186
184
|
id: 'container',
|
|
187
185
|
fieldId: 'container',
|
|
188
186
|
type: _models.ComponentTypes.CONTAINER,
|
|
189
187
|
components: [COMPONENT],
|
|
190
188
|
value: FORM_DATA
|
|
191
189
|
};
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
const ON_ACTION = () => {};
|
|
191
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
194
192
|
expect(ROWS.length).toEqual(0);
|
|
195
193
|
});
|
|
196
|
-
it('should get an appropriate row for a container with a single readonly text component inside a nested container',
|
|
197
|
-
|
|
194
|
+
it('should get an appropriate row for a container with a single readonly text component inside a nested container', () => {
|
|
195
|
+
const FORM_DATA = {
|
|
198
196
|
container: {
|
|
199
197
|
nested: {
|
|
200
198
|
a: 'Bravo'
|
|
201
199
|
}
|
|
202
200
|
}
|
|
203
201
|
};
|
|
204
|
-
|
|
202
|
+
const PAGE = {
|
|
205
203
|
id: 'page',
|
|
206
204
|
formData: FORM_DATA,
|
|
207
205
|
cya_link: {}
|
|
208
206
|
};
|
|
209
|
-
|
|
207
|
+
const COMPONENT = {
|
|
210
208
|
type: 'text',
|
|
211
209
|
readonly: true,
|
|
212
210
|
id: 'a',
|
|
213
211
|
fieldId: 'a',
|
|
214
212
|
label: 'Alpha'
|
|
215
213
|
};
|
|
216
|
-
|
|
214
|
+
const NESTED_CONTAINER = {
|
|
217
215
|
id: 'nested',
|
|
218
216
|
fieldId: 'nested',
|
|
219
217
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -221,7 +219,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
221
219
|
value: FORM_DATA.container.nested,
|
|
222
220
|
formData: FORM_DATA
|
|
223
221
|
};
|
|
224
|
-
|
|
222
|
+
const CONTAINER = {
|
|
225
223
|
id: 'container',
|
|
226
224
|
fieldId: 'container',
|
|
227
225
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -229,10 +227,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
229
227
|
value: FORM_DATA.container,
|
|
230
228
|
formData: FORM_DATA
|
|
231
229
|
};
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
const ON_ACTION = () => {};
|
|
231
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
234
232
|
expect(ROWS.length).toEqual(1);
|
|
235
|
-
ROWS.forEach(
|
|
233
|
+
ROWS.forEach((row, index) => {
|
|
236
234
|
(0, _setupTests.expectObjectLike)(row, {
|
|
237
235
|
pageId: PAGE.id,
|
|
238
236
|
fieldId: NESTED_CONTAINER.components[index].fieldId,
|
|
@@ -243,36 +241,36 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
243
241
|
});
|
|
244
242
|
});
|
|
245
243
|
});
|
|
246
|
-
it('should get an appropriate row for a container with a single readonly text component inside a nested container but no formData',
|
|
247
|
-
|
|
248
|
-
|
|
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 = {
|
|
249
247
|
id: 'page',
|
|
250
248
|
formData: FORM_DATA,
|
|
251
249
|
cya_link: {}
|
|
252
250
|
};
|
|
253
|
-
|
|
251
|
+
const COMPONENT = {
|
|
254
252
|
type: 'text',
|
|
255
253
|
readonly: true,
|
|
256
254
|
id: 'a',
|
|
257
255
|
fieldId: 'a',
|
|
258
256
|
label: 'Alpha'
|
|
259
257
|
};
|
|
260
|
-
|
|
258
|
+
const NESTED_CONTAINER = {
|
|
261
259
|
id: 'nested',
|
|
262
260
|
fieldId: 'nested',
|
|
263
261
|
type: _models.ComponentTypes.CONTAINER,
|
|
264
262
|
components: [COMPONENT]
|
|
265
263
|
};
|
|
266
|
-
|
|
264
|
+
const CONTAINER = {
|
|
267
265
|
id: 'container',
|
|
268
266
|
fieldId: 'container',
|
|
269
267
|
type: _models.ComponentTypes.CONTAINER,
|
|
270
268
|
components: [NESTED_CONTAINER]
|
|
271
269
|
};
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
const ON_ACTION = () => {};
|
|
271
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, undefined, ON_ACTION);
|
|
274
272
|
expect(ROWS.length).toEqual(1);
|
|
275
|
-
ROWS.forEach(
|
|
273
|
+
ROWS.forEach((row, index) => {
|
|
276
274
|
(0, _setupTests.expectObjectLike)(row, {
|
|
277
275
|
pageId: PAGE.id,
|
|
278
276
|
fieldId: NESTED_CONTAINER.components[index].fieldId,
|
|
@@ -283,15 +281,21 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
283
281
|
});
|
|
284
282
|
});
|
|
285
283
|
});
|
|
286
|
-
it('should get an appropriate row for a collection with a single text component inside a container',
|
|
287
|
-
|
|
288
|
-
|
|
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 = {
|
|
289
293
|
id: 'page',
|
|
290
294
|
formData: FORM_DATA,
|
|
291
295
|
cya_link: {},
|
|
292
296
|
collection: 'collectionName'
|
|
293
297
|
};
|
|
294
|
-
|
|
298
|
+
const COLLECTION_COMPONENT = {
|
|
295
299
|
type: 'collection',
|
|
296
300
|
id: OUTER_ID,
|
|
297
301
|
fieldId: OUTER_ID,
|
|
@@ -303,7 +307,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
303
307
|
type: 'text'
|
|
304
308
|
}]
|
|
305
309
|
};
|
|
306
|
-
|
|
310
|
+
const CONTAINER = {
|
|
307
311
|
id: 'container',
|
|
308
312
|
fieldId: 'container',
|
|
309
313
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -311,9 +315,9 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
311
315
|
value: FORM_DATA.container,
|
|
312
316
|
formData: FORM_DATA
|
|
313
317
|
};
|
|
314
|
-
|
|
318
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA, () => {});
|
|
315
319
|
expect(ROWS.length).toEqual(4);
|
|
316
|
-
|
|
320
|
+
const checkTitleRow = (index, row) => {
|
|
317
321
|
expect(row).toEqual({
|
|
318
322
|
pageId: PAGE.id,
|
|
319
323
|
fieldId: CONTAINER.components[0].fieldId,
|
|
@@ -323,7 +327,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
323
327
|
type: 'title'
|
|
324
328
|
});
|
|
325
329
|
};
|
|
326
|
-
|
|
330
|
+
const checkValueRow = (index, row, value) => {
|
|
327
331
|
(0, _setupTests.expectObjectLike)(row, {
|
|
328
332
|
pageId: PAGE.id,
|
|
329
333
|
fieldId: INNER_ID,
|
|
@@ -336,7 +340,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
336
340
|
label: INNER_ID,
|
|
337
341
|
type: 'text'
|
|
338
342
|
},
|
|
339
|
-
value
|
|
343
|
+
value,
|
|
340
344
|
full_path: "".concat(OUTER_ID, "[").concat(index, "].").concat(INNER_ID)
|
|
341
345
|
});
|
|
342
346
|
};
|
|
@@ -345,23 +349,27 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
345
349
|
checkTitleRow(1, ROWS[2]);
|
|
346
350
|
checkValueRow(1, ROWS[3], 'Charlie');
|
|
347
351
|
});
|
|
348
|
-
it('should conditionally show an appropriate row for a single text component inside a container belonging to a partial-collection',
|
|
349
|
-
|
|
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 = {
|
|
350
354
|
collectionName: [{
|
|
351
|
-
container:
|
|
355
|
+
container: {
|
|
356
|
+
[INNER_ID]: 'Bravo'
|
|
357
|
+
},
|
|
352
358
|
other_data: true
|
|
353
359
|
}, {
|
|
354
|
-
container:
|
|
360
|
+
container: {
|
|
361
|
+
[INNER_ID]: 'Charlie'
|
|
362
|
+
},
|
|
355
363
|
other_data: false
|
|
356
364
|
}]
|
|
357
365
|
};
|
|
358
|
-
|
|
366
|
+
const PAGE = {
|
|
359
367
|
id: 'page',
|
|
360
368
|
formData: FORM_DATA,
|
|
361
369
|
cya_link: {},
|
|
362
370
|
collection: 'collectionName'
|
|
363
371
|
};
|
|
364
|
-
|
|
372
|
+
const CONTAINER = {
|
|
365
373
|
id: 'container',
|
|
366
374
|
fieldId: 'container',
|
|
367
375
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -378,27 +386,27 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
378
386
|
value: true
|
|
379
387
|
}
|
|
380
388
|
};
|
|
381
|
-
expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[0],
|
|
382
|
-
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();
|
|
383
391
|
});
|
|
384
|
-
it('should get the appropriate number for rows components with nested components inside a container',
|
|
385
|
-
|
|
392
|
+
it('should get the appropriate number for rows components with nested components inside a container', () => {
|
|
393
|
+
const FORM_DATA = {
|
|
386
394
|
container: {
|
|
387
395
|
a: 'B',
|
|
388
396
|
nested: 'Bravo'
|
|
389
397
|
}
|
|
390
398
|
};
|
|
391
|
-
|
|
399
|
+
const PAGE = {
|
|
392
400
|
id: 'page',
|
|
393
401
|
formData: FORM_DATA,
|
|
394
402
|
cya_link: {}
|
|
395
403
|
};
|
|
396
|
-
|
|
404
|
+
const NESTED_COMPONENT = {
|
|
397
405
|
id: 'nested',
|
|
398
406
|
fieldId: 'nested',
|
|
399
407
|
type: _models.ComponentTypes.TEXT
|
|
400
408
|
};
|
|
401
|
-
|
|
409
|
+
const COMPONENT = {
|
|
402
410
|
type: 'radios',
|
|
403
411
|
id: 'a',
|
|
404
412
|
fieldId: 'a',
|
|
@@ -414,7 +422,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
414
422
|
}]
|
|
415
423
|
}
|
|
416
424
|
};
|
|
417
|
-
|
|
425
|
+
const CONTAINER = {
|
|
418
426
|
id: 'container',
|
|
419
427
|
fieldId: 'container',
|
|
420
428
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -422,35 +430,35 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
422
430
|
value: FORM_DATA.container,
|
|
423
431
|
formData: FORM_DATA
|
|
424
432
|
};
|
|
425
|
-
|
|
426
|
-
|
|
433
|
+
const ON_ACTION = () => {};
|
|
434
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
427
435
|
expect(ROWS.length).toEqual(2);
|
|
428
436
|
});
|
|
429
|
-
it('should ignore the result of the override function if it returns nullish',
|
|
430
|
-
|
|
437
|
+
it('should ignore the result of the override function if it returns nullish', () => {
|
|
438
|
+
const FORM_DATA = {
|
|
431
439
|
container: {
|
|
432
440
|
a: 'Alpha Charlie',
|
|
433
441
|
b: 'Bravo Charlie'
|
|
434
442
|
}
|
|
435
443
|
};
|
|
436
|
-
|
|
444
|
+
const PAGE = {
|
|
437
445
|
id: 'page',
|
|
438
446
|
formData: FORM_DATA,
|
|
439
447
|
cya_link: {}
|
|
440
448
|
};
|
|
441
|
-
|
|
449
|
+
const COMPONENT_A = {
|
|
442
450
|
type: 'text',
|
|
443
451
|
id: 'a',
|
|
444
452
|
fieldId: 'a',
|
|
445
453
|
label: 'Alpha'
|
|
446
454
|
};
|
|
447
|
-
|
|
455
|
+
const COMPONENT_B = {
|
|
448
456
|
type: 'text',
|
|
449
457
|
id: 'b',
|
|
450
458
|
fieldId: 'b',
|
|
451
459
|
label: 'Bravo'
|
|
452
460
|
};
|
|
453
|
-
|
|
461
|
+
const CONTAINER = {
|
|
454
462
|
id: 'container',
|
|
455
463
|
fieldId: 'container',
|
|
456
464
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -458,12 +466,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
458
466
|
value: FORM_DATA.container,
|
|
459
467
|
formData: FORM_DATA
|
|
460
468
|
};
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
return null;
|
|
464
|
-
});
|
|
469
|
+
const ON_ACTION = () => {};
|
|
470
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION, () => null);
|
|
465
471
|
expect(ROWS.length).toEqual(2);
|
|
466
|
-
ROWS.forEach(
|
|
472
|
+
ROWS.forEach((row, index) => {
|
|
467
473
|
(0, _setupTests.expectObjectLike)(row, {
|
|
468
474
|
pageId: PAGE.id,
|
|
469
475
|
fieldId: CONTAINER.components[index].fieldId,
|
|
@@ -476,31 +482,31 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
476
482
|
});
|
|
477
483
|
});
|
|
478
484
|
});
|
|
479
|
-
it('should use rows produced by the override function if provided',
|
|
480
|
-
|
|
485
|
+
it('should use rows produced by the override function if provided', () => {
|
|
486
|
+
const FORM_DATA = {
|
|
481
487
|
container: {
|
|
482
488
|
a: 'Alpha Charlie',
|
|
483
489
|
b: 'Bravo Charlie'
|
|
484
490
|
}
|
|
485
491
|
};
|
|
486
|
-
|
|
492
|
+
const PAGE = {
|
|
487
493
|
id: 'page',
|
|
488
494
|
formData: FORM_DATA,
|
|
489
495
|
cya_link: {}
|
|
490
496
|
};
|
|
491
|
-
|
|
497
|
+
const COMPONENT_A = {
|
|
492
498
|
type: 'text',
|
|
493
499
|
id: 'a',
|
|
494
500
|
fieldId: 'a',
|
|
495
501
|
label: 'Alpha'
|
|
496
502
|
};
|
|
497
|
-
|
|
503
|
+
const COMPONENT_B = {
|
|
498
504
|
type: 'text',
|
|
499
505
|
id: 'b',
|
|
500
506
|
fieldId: 'b',
|
|
501
507
|
label: 'Bravo'
|
|
502
508
|
};
|
|
503
|
-
|
|
509
|
+
const CONTAINER = {
|
|
504
510
|
id: 'container',
|
|
505
511
|
fieldId: 'container',
|
|
506
512
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -508,16 +514,16 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
508
514
|
value: FORM_DATA.container,
|
|
509
515
|
formData: FORM_DATA
|
|
510
516
|
};
|
|
511
|
-
|
|
517
|
+
const ON_ACTION = () => {};
|
|
512
518
|
// eslint-disable-next-line arrow-body-style
|
|
513
|
-
|
|
519
|
+
const OVERRIDE = (page, comp) => {
|
|
514
520
|
// This will be called for each component in the container,
|
|
515
521
|
// returning a custom row object.
|
|
516
522
|
return {
|
|
517
523
|
key: "CustomRowFor".concat(comp.label)
|
|
518
524
|
};
|
|
519
525
|
};
|
|
520
|
-
|
|
526
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION, OVERRIDE);
|
|
521
527
|
expect(ROWS.length).toEqual(2);
|
|
522
528
|
expect(ROWS).toEqual([{
|
|
523
529
|
key: 'CustomRowForAlpha'
|