@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,34 +4,30 @@ var _setupTests = require("../../setupTests");
|
|
|
4
4
|
var _models = require("../../models");
|
|
5
5
|
var _getCYARowsForPage = _interopRequireDefault(require("./getCYARowsForPage"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
describe('CheckYourAnswers', function () {
|
|
15
|
-
describe('getCYARowsForPage', function () {
|
|
16
|
-
it('should get a appropriate row for a page with a single readonly text component', function () {
|
|
17
|
-
var COMPONENT = {
|
|
7
|
+
// Local imports
|
|
8
|
+
|
|
9
|
+
describe('utils', () => {
|
|
10
|
+
describe('CheckYourAnswers', () => {
|
|
11
|
+
describe('getCYARowsForPage', () => {
|
|
12
|
+
it('should get a appropriate row for a page with a single readonly text component', () => {
|
|
13
|
+
const COMPONENT = {
|
|
18
14
|
type: 'text',
|
|
19
15
|
readonly: true,
|
|
20
16
|
id: 'a',
|
|
21
17
|
fieldId: 'a',
|
|
22
18
|
label: 'Alpha'
|
|
23
19
|
};
|
|
24
|
-
|
|
20
|
+
const PAGE = {
|
|
25
21
|
id: 'page',
|
|
26
22
|
components: [COMPONENT],
|
|
27
23
|
formData: {
|
|
28
24
|
a: 'Bravo'
|
|
29
25
|
}
|
|
30
26
|
};
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const ON_ACTION = () => {};
|
|
28
|
+
const ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
33
29
|
expect(ROWS.length).toEqual(1);
|
|
34
|
-
ROWS.forEach(
|
|
30
|
+
ROWS.forEach((row, index) => {
|
|
35
31
|
(0, _setupTests.expectObjectLike)(row, {
|
|
36
32
|
pageId: PAGE.id,
|
|
37
33
|
fieldId: PAGE.components[index].fieldId,
|
|
@@ -42,20 +38,20 @@ describe('utils', function () {
|
|
|
42
38
|
});
|
|
43
39
|
});
|
|
44
40
|
});
|
|
45
|
-
it('should get appropriate rows for a page with two editable text components',
|
|
46
|
-
|
|
41
|
+
it('should get appropriate rows for a page with two editable text components', () => {
|
|
42
|
+
const COMPONENT_A = {
|
|
47
43
|
type: 'text',
|
|
48
44
|
id: 'a',
|
|
49
45
|
fieldId: 'a',
|
|
50
46
|
label: 'Alpha'
|
|
51
47
|
};
|
|
52
|
-
|
|
48
|
+
const COMPONENT_B = {
|
|
53
49
|
type: 'text',
|
|
54
50
|
id: 'b',
|
|
55
51
|
fieldId: 'b',
|
|
56
52
|
label: 'Bravo'
|
|
57
53
|
};
|
|
58
|
-
|
|
54
|
+
const PAGE = {
|
|
59
55
|
id: 'page',
|
|
60
56
|
components: [COMPONENT_A, COMPONENT_B],
|
|
61
57
|
formData: {
|
|
@@ -64,10 +60,10 @@ describe('utils', function () {
|
|
|
64
60
|
},
|
|
65
61
|
cya_link: {}
|
|
66
62
|
};
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
const ON_ACTION = () => {};
|
|
64
|
+
const ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
69
65
|
expect(ROWS.length).toEqual(2);
|
|
70
|
-
ROWS.forEach(
|
|
66
|
+
ROWS.forEach((row, index) => {
|
|
71
67
|
(0, _setupTests.expectObjectLike)(row, {
|
|
72
68
|
pageId: PAGE.id,
|
|
73
69
|
fieldId: PAGE.components[index].fieldId,
|
|
@@ -80,24 +76,24 @@ describe('utils', function () {
|
|
|
80
76
|
});
|
|
81
77
|
});
|
|
82
78
|
});
|
|
83
|
-
it("should filter out any components that shouldn't be shown",
|
|
84
|
-
|
|
79
|
+
it("should filter out any components that shouldn't be shown", () => {
|
|
80
|
+
const COMPONENT_A = {
|
|
85
81
|
type: 'text',
|
|
86
82
|
id: 'a',
|
|
87
83
|
fieldId: 'a',
|
|
88
84
|
label: 'Alpha'
|
|
89
85
|
};
|
|
90
|
-
|
|
86
|
+
const COMPONENT_B = {
|
|
91
87
|
type: 'text',
|
|
92
88
|
id: 'b',
|
|
93
89
|
fieldId: 'b',
|
|
94
90
|
label: 'Bravo'
|
|
95
91
|
};
|
|
96
|
-
|
|
92
|
+
const COMPONENT_C = {
|
|
97
93
|
type: 'heading',
|
|
98
94
|
content: 'Heading component'
|
|
99
95
|
};
|
|
100
|
-
|
|
96
|
+
const PAGE = {
|
|
101
97
|
id: 'page',
|
|
102
98
|
components: [COMPONENT_A, COMPONENT_B, COMPONENT_C],
|
|
103
99
|
formData: {
|
|
@@ -106,10 +102,10 @@ describe('utils', function () {
|
|
|
106
102
|
},
|
|
107
103
|
cya_link: {}
|
|
108
104
|
};
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
const ON_ACTION = () => {};
|
|
106
|
+
const ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
111
107
|
expect(ROWS.length).toEqual(2);
|
|
112
|
-
ROWS.forEach(
|
|
108
|
+
ROWS.forEach((row, index) => {
|
|
113
109
|
(0, _setupTests.expectObjectLike)(row, {
|
|
114
110
|
pageId: PAGE.id,
|
|
115
111
|
fieldId: PAGE.components[index].fieldId,
|
|
@@ -122,20 +118,20 @@ describe('utils', function () {
|
|
|
122
118
|
});
|
|
123
119
|
});
|
|
124
120
|
});
|
|
125
|
-
it('should get a appropriate row for a page with a single readonly text component inside of a container',
|
|
126
|
-
|
|
121
|
+
it('should get a appropriate row for a page with a single readonly text component inside of a container', () => {
|
|
122
|
+
const FORM_DATA = {
|
|
127
123
|
container: {
|
|
128
124
|
a: 'Bravo'
|
|
129
125
|
}
|
|
130
126
|
};
|
|
131
|
-
|
|
127
|
+
const COMPONENT = {
|
|
132
128
|
type: 'text',
|
|
133
129
|
readonly: true,
|
|
134
130
|
id: 'a',
|
|
135
131
|
fieldId: 'a',
|
|
136
132
|
label: 'Alpha'
|
|
137
133
|
};
|
|
138
|
-
|
|
134
|
+
const CONTAINER = {
|
|
139
135
|
id: 'container',
|
|
140
136
|
fieldId: 'container',
|
|
141
137
|
type: _models.ComponentTypes.CONTAINER,
|
|
@@ -143,15 +139,15 @@ describe('utils', function () {
|
|
|
143
139
|
value: FORM_DATA.container,
|
|
144
140
|
formData: FORM_DATA
|
|
145
141
|
};
|
|
146
|
-
|
|
142
|
+
const PAGE = {
|
|
147
143
|
id: 'page',
|
|
148
144
|
components: [CONTAINER],
|
|
149
145
|
formData: FORM_DATA
|
|
150
146
|
};
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
const ON_ACTION = () => {};
|
|
148
|
+
const ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
153
149
|
expect(ROWS.length).toEqual(1);
|
|
154
|
-
ROWS.forEach(
|
|
150
|
+
ROWS.forEach((row, index) => {
|
|
155
151
|
(0, _setupTests.expectObjectLike)(row, {
|
|
156
152
|
pageId: PAGE.id,
|
|
157
153
|
fieldId: CONTAINER.components[index].fieldId,
|
|
@@ -162,32 +158,32 @@ describe('utils', function () {
|
|
|
162
158
|
});
|
|
163
159
|
});
|
|
164
160
|
});
|
|
165
|
-
it('Add ability to display answers from multiple fields in a single row',
|
|
166
|
-
|
|
161
|
+
it('Add ability to display answers from multiple fields in a single row', () => {
|
|
162
|
+
const COMPONENT_ADDRESS = {
|
|
167
163
|
id: 'firstLineOfTheAddress',
|
|
168
164
|
fieldId: 'firstLineOfTheAddress',
|
|
169
165
|
label: 'address',
|
|
170
166
|
type: 'text'
|
|
171
167
|
};
|
|
172
|
-
|
|
168
|
+
const COMPONENT_TOWN = {
|
|
173
169
|
id: 'town',
|
|
174
170
|
fieldId: 'town',
|
|
175
171
|
label: 'Town',
|
|
176
172
|
type: 'text'
|
|
177
173
|
};
|
|
178
|
-
|
|
174
|
+
const COMPONENT_CITY = {
|
|
179
175
|
id: 'city',
|
|
180
176
|
fieldId: 'city',
|
|
181
177
|
label: 'City',
|
|
182
178
|
type: 'text'
|
|
183
179
|
};
|
|
184
|
-
|
|
180
|
+
const COMPONENT_POSTCODE = {
|
|
185
181
|
id: 'postCode',
|
|
186
182
|
fieldId: 'postCode',
|
|
187
183
|
label: 'postCode',
|
|
188
184
|
type: 'text'
|
|
189
185
|
};
|
|
190
|
-
|
|
186
|
+
const PAGE = {
|
|
191
187
|
components: [COMPONENT_ADDRESS, COMPONENT_TOWN, COMPONENT_CITY, COMPONENT_POSTCODE],
|
|
192
188
|
id: 'addressDetails',
|
|
193
189
|
fieldId: 'UK address',
|
|
@@ -205,36 +201,35 @@ describe('utils', function () {
|
|
|
205
201
|
postCode: 'SW1A 2AA'
|
|
206
202
|
}
|
|
207
203
|
};
|
|
208
|
-
|
|
204
|
+
const ON_ACTION = () => {};
|
|
209
205
|
// rows do not have defined keys which means cannot pass them to render as an array,
|
|
210
206
|
// so just pass the single row instead of array containing single row
|
|
211
|
-
|
|
212
|
-
return row.value;
|
|
213
|
-
});
|
|
207
|
+
const cyaRow = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION).map(row => row.value);
|
|
214
208
|
expect(cyaRow.length).toEqual(1);
|
|
215
|
-
|
|
216
|
-
container
|
|
209
|
+
const {
|
|
210
|
+
container
|
|
211
|
+
} = (0, _setupTests.renderWithValidation)(cyaRow[0]);
|
|
217
212
|
expect(container.childNodes.length).toEqual(4);
|
|
218
|
-
|
|
213
|
+
const addressValues = container.childNodes;
|
|
219
214
|
expect(addressValues[0].childNodes[0].textContent).toEqual('10 Downing Street');
|
|
220
215
|
expect(addressValues[1].childNodes[0].textContent).toEqual('City of Westminster');
|
|
221
216
|
expect(addressValues[2].childNodes[0].textContent).toEqual('London');
|
|
222
217
|
expect(addressValues[3].childNodes[0].textContent).toEqual('SW1A 2AA');
|
|
223
218
|
});
|
|
224
|
-
it('should get appropriate rows for a page with a single readonly text component within a collection',
|
|
225
|
-
|
|
219
|
+
it('should get appropriate rows for a page with a single readonly text component within a collection', () => {
|
|
220
|
+
const FORM_DATA = {
|
|
226
221
|
collection: [{
|
|
227
222
|
a: 'Bravo'
|
|
228
223
|
}]
|
|
229
224
|
};
|
|
230
|
-
|
|
225
|
+
const COMPONENT = {
|
|
231
226
|
type: 'text',
|
|
232
227
|
readonly: true,
|
|
233
228
|
id: 'a',
|
|
234
229
|
fieldId: 'a',
|
|
235
230
|
label: 'Alpha'
|
|
236
231
|
};
|
|
237
|
-
|
|
232
|
+
const COLLECTION = {
|
|
238
233
|
id: 'collection',
|
|
239
234
|
fieldId: 'collection',
|
|
240
235
|
type: _models.ComponentTypes.COLLECTION,
|
|
@@ -242,13 +237,13 @@ describe('utils', function () {
|
|
|
242
237
|
value: FORM_DATA.collection,
|
|
243
238
|
formData: FORM_DATA
|
|
244
239
|
};
|
|
245
|
-
|
|
240
|
+
const PAGE = {
|
|
246
241
|
id: 'page',
|
|
247
242
|
components: [COLLECTION],
|
|
248
243
|
formData: FORM_DATA
|
|
249
244
|
};
|
|
250
|
-
|
|
251
|
-
|
|
245
|
+
const ON_ACTION = () => {};
|
|
246
|
+
const ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
252
247
|
expect(ROWS.length).toEqual(2); // Title and item row
|
|
253
248
|
(0, _setupTests.expectObjectLike)(ROWS[1], {
|
|
254
249
|
pageId: PAGE.id,
|
|
@@ -256,26 +251,27 @@ describe('utils', function () {
|
|
|
256
251
|
full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
|
|
257
252
|
key: COMPONENT.label,
|
|
258
253
|
action: null,
|
|
259
|
-
component:
|
|
254
|
+
component: {
|
|
255
|
+
...COMPONENT,
|
|
260
256
|
full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId)
|
|
261
|
-
}
|
|
257
|
+
},
|
|
262
258
|
value: 'Bravo'
|
|
263
259
|
});
|
|
264
260
|
});
|
|
265
|
-
it('should ignore the result of the override function if it returns nullish',
|
|
266
|
-
|
|
261
|
+
it('should ignore the result of the override function if it returns nullish', () => {
|
|
262
|
+
const COMPONENT_A = {
|
|
267
263
|
type: 'text',
|
|
268
264
|
id: 'a',
|
|
269
265
|
fieldId: 'a',
|
|
270
266
|
label: 'Alpha'
|
|
271
267
|
};
|
|
272
|
-
|
|
268
|
+
const COMPONENT_B = {
|
|
273
269
|
type: 'text',
|
|
274
270
|
id: 'b',
|
|
275
271
|
fieldId: 'b',
|
|
276
272
|
label: 'Bravo'
|
|
277
273
|
};
|
|
278
|
-
|
|
274
|
+
const PAGE = {
|
|
279
275
|
id: 'page',
|
|
280
276
|
components: [COMPONENT_A, COMPONENT_B],
|
|
281
277
|
formData: {
|
|
@@ -284,12 +280,10 @@ describe('utils', function () {
|
|
|
284
280
|
},
|
|
285
281
|
cya_link: {}
|
|
286
282
|
};
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
return null;
|
|
290
|
-
});
|
|
283
|
+
const ON_ACTION = () => {};
|
|
284
|
+
const ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION, () => null);
|
|
291
285
|
expect(ROWS.length).toEqual(2);
|
|
292
|
-
ROWS.forEach(
|
|
286
|
+
ROWS.forEach((row, index) => {
|
|
293
287
|
(0, _setupTests.expectObjectLike)(row, {
|
|
294
288
|
pageId: PAGE.id,
|
|
295
289
|
fieldId: PAGE.components[index].fieldId,
|
|
@@ -302,20 +296,20 @@ describe('utils', function () {
|
|
|
302
296
|
});
|
|
303
297
|
});
|
|
304
298
|
});
|
|
305
|
-
it('should use rows produced by the override function if provided',
|
|
306
|
-
|
|
299
|
+
it('should use rows produced by the override function if provided', () => {
|
|
300
|
+
const COMPONENT_A = {
|
|
307
301
|
type: 'text',
|
|
308
302
|
id: 'a',
|
|
309
303
|
fieldId: 'a',
|
|
310
304
|
label: 'Alpha'
|
|
311
305
|
};
|
|
312
|
-
|
|
306
|
+
const COMPONENT_B = {
|
|
313
307
|
type: 'text',
|
|
314
308
|
id: 'b',
|
|
315
309
|
fieldId: 'b',
|
|
316
310
|
label: 'Bravo'
|
|
317
311
|
};
|
|
318
|
-
|
|
312
|
+
const PAGE = {
|
|
319
313
|
id: 'page',
|
|
320
314
|
components: [COMPONENT_A, COMPONENT_B],
|
|
321
315
|
formData: {
|
|
@@ -324,16 +318,16 @@ describe('utils', function () {
|
|
|
324
318
|
},
|
|
325
319
|
cya_link: {}
|
|
326
320
|
};
|
|
327
|
-
|
|
321
|
+
const ON_ACTION = () => {};
|
|
328
322
|
// eslint-disable-next-line arrow-body-style
|
|
329
|
-
|
|
323
|
+
const OVERRIDE = (page, comp) => {
|
|
330
324
|
// This will be called for each component on the page,
|
|
331
325
|
// returning a custom row object.
|
|
332
326
|
return {
|
|
333
327
|
key: "CustomRowFor".concat(comp.label)
|
|
334
328
|
};
|
|
335
329
|
};
|
|
336
|
-
|
|
330
|
+
const ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION, OVERRIDE);
|
|
337
331
|
expect(ROWS.length).toEqual(2);
|
|
338
332
|
expect(ROWS).toEqual([{
|
|
339
333
|
key: 'CustomRowForAlpha'
|
|
@@ -9,17 +9,17 @@ var _Answer = _interopRequireDefault(require("../../components/CheckYourAnswers/
|
|
|
9
9
|
var _SummaryListRow = _interopRequireDefault(require("../../components/SummaryList/SummaryListRow"));
|
|
10
10
|
var _getCYARow = _interopRequireDefault(require("./getCYARow"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
12
|
+
// Local imports
|
|
13
|
+
|
|
14
|
+
const getComponentRowForCYA = (page, component, customClasses, entryData) => {
|
|
15
|
+
const modifiedPage = {
|
|
16
|
+
...page,
|
|
17
|
+
formData: {
|
|
18
|
+
...page.formData,
|
|
19
|
+
...entryData
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const row = (0, _getCYARow.default)(modifiedPage, component);
|
|
23
23
|
return /*#__PURE__*/_react.default.createElement(_SummaryListRow.default, {
|
|
24
24
|
key: "".concat(row.fieldId),
|
|
25
25
|
row: {
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
var _getCYARowsForPage = _interopRequireDefault(require("./getCYARowsForPage"));
|
|
4
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
|
-
describe('utils.CheckYourAnswers.getCYARowsForPage',
|
|
6
|
-
|
|
5
|
+
describe('utils.CheckYourAnswers.getCYARowsForPage', () => {
|
|
6
|
+
const COMPONENT_A = {
|
|
7
7
|
type: 'text',
|
|
8
8
|
id: 'a',
|
|
9
9
|
fieldId: 'a',
|
|
10
10
|
label: 'Alpha'
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
const COMPONENT_B = {
|
|
13
13
|
type: 'text',
|
|
14
14
|
id: 'b',
|
|
15
15
|
fieldId: 'b',
|
|
16
16
|
label: 'Bravo'
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
const PAGE = {
|
|
19
19
|
id: 'page',
|
|
20
20
|
components: [COMPONENT_A, COMPONENT_B],
|
|
21
21
|
formData: {
|
|
@@ -23,9 +23,9 @@ describe('utils.CheckYourAnswers.getCYARowsForPage', function () {
|
|
|
23
23
|
b: 'Bravo Value'
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
it('should get rows for a page with readonly text components',
|
|
28
|
-
|
|
26
|
+
const ON_ACTION = () => {};
|
|
27
|
+
it('should get rows for a page with readonly text components', () => {
|
|
28
|
+
const rows = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
29
29
|
expect(rows.length).toEqual(2);
|
|
30
30
|
expect(rows[0]).toEqual(expect.objectContaining({
|
|
31
31
|
fieldId: COMPONENT_A.fieldId,
|
|
@@ -8,7 +8,7 @@ var _getCYARowsForPage = _interopRequireDefault(require("./getCYARowsForPage"));
|
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
9
|
// Local imports
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const CheckYourAnswers = {
|
|
12
12
|
getRows: _getCYARowsForPage.default
|
|
13
13
|
};
|
|
14
14
|
var _default = exports.default = CheckYourAnswers;
|
|
@@ -11,7 +11,7 @@ var _getSourceData = _interopRequireDefault(require("../Data/getSourceData"));
|
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
// Local imports
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const EXCLUDE_FROM_CYA = exports.EXCLUDE_FROM_CYA = [_models.ComponentTypes.ALERT, _models.ComponentTypes.COLLECTION_SUMMARY, _models.ComponentTypes.DETAILS, _models.ComponentTypes.HEADING, _models.ComponentTypes.HTML, _models.ComponentTypes.INSET_TEXT];
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Determines whether a given component should display on the Check your answers screen.
|
|
@@ -21,7 +21,7 @@ var EXCLUDE_FROM_CYA = exports.EXCLUDE_FROM_CYA = [_models.ComponentTypes.ALERT,
|
|
|
21
21
|
*
|
|
22
22
|
* @returns A boolean true if the component should show; otherwise false.
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
const showComponentCYA = (options, data) => {
|
|
25
25
|
if (!options) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
@@ -33,12 +33,12 @@ var showComponentCYA = function showComponentCYA(options, data) {
|
|
|
33
33
|
}
|
|
34
34
|
if (options.hideOnCyaWhenEmpty) {
|
|
35
35
|
if (options.type === _models.ComponentTypes.COLLECTION) {
|
|
36
|
-
|
|
36
|
+
const itemCollectionsData = (0, _getSourceData.default)(data, options.full_path);
|
|
37
37
|
if (!(itemCollectionsData !== null && itemCollectionsData !== void 0 && itemCollectionsData.length)) {
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
40
|
} else {
|
|
41
|
-
|
|
41
|
+
const value = (0, _getSourceData.default)(data, options.fieldId);
|
|
42
42
|
if (!value && value !== false && value !== 0) {
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
@@ -5,86 +5,86 @@ var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
|
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
6
|
// Local imports
|
|
7
7
|
|
|
8
|
-
describe('utils',
|
|
9
|
-
describe('CheckYourAnswers',
|
|
10
|
-
describe('showComponentCYA',
|
|
11
|
-
it('should not show when there are no options',
|
|
8
|
+
describe('utils', () => {
|
|
9
|
+
describe('CheckYourAnswers', () => {
|
|
10
|
+
describe('showComponentCYA', () => {
|
|
11
|
+
it('should not show when there are no options', () => {
|
|
12
12
|
expect((0, _showComponentCYA.default)(null, null)).toBeFalsy();
|
|
13
13
|
});
|
|
14
|
-
it('should not show when show_on_cya is defined and falsy',
|
|
14
|
+
it('should not show when show_on_cya is defined and falsy', () => {
|
|
15
15
|
expect((0, _showComponentCYA.default)({
|
|
16
16
|
show_on_cya: false
|
|
17
17
|
})).toBeFalsy();
|
|
18
18
|
});
|
|
19
|
-
it('should not show when it is a heading type',
|
|
19
|
+
it('should not show when it is a heading type', () => {
|
|
20
20
|
expect((0, _showComponentCYA.default)({
|
|
21
21
|
type: _models.ComponentTypes.HEADING
|
|
22
22
|
}, null)).toBeFalsy();
|
|
23
23
|
});
|
|
24
|
-
it('should not show when it is an html type',
|
|
24
|
+
it('should not show when it is an html type', () => {
|
|
25
25
|
expect((0, _showComponentCYA.default)({
|
|
26
26
|
type: _models.ComponentTypes.HTML
|
|
27
27
|
}, null)).toBeFalsy();
|
|
28
28
|
});
|
|
29
|
-
it('should not show when it is an inset-text type',
|
|
29
|
+
it('should not show when it is an inset-text type', () => {
|
|
30
30
|
expect((0, _showComponentCYA.default)({
|
|
31
31
|
type: _models.ComponentTypes.INSET_TEXT
|
|
32
32
|
}, null)).toBeFalsy();
|
|
33
33
|
});
|
|
34
|
-
it('should not show when it is a details type',
|
|
34
|
+
it('should not show when it is a details type', () => {
|
|
35
35
|
expect((0, _showComponentCYA.default)({
|
|
36
36
|
type: _models.ComponentTypes.DETAILS
|
|
37
37
|
}, null)).toBeFalsy();
|
|
38
38
|
});
|
|
39
|
-
it('should not show when it hidden and disabled',
|
|
39
|
+
it('should not show when it hidden and disabled', () => {
|
|
40
40
|
expect((0, _showComponentCYA.default)({
|
|
41
41
|
hidden: true,
|
|
42
42
|
disabled: true
|
|
43
43
|
}, null)).toBeFalsy();
|
|
44
44
|
});
|
|
45
|
-
it('should show when show_on_cya is defined and truthy',
|
|
45
|
+
it('should show when show_on_cya is defined and truthy', () => {
|
|
46
46
|
expect((0, _showComponentCYA.default)({
|
|
47
47
|
show_on_cya: true
|
|
48
48
|
})).toBeTruthy();
|
|
49
49
|
});
|
|
50
|
-
it('should show when it hidden but not disabled',
|
|
50
|
+
it('should show when it hidden but not disabled', () => {
|
|
51
51
|
expect((0, _showComponentCYA.default)({
|
|
52
52
|
hidden: true
|
|
53
53
|
}, null)).toBeTruthy();
|
|
54
54
|
});
|
|
55
|
-
it('should show when it disabled but not hidden',
|
|
55
|
+
it('should show when it disabled but not hidden', () => {
|
|
56
56
|
expect((0, _showComponentCYA.default)({
|
|
57
57
|
disabled: true
|
|
58
58
|
}, null)).toBeTruthy();
|
|
59
59
|
});
|
|
60
|
-
it('should show when it not html, inset-text, a heading, hidden, or disabled',
|
|
60
|
+
it('should show when it not html, inset-text, a heading, hidden, or disabled', () => {
|
|
61
61
|
expect((0, _showComponentCYA.default)({
|
|
62
62
|
type: _models.ComponentTypes.TEXT
|
|
63
63
|
}, null)).toBeTruthy();
|
|
64
64
|
});
|
|
65
|
-
it('should show when hideOnCyaWhenEmpty is defined and falsy',
|
|
65
|
+
it('should show when hideOnCyaWhenEmpty is defined and falsy', () => {
|
|
66
66
|
expect((0, _showComponentCYA.default)({
|
|
67
67
|
hideOnCyaWhenEmpty: false
|
|
68
68
|
})).toBeTruthy();
|
|
69
69
|
});
|
|
70
|
-
it('should show collection when hideOnCyaWhenEmpty is not defined',
|
|
70
|
+
it('should show collection when hideOnCyaWhenEmpty is not defined', () => {
|
|
71
71
|
expect((0, _showComponentCYA.default)({
|
|
72
72
|
type: _models.ComponentTypes.COLLECTION
|
|
73
73
|
})).toBeTruthy();
|
|
74
74
|
});
|
|
75
|
-
it('should not show when it\'s a collection and hideOnCyaWhenEmpty is truthy',
|
|
75
|
+
it('should not show when it\'s a collection and hideOnCyaWhenEmpty is truthy', () => {
|
|
76
76
|
expect((0, _showComponentCYA.default)({
|
|
77
77
|
hideOnCyaWhenEmpty: true,
|
|
78
78
|
type: _models.ComponentTypes.COLLECTION
|
|
79
79
|
})).toBeFalsy();
|
|
80
80
|
});
|
|
81
|
-
it('should not show when it\'s not a collection and hideOnCyaWhenEmpty is truthy',
|
|
81
|
+
it('should not show when it\'s not a collection and hideOnCyaWhenEmpty is truthy', () => {
|
|
82
82
|
expect((0, _showComponentCYA.default)({
|
|
83
83
|
hideOnCyaWhenEmpty: true,
|
|
84
84
|
type: _models.ComponentTypes.TEXT
|
|
85
85
|
})).toBeFalsy();
|
|
86
86
|
});
|
|
87
|
-
it('should show when length of full_path data is 1 or more',
|
|
87
|
+
it('should show when length of full_path data is 1 or more', () => {
|
|
88
88
|
expect((0, _showComponentCYA.default)({
|
|
89
89
|
hideOnCyaWhenEmpty: true,
|
|
90
90
|
type: _models.ComponentTypes.COLLECTION,
|
|
@@ -93,7 +93,7 @@ describe('utils', function () {
|
|
|
93
93
|
example: [0, 1]
|
|
94
94
|
})).toBeTruthy();
|
|
95
95
|
});
|
|
96
|
-
it('should not show when length of full_path data is less than 1',
|
|
96
|
+
it('should not show when length of full_path data is less than 1', () => {
|
|
97
97
|
expect((0, _showComponentCYA.default)({
|
|
98
98
|
hideOnCyaWhenEmpty: true,
|
|
99
99
|
type: _models.ComponentTypes.COLLECTION,
|
|
@@ -102,7 +102,7 @@ describe('utils', function () {
|
|
|
102
102
|
example: []
|
|
103
103
|
})).toBeFalsy();
|
|
104
104
|
});
|
|
105
|
-
it('should show when value of component data does exist and hideOnCyaWhenEmpty is truthy',
|
|
105
|
+
it('should show when value of component data does exist and hideOnCyaWhenEmpty is truthy', () => {
|
|
106
106
|
expect((0, _showComponentCYA.default)({
|
|
107
107
|
hideOnCyaWhenEmpty: true,
|
|
108
108
|
type: _models.ComponentTypes.TEXT,
|
|
@@ -111,21 +111,21 @@ describe('utils', function () {
|
|
|
111
111
|
example: "yes"
|
|
112
112
|
})).toBeTruthy();
|
|
113
113
|
});
|
|
114
|
-
it('should not show when value of component data does not exist and hideOnCyaWhenEmpty is truthy',
|
|
114
|
+
it('should not show when value of component data does not exist and hideOnCyaWhenEmpty is truthy', () => {
|
|
115
115
|
expect((0, _showComponentCYA.default)({
|
|
116
116
|
hideOnCyaWhenEmpty: true,
|
|
117
117
|
type: _models.ComponentTypes.TEXT,
|
|
118
118
|
fieldId: "example"
|
|
119
119
|
}, {})).toBeFalsy();
|
|
120
120
|
});
|
|
121
|
-
it('should show when value of component data does not exist and hideOnCyaWhenEmpty is falsy',
|
|
121
|
+
it('should show when value of component data does not exist and hideOnCyaWhenEmpty is falsy', () => {
|
|
122
122
|
expect((0, _showComponentCYA.default)({
|
|
123
123
|
hideOnCyaWhenEmpty: false,
|
|
124
124
|
type: _models.ComponentTypes.TEXT,
|
|
125
125
|
fieldId: "example"
|
|
126
126
|
}, {})).toBeTruthy();
|
|
127
127
|
});
|
|
128
|
-
it('should show when value of component data does is falsy and hideOnCyaWhenEmpty is truthy',
|
|
128
|
+
it('should show when value of component data does is falsy and hideOnCyaWhenEmpty is truthy', () => {
|
|
129
129
|
expect((0, _showComponentCYA.default)({
|
|
130
130
|
hideOnCyaWhenEmpty: true,
|
|
131
131
|
type: _models.ComponentTypes.TEXT,
|
|
@@ -134,7 +134,7 @@ describe('utils', function () {
|
|
|
134
134
|
example: false
|
|
135
135
|
})).toBeTruthy();
|
|
136
136
|
});
|
|
137
|
-
it('should show when value of component data is numerically zero and hideOnCyaWhenEmpty is truthy',
|
|
137
|
+
it('should show when value of component data is numerically zero and hideOnCyaWhenEmpty is truthy', () => {
|
|
138
138
|
expect((0, _showComponentCYA.default)({
|
|
139
139
|
hideOnCyaWhenEmpty: true,
|
|
140
140
|
type: _models.ComponentTypes.TEXT,
|
|
@@ -15,8 +15,8 @@ exports.default = void 0;
|
|
|
15
15
|
* @param {string} collectionName The name of the collection to create the new entry for.
|
|
16
16
|
* @param {object} formData The top level formData object.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const addCollectionPageEntry = (collectionName, formData) => {
|
|
19
|
+
const fieldName = collectionName.split('.').pop();
|
|
20
20
|
formData["".concat(fieldName, "ActiveId")] = null;
|
|
21
21
|
};
|
|
22
22
|
var _default = exports.default = addCollectionPageEntry;
|