@ukhomeoffice/cop-react-form-renderer 6.5.1-peter → 6.7.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +12 -12
- package/dist/components/CheckYourAnswers/Answer.test.js +92 -127
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +101 -131
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +463 -769
- package/dist/components/CollectionPage/CollectionPage.js +73 -63
- package/dist/components/CollectionPage/CollectionPage.test.js +316 -366
- package/dist/components/CollectionSummary/BannerStrip.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.test.js +80 -76
- package/dist/components/CollectionSummary/CollectionSummary.js +97 -107
- package/dist/components/CollectionSummary/CollectionSummary.test.js +152 -142
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +45 -51
- package/dist/components/CollectionSummary/RenderListView.test.js +78 -77
- package/dist/components/CollectionSummary/SummaryCard.js +104 -135
- package/dist/components/CollectionSummary/SummaryCard.test.js +930 -962
- package/dist/components/CollectionSummary/SummaryCardDetails.js +72 -71
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +128 -135
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +30 -35
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +62 -74
- package/dist/components/FormComponent/Collection.js +74 -108
- package/dist/components/FormComponent/Collection.test.js +909 -1081
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +69 -72
- package/dist/components/FormComponent/FormComponent.test.js +353 -414
- 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 +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +65 -80
- package/dist/components/FormPage/FormPage.test.js +127 -163
- package/dist/components/FormRenderer/FormRenderer.js +143 -179
- package/dist/components/FormRenderer/FormRenderer.test.js +730 -1115
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- 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 +15 -15
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +16 -20
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +17 -22
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +3 -5
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +5 -7
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -24
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +103 -97
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -78
- package/dist/components/FormRenderer/helpers/index.js +2 -4
- package/dist/components/FormRenderer/onCYAAction.js +59 -51
- package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
- package/dist/components/FormRenderer/onPageAction.js +44 -47
- package/dist/components/FormRenderer/onPageAction.test.js +223 -213
- package/dist/components/FormRenderer/onTaskAction.js +9 -13
- package/dist/components/FormRenderer/onTaskAction.test.js +93 -88
- package/dist/components/PageActions/ActionButton.js +12 -15
- package/dist/components/PageActions/ActionButton.test.js +56 -78
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +86 -115
- package/dist/components/SummaryList/GroupAction.js +9 -17
- package/dist/components/SummaryList/GroupAction.test.js +37 -33
- package/dist/components/SummaryList/RowAction.js +11 -16
- package/dist/components/SummaryList/RowAction.test.js +37 -33
- package/dist/components/SummaryList/SummaryList.js +21 -26
- package/dist/components/SummaryList/SummaryList.test.js +143 -166
- package/dist/components/SummaryList/SummaryListHeadingRow.js +6 -4
- package/dist/components/SummaryList/SummaryListRow.js +6 -4
- package/dist/components/SummaryList/SummaryListTitleRow.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +19 -29
- package/dist/components/TaskList/Task.test.js +83 -76
- package/dist/components/TaskList/TaskList.js +45 -71
- package/dist/components/TaskList/TaskList.test.js +113 -111
- package/dist/components/TaskList/TaskState.js +7 -5
- package/dist/components/TaskList/TaskState.test.js +52 -45
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +57 -80
- package/dist/context/HooksContext/HooksContext.test.js +26 -35
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +43 -94
- package/dist/context/ValidationContext/ValidationContext.test.js +56 -68
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +9 -10
- package/dist/hooks/useAxios.js +14 -40
- package/dist/hooks/useGetRequest.js +61 -97
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +26 -39
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +13 -14
- 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 +9 -9
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +52 -54
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +15 -25
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +33 -35
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -31
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +42 -44
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +18 -24
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +15 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +33 -36
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +58 -61
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +83 -89
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +164 -138
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +25 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +103 -97
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +13 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +70 -76
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +11 -11
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +7 -7
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +18 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +55 -26
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getErrorsForCollection.js +24 -24
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +20 -22
- package/dist/utils/CollectionPage/getQuickEditPage.js +36 -28
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +26 -45
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +31 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +20 -20
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
- package/dist/utils/Component/addShowWhen.js +4 -8
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +27 -32
- package/dist/utils/Component/cleanAttributes.js +10 -13
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +88 -94
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +18 -17
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +46 -59
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +39 -48
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +23 -33
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +20 -18
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +20 -25
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +9 -8
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +22 -26
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +57 -72
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +31 -38
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +20 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +9 -8
- package/dist/utils/Component/getDefaultValue.js +6 -8
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +22 -21
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +27 -29
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +8 -8
- package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
- package/dist/utils/Condition/meetsCondition.js +16 -25
- package/dist/utils/Condition/meetsCondition.test.js +402 -402
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +13 -18
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +3 -5
- package/dist/utils/Container/getEditableComponents.test.js +43 -45
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +16 -20
- package/dist/utils/Container/setupNesting.test.js +27 -30
- package/dist/utils/Container/showContainer.js +3 -7
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +38 -48
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +18 -26
- package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +24 -30
- package/dist/utils/Data/getOptions.test.js +27 -27
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +84 -80
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/nestInRefdataOptions.js +9 -16
- package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
- package/dist/utils/Data/refDataToOptions.js +10 -13
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +13 -21
- package/dist/utils/Data/setupFormData.test.js +51 -50
- package/dist/utils/Data/setupRefDataUrlForComponent.js +20 -26
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +5 -9
- package/dist/utils/FormPage/applyConditionalProperties.test.js +15 -18
- package/dist/utils/FormPage/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- package/dist/utils/FormPage/getFormPage.js +15 -16
- package/dist/utils/FormPage/getFormPage.test.js +47 -46
- package/dist/utils/FormPage/getFormPages.js +7 -12
- package/dist/utils/FormPage/getFormPages.test.js +20 -23
- package/dist/utils/FormPage/getPageActions.js +9 -15
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +2 -4
- package/dist/utils/FormPage/showFormPage.js +3 -7
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +21 -28
- package/dist/utils/FormPage/useComponent.test.js +77 -79
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +5 -6
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +13 -16
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +28 -31
- package/dist/utils/Hub/index.js +1 -1
- 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 +24 -16
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +14 -16
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +68 -34
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -52
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +22 -20
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +35 -36
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +21 -27
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +6 -6
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +7 -11
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -41
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +8 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +64 -32
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +14 -16
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +28 -26
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +19 -25
- package/dist/utils/Validate/validateCollection.test.js +74 -66
- package/dist/utils/Validate/validateComponent.js +17 -15
- package/dist/utils/Validate/validateComponent.test.js +167 -146
- package/dist/utils/Validate/validateContainer.js +15 -20
- package/dist/utils/Validate/validateContainer.test.js +58 -52
- package/dist/utils/Validate/validateDate.js +15 -21
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +6 -8
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +19 -22
- package/dist/utils/Validate/validatePage.test.js +215 -203
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +11 -18
- package/dist/utils/Validate/validateTime.test.js +16 -16
- package/dist/utils/index.js +7 -9
- package/package.json +2 -2
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-data.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-form.json +0 -61
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-after.json +0 -429
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-before.json +0 -449
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-form.json +0 -15219
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-after.json +0 -516
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-before.json +0 -593
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab2-form.json +0 -15219
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-after.json +0 -84
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-before.json +0 -98
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-form.json +0 -9158
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collection-data-removed.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collections.json +0 -8
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components.json +0 -5
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-entire-collection-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-component-removed.json +0 -10
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-components.json +0 -11
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-for-nested-components.json +0 -96
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections-delete-entire.json +0 -47
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections.json +0 -46
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-components.json +0 -48
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test.json +0 -1605
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test2.json +0 -205
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +0 -206
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +0 -143
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +0 -26
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.test.js +0 -56
|
@@ -4,32 +4,30 @@ var _models = require("../../models");
|
|
|
4
4
|
var _setupTests = require("../../setupTests");
|
|
5
5
|
var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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 = {
|
|
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,27 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
151
149
|
});
|
|
152
150
|
});
|
|
153
151
|
});
|
|
154
|
-
it('should get an appropriate row for a container with a single readonly text component inside a nested container',
|
|
155
|
-
|
|
152
|
+
it('should get an appropriate row for a container with a single readonly text component inside a nested container', () => {
|
|
153
|
+
const FORM_DATA = {
|
|
156
154
|
container: {
|
|
157
155
|
nested: {
|
|
158
156
|
a: 'Bravo'
|
|
159
157
|
}
|
|
160
158
|
}
|
|
161
159
|
};
|
|
162
|
-
|
|
160
|
+
const PAGE = {
|
|
163
161
|
id: 'page',
|
|
164
162
|
formData: FORM_DATA,
|
|
165
163
|
cya_link: {}
|
|
166
164
|
};
|
|
167
|
-
|
|
165
|
+
const COMPONENT = {
|
|
168
166
|
type: 'text',
|
|
169
167
|
readonly: true,
|
|
170
168
|
id: 'a',
|
|
171
169
|
fieldId: 'a',
|
|
172
170
|
label: 'Alpha'
|
|
173
171
|
};
|
|
174
|
-
|
|
172
|
+
const NESTED_CONTAINER = {
|
|
175
173
|
id: 'nested',
|
|
176
174
|
fieldId: 'nested',
|
|
177
175
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -179,7 +177,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
179
177
|
value: FORM_DATA.container.nested,
|
|
180
178
|
formData: FORM_DATA
|
|
181
179
|
};
|
|
182
|
-
|
|
180
|
+
const CONTAINER = {
|
|
183
181
|
id: 'container',
|
|
184
182
|
fieldId: 'container',
|
|
185
183
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -187,10 +185,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
187
185
|
value: FORM_DATA.container,
|
|
188
186
|
formData: FORM_DATA
|
|
189
187
|
};
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
const ON_ACTION = () => {};
|
|
189
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
192
190
|
expect(ROWS.length).toEqual(1);
|
|
193
|
-
ROWS.forEach(
|
|
191
|
+
ROWS.forEach((row, index) => {
|
|
194
192
|
(0, _setupTests.expectObjectLike)(row, {
|
|
195
193
|
pageId: PAGE.id,
|
|
196
194
|
fieldId: NESTED_CONTAINER.components[index].fieldId,
|
|
@@ -201,36 +199,36 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
201
199
|
});
|
|
202
200
|
});
|
|
203
201
|
});
|
|
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
|
-
|
|
202
|
+
it('should get an appropriate row for a container with a single readonly text component inside a nested container but no formData', () => {
|
|
203
|
+
const FORM_DATA = undefined;
|
|
204
|
+
const PAGE = {
|
|
207
205
|
id: 'page',
|
|
208
206
|
formData: FORM_DATA,
|
|
209
207
|
cya_link: {}
|
|
210
208
|
};
|
|
211
|
-
|
|
209
|
+
const COMPONENT = {
|
|
212
210
|
type: 'text',
|
|
213
211
|
readonly: true,
|
|
214
212
|
id: 'a',
|
|
215
213
|
fieldId: 'a',
|
|
216
214
|
label: 'Alpha'
|
|
217
215
|
};
|
|
218
|
-
|
|
216
|
+
const NESTED_CONTAINER = {
|
|
219
217
|
id: 'nested',
|
|
220
218
|
fieldId: 'nested',
|
|
221
219
|
type: _models.ComponentTypes.CONTAINER,
|
|
222
220
|
components: [COMPONENT]
|
|
223
221
|
};
|
|
224
|
-
|
|
222
|
+
const CONTAINER = {
|
|
225
223
|
id: 'container',
|
|
226
224
|
fieldId: 'container',
|
|
227
225
|
type: _models.ComponentTypes.CONTAINER,
|
|
228
226
|
components: [NESTED_CONTAINER]
|
|
229
227
|
};
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
const ON_ACTION = () => {};
|
|
229
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, undefined, ON_ACTION);
|
|
232
230
|
expect(ROWS.length).toEqual(1);
|
|
233
|
-
ROWS.forEach(
|
|
231
|
+
ROWS.forEach((row, index) => {
|
|
234
232
|
(0, _setupTests.expectObjectLike)(row, {
|
|
235
233
|
pageId: PAGE.id,
|
|
236
234
|
fieldId: NESTED_CONTAINER.components[index].fieldId,
|
|
@@ -241,15 +239,21 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
241
239
|
});
|
|
242
240
|
});
|
|
243
241
|
});
|
|
244
|
-
it('should get an appropriate row for a collection with a single text component inside a container',
|
|
245
|
-
|
|
246
|
-
|
|
242
|
+
it('should get an appropriate row for a collection with a single text component inside a container', () => {
|
|
243
|
+
const FORM_DATA = {
|
|
244
|
+
[OUTER_ID]: [{
|
|
245
|
+
[INNER_ID]: 'Bravo'
|
|
246
|
+
}, {
|
|
247
|
+
[INNER_ID]: 'Charlie'
|
|
248
|
+
}]
|
|
249
|
+
};
|
|
250
|
+
const PAGE = {
|
|
247
251
|
id: 'page',
|
|
248
252
|
formData: FORM_DATA,
|
|
249
253
|
cya_link: {},
|
|
250
254
|
collection: 'collectionName'
|
|
251
255
|
};
|
|
252
|
-
|
|
256
|
+
const COLLECTION_COMPONENT = {
|
|
253
257
|
type: 'collection',
|
|
254
258
|
id: OUTER_ID,
|
|
255
259
|
fieldId: OUTER_ID,
|
|
@@ -261,7 +265,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
261
265
|
type: 'text'
|
|
262
266
|
}]
|
|
263
267
|
};
|
|
264
|
-
|
|
268
|
+
const CONTAINER = {
|
|
265
269
|
id: 'container',
|
|
266
270
|
fieldId: 'container',
|
|
267
271
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -269,9 +273,9 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
269
273
|
value: FORM_DATA.container,
|
|
270
274
|
formData: FORM_DATA
|
|
271
275
|
};
|
|
272
|
-
|
|
276
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA, () => {});
|
|
273
277
|
expect(ROWS.length).toEqual(4);
|
|
274
|
-
|
|
278
|
+
const checkTitleRow = (index, row) => {
|
|
275
279
|
expect(row).toEqual({
|
|
276
280
|
pageId: PAGE.id,
|
|
277
281
|
fieldId: CONTAINER.components[0].fieldId,
|
|
@@ -281,7 +285,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
281
285
|
type: 'title'
|
|
282
286
|
});
|
|
283
287
|
};
|
|
284
|
-
|
|
288
|
+
const checkValueRow = (index, row, value) => {
|
|
285
289
|
(0, _setupTests.expectObjectLike)(row, {
|
|
286
290
|
pageId: PAGE.id,
|
|
287
291
|
fieldId: INNER_ID,
|
|
@@ -294,7 +298,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
294
298
|
label: INNER_ID,
|
|
295
299
|
type: 'text'
|
|
296
300
|
},
|
|
297
|
-
value
|
|
301
|
+
value,
|
|
298
302
|
full_path: "".concat(OUTER_ID, "[").concat(index, "].").concat(INNER_ID)
|
|
299
303
|
});
|
|
300
304
|
};
|
|
@@ -303,23 +307,27 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
303
307
|
checkTitleRow(1, ROWS[2]);
|
|
304
308
|
checkValueRow(1, ROWS[3], 'Charlie');
|
|
305
309
|
});
|
|
306
|
-
it('should conditionally show an appropriate row for a single text component inside a container belonging to a partial-collection',
|
|
307
|
-
|
|
310
|
+
it('should conditionally show an appropriate row for a single text component inside a container belonging to a partial-collection', () => {
|
|
311
|
+
const FORM_DATA = {
|
|
308
312
|
collectionName: [{
|
|
309
|
-
container:
|
|
313
|
+
container: {
|
|
314
|
+
[INNER_ID]: 'Bravo'
|
|
315
|
+
},
|
|
310
316
|
other_data: true
|
|
311
317
|
}, {
|
|
312
|
-
container:
|
|
318
|
+
container: {
|
|
319
|
+
[INNER_ID]: 'Charlie'
|
|
320
|
+
},
|
|
313
321
|
other_data: false
|
|
314
322
|
}]
|
|
315
323
|
};
|
|
316
|
-
|
|
324
|
+
const PAGE = {
|
|
317
325
|
id: 'page',
|
|
318
326
|
formData: FORM_DATA,
|
|
319
327
|
cya_link: {},
|
|
320
328
|
collection: 'collectionName'
|
|
321
329
|
};
|
|
322
|
-
|
|
330
|
+
const CONTAINER = {
|
|
323
331
|
id: 'container',
|
|
324
332
|
fieldId: 'container',
|
|
325
333
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -336,27 +344,27 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
336
344
|
value: true
|
|
337
345
|
}
|
|
338
346
|
};
|
|
339
|
-
expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[0],
|
|
340
|
-
expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[1],
|
|
347
|
+
expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[0], () => {}).length).toEqual(1);
|
|
348
|
+
expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[1], () => {})).toBeFalsy();
|
|
341
349
|
});
|
|
342
|
-
it('should get the appropriate number for rows components with nested components inside a container',
|
|
343
|
-
|
|
350
|
+
it('should get the appropriate number for rows components with nested components inside a container', () => {
|
|
351
|
+
const FORM_DATA = {
|
|
344
352
|
container: {
|
|
345
353
|
a: 'B',
|
|
346
354
|
nested: 'Bravo'
|
|
347
355
|
}
|
|
348
356
|
};
|
|
349
|
-
|
|
357
|
+
const PAGE = {
|
|
350
358
|
id: 'page',
|
|
351
359
|
formData: FORM_DATA,
|
|
352
360
|
cya_link: {}
|
|
353
361
|
};
|
|
354
|
-
|
|
362
|
+
const NESTED_COMPONENT = {
|
|
355
363
|
id: 'nested',
|
|
356
364
|
fieldId: 'nested',
|
|
357
365
|
type: _models.ComponentTypes.TEXT
|
|
358
366
|
};
|
|
359
|
-
|
|
367
|
+
const COMPONENT = {
|
|
360
368
|
type: 'radios',
|
|
361
369
|
id: 'a',
|
|
362
370
|
fieldId: 'a',
|
|
@@ -372,7 +380,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
372
380
|
}]
|
|
373
381
|
}
|
|
374
382
|
};
|
|
375
|
-
|
|
383
|
+
const CONTAINER = {
|
|
376
384
|
id: 'container',
|
|
377
385
|
fieldId: 'container',
|
|
378
386
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -380,35 +388,35 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
380
388
|
value: FORM_DATA.container,
|
|
381
389
|
formData: FORM_DATA
|
|
382
390
|
};
|
|
383
|
-
|
|
384
|
-
|
|
391
|
+
const ON_ACTION = () => {};
|
|
392
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
385
393
|
expect(ROWS.length).toEqual(2);
|
|
386
394
|
});
|
|
387
|
-
it('should ignore the result of the override function if it returns nullish',
|
|
388
|
-
|
|
395
|
+
it('should ignore the result of the override function if it returns nullish', () => {
|
|
396
|
+
const FORM_DATA = {
|
|
389
397
|
container: {
|
|
390
398
|
a: 'Alpha Charlie',
|
|
391
399
|
b: 'Bravo Charlie'
|
|
392
400
|
}
|
|
393
401
|
};
|
|
394
|
-
|
|
402
|
+
const PAGE = {
|
|
395
403
|
id: 'page',
|
|
396
404
|
formData: FORM_DATA,
|
|
397
405
|
cya_link: {}
|
|
398
406
|
};
|
|
399
|
-
|
|
407
|
+
const COMPONENT_A = {
|
|
400
408
|
type: 'text',
|
|
401
409
|
id: 'a',
|
|
402
410
|
fieldId: 'a',
|
|
403
411
|
label: 'Alpha'
|
|
404
412
|
};
|
|
405
|
-
|
|
413
|
+
const COMPONENT_B = {
|
|
406
414
|
type: 'text',
|
|
407
415
|
id: 'b',
|
|
408
416
|
fieldId: 'b',
|
|
409
417
|
label: 'Bravo'
|
|
410
418
|
};
|
|
411
|
-
|
|
419
|
+
const CONTAINER = {
|
|
412
420
|
id: 'container',
|
|
413
421
|
fieldId: 'container',
|
|
414
422
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -416,12 +424,10 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
416
424
|
value: FORM_DATA.container,
|
|
417
425
|
formData: FORM_DATA
|
|
418
426
|
};
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
return null;
|
|
422
|
-
});
|
|
427
|
+
const ON_ACTION = () => {};
|
|
428
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION, () => null);
|
|
423
429
|
expect(ROWS.length).toEqual(2);
|
|
424
|
-
ROWS.forEach(
|
|
430
|
+
ROWS.forEach((row, index) => {
|
|
425
431
|
(0, _setupTests.expectObjectLike)(row, {
|
|
426
432
|
pageId: PAGE.id,
|
|
427
433
|
fieldId: CONTAINER.components[index].fieldId,
|
|
@@ -434,31 +440,31 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
434
440
|
});
|
|
435
441
|
});
|
|
436
442
|
});
|
|
437
|
-
it('should use rows produced by the override function if provided',
|
|
438
|
-
|
|
443
|
+
it('should use rows produced by the override function if provided', () => {
|
|
444
|
+
const FORM_DATA = {
|
|
439
445
|
container: {
|
|
440
446
|
a: 'Alpha Charlie',
|
|
441
447
|
b: 'Bravo Charlie'
|
|
442
448
|
}
|
|
443
449
|
};
|
|
444
|
-
|
|
450
|
+
const PAGE = {
|
|
445
451
|
id: 'page',
|
|
446
452
|
formData: FORM_DATA,
|
|
447
453
|
cya_link: {}
|
|
448
454
|
};
|
|
449
|
-
|
|
455
|
+
const COMPONENT_A = {
|
|
450
456
|
type: 'text',
|
|
451
457
|
id: 'a',
|
|
452
458
|
fieldId: 'a',
|
|
453
459
|
label: 'Alpha'
|
|
454
460
|
};
|
|
455
|
-
|
|
461
|
+
const COMPONENT_B = {
|
|
456
462
|
type: 'text',
|
|
457
463
|
id: 'b',
|
|
458
464
|
fieldId: 'b',
|
|
459
465
|
label: 'Bravo'
|
|
460
466
|
};
|
|
461
|
-
|
|
467
|
+
const CONTAINER = {
|
|
462
468
|
id: 'container',
|
|
463
469
|
fieldId: 'container',
|
|
464
470
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -466,16 +472,16 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
466
472
|
value: FORM_DATA.container,
|
|
467
473
|
formData: FORM_DATA
|
|
468
474
|
};
|
|
469
|
-
|
|
475
|
+
const ON_ACTION = () => {};
|
|
470
476
|
// eslint-disable-next-line arrow-body-style
|
|
471
|
-
|
|
477
|
+
const OVERRIDE = (page, comp) => {
|
|
472
478
|
// This will be called for each component in the container,
|
|
473
479
|
// returning a custom row object.
|
|
474
480
|
return {
|
|
475
481
|
key: "CustomRowFor".concat(comp.label)
|
|
476
482
|
};
|
|
477
483
|
};
|
|
478
|
-
|
|
484
|
+
const ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION, OVERRIDE);
|
|
479
485
|
expect(ROWS.length).toEqual(2);
|
|
480
486
|
expect(ROWS).toEqual([{
|
|
481
487
|
key: 'CustomRowForAlpha'
|
|
@@ -9,7 +9,7 @@ var _models = require("../../models");
|
|
|
9
9
|
var _FormPage = _interopRequireDefault(require("../FormPage"));
|
|
10
10
|
var _getCYARow = _interopRequireDefault(require("./getCYARow"));
|
|
11
11
|
var _getCYARowsForCollectionPage = _interopRequireDefault(require("./getCYARowsForCollectionPage"));
|
|
12
|
-
var
|
|
12
|
+
var _getCYARowForGroup = _interopRequireDefault(require("./getCYARowForGroup"));
|
|
13
13
|
var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
|
|
14
14
|
var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
|
|
15
15
|
var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
|
|
@@ -25,19 +25,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
*
|
|
26
26
|
* @returns An array of configuration objects for Check your answers rows.
|
|
27
27
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const getCYARowsForPage = function (page, onAction) {
|
|
29
|
+
let fnOverride = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
30
30
|
if (_FormPage.default.showCYA(page, page.formData)) {
|
|
31
31
|
var _page$groups;
|
|
32
32
|
if (page.collection) {
|
|
33
33
|
return (0, _getCYARowsForCollectionPage.default)(page, onAction, fnOverride, page.formData);
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return (0, _showComponentCYA.default)(c, page.formData);
|
|
38
|
-
}).flatMap(function (component) {
|
|
35
|
+
const allComponents = (0, _elevateNestedComponents.default)(page.components, page.formData);
|
|
36
|
+
const rows = allComponents.filter(c => (0, _showComponentCYA.default)(c, page.formData)).flatMap(component => {
|
|
39
37
|
if (typeof fnOverride === 'function') {
|
|
40
|
-
|
|
38
|
+
const overrideRows = fnOverride(page, component, onAction);
|
|
41
39
|
if (overrideRows) {
|
|
42
40
|
return overrideRows;
|
|
43
41
|
}
|
|
@@ -52,22 +50,19 @@ var getCYARowsForPage = function getCYARowsForPage(page, onAction) {
|
|
|
52
50
|
}
|
|
53
51
|
});
|
|
54
52
|
if (((_page$groups = page.groups) === null || _page$groups === void 0 ? void 0 : _page$groups.length) > 0) {
|
|
55
|
-
page.groups.forEach(
|
|
56
|
-
|
|
57
|
-
row
|
|
58
|
-
insertAt
|
|
53
|
+
page.groups.forEach(group => {
|
|
54
|
+
const {
|
|
55
|
+
row,
|
|
56
|
+
insertAt
|
|
57
|
+
} = (0, _getCYARowForGroup.default)(page, group, rows, onAction);
|
|
59
58
|
if (insertAt > -1) {
|
|
60
59
|
rows.splice(insertAt, 0, row);
|
|
61
60
|
} else {
|
|
62
61
|
rows.push(row);
|
|
63
62
|
}
|
|
64
63
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
return rows.filter(function (r) {
|
|
69
|
-
return !allReplacedIds.includes(r.id);
|
|
70
|
-
});
|
|
64
|
+
const allReplacedIds = page.groups.flatMap(g => g.components);
|
|
65
|
+
return rows.filter(r => !allReplacedIds.includes(r.id));
|
|
71
66
|
}
|
|
72
67
|
return rows;
|
|
73
68
|
}
|