@ukhomeoffice/cop-react-form-renderer 5.45.2-alpha → 5.48.1-bravo
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 +127 -92
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +131 -101
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +769 -464
- package/dist/components/CollectionPage/CollectionPage.js +58 -66
- package/dist/components/CollectionPage/CollectionPage.test.js +342 -300
- package/dist/components/CollectionSummary/BannerStrip.js +12 -12
- package/dist/components/CollectionSummary/BannerStrip.test.js +59 -63
- package/dist/components/CollectionSummary/CollectionSummary.js +88 -61
- package/dist/components/CollectionSummary/CollectionSummary.test.js +96 -102
- package/dist/components/CollectionSummary/Confirmation.js +12 -14
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/SummaryCard.js +148 -109
- package/dist/components/CollectionSummary/SummaryCard.scss +1 -1
- package/dist/components/CollectionSummary/SummaryCard.test.js +927 -905
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +29 -23
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +73 -61
- package/dist/components/FormComponent/Collection.js +107 -73
- package/dist/components/FormComponent/Collection.test.js +945 -809
- package/dist/components/FormComponent/Container.js +38 -40
- package/dist/components/FormComponent/Container.test.js +345 -314
- package/dist/components/FormComponent/FormComponent.js +70 -67
- package/dist/components/FormComponent/FormComponent.test.js +342 -284
- package/dist/components/FormComponent/helpers/addLabel.js +7 -4
- 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 +5 -3
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +4 -3
- 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 +80 -65
- package/dist/components/FormPage/FormPage.test.js +163 -127
- package/dist/components/FormRenderer/FormRenderer.js +181 -144
- package/dist/components/FormRenderer/FormRenderer.test.js +1115 -730
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +3 -1
- 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 +5 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +47 -11
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +3 -1
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +20 -16
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -17
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +5 -3
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +24 -13
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +4 -2
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -7
- 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 +91 -97
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +73 -71
- package/dist/components/FormRenderer/helpers/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +51 -59
- package/dist/components/FormRenderer/onCYAAction.test.js +152 -164
- package/dist/components/FormRenderer/onPageAction.js +40 -44
- package/dist/components/FormRenderer/onPageAction.test.js +206 -223
- package/dist/components/FormRenderer/onTaskAction.js +13 -9
- package/dist/components/FormRenderer/onTaskAction.test.js +88 -93
- package/dist/components/PageActions/ActionButton.js +15 -12
- package/dist/components/PageActions/ActionButton.test.js +78 -56
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +115 -86
- package/dist/components/SummaryList/GroupAction.js +17 -9
- package/dist/components/SummaryList/GroupAction.test.js +33 -37
- package/dist/components/SummaryList/RowAction.js +16 -11
- package/dist/components/SummaryList/RowAction.test.js +33 -37
- package/dist/components/SummaryList/SummaryList.js +26 -21
- package/dist/components/SummaryList/SummaryList.test.js +166 -143
- package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
- package/dist/components/SummaryList/SummaryListRow.js +4 -6
- package/dist/components/SummaryList/SummaryListTitleRow.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -3
- 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 +29 -19
- package/dist/components/TaskList/Task.test.js +76 -83
- package/dist/components/TaskList/TaskList.js +71 -45
- package/dist/components/TaskList/TaskList.test.js +111 -113
- package/dist/components/TaskList/TaskState.js +5 -7
- package/dist/components/TaskList/TaskState.test.js +45 -52
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +79 -58
- package/dist/context/HooksContext/HooksContext.test.js +35 -26
- package/dist/context/HooksContext/index.js +4 -3
- package/dist/context/ValidationContext/ValidationContext.js +72 -32
- package/dist/context/ValidationContext/ValidationContext.test.js +59 -47
- package/dist/context/ValidationContext/index.js +4 -3
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +10 -9
- package/dist/hooks/useAxios.js +40 -14
- package/dist/hooks/useGetRequest.js +97 -61
- package/dist/hooks/useHooks.js +3 -1
- package/dist/hooks/useRefData.js +39 -26
- package/dist/hooks/useValidation.js +3 -1
- package/dist/index.js +14 -13
- 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 +38 -44
- package/dist/models/TaskStates.js +28 -30
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +31 -30
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +54 -52
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +25 -15
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +35 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +31 -17
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +44 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +24 -18
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +36 -33
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +60 -58
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +88 -79
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +124 -146
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +20 -25
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +97 -103
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +18 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +76 -70
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +24 -24
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +1 -1
- 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 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +18 -9
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +22 -27
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +11 -7
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +16 -12
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +30 -29
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +17 -17
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +17 -17
- package/dist/utils/Component/addShowWhen.js +8 -4
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +32 -27
- package/dist/utils/Component/cleanAttributes.js +13 -10
- package/dist/utils/Component/cleanAttributes.test.js +18 -17
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +95 -88
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +17 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +59 -46
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +48 -39
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -23
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +18 -20
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +25 -20
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +9 -10
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +8 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +26 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +175 -155
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +70 -57
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +38 -31
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +29 -20
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +8 -9
- package/dist/utils/Component/getDefaultValue.js +8 -6
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +22 -23
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +4 -2
- package/dist/utils/Component/isEditable.test.js +15 -14
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +29 -27
- 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 +7 -7
- package/dist/utils/Condition/meetsAllConditions.test.js +17 -17
- package/dist/utils/Condition/meetsCondition.js +17 -14
- package/dist/utils/Condition/meetsCondition.test.js +376 -376
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +18 -13
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +5 -3
- package/dist/utils/Container/getEditableComponents.test.js +45 -43
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +20 -16
- package/dist/utils/Container/setupNesting.test.js +30 -27
- package/dist/utils/Container/showContainer.js +7 -3
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +48 -38
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +26 -18
- package/dist/utils/Data/getAutocompleteSource.test.js +86 -80
- package/dist/utils/Data/getDataPath.js +28 -18
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +25 -19
- package/dist/utils/Data/getOptions.test.js +20 -20
- package/dist/utils/Data/getSourceData.js +19 -6
- package/dist/utils/Data/getSourceData.test.js +80 -84
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/refDataToOptions.js +13 -10
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +8 -7
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +21 -13
- package/dist/utils/Data/setupFormData.test.js +50 -51
- package/dist/utils/Data/setupRefDataUrlForComponent.js +26 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +9 -5
- package/dist/utils/FormPage/applyConditionalProperties.test.js +18 -15
- package/dist/utils/FormPage/getFormPage.js +16 -15
- package/dist/utils/FormPage/getFormPage.test.js +46 -47
- package/dist/utils/FormPage/getFormPages.js +12 -7
- package/dist/utils/FormPage/getFormPages.test.js +23 -20
- package/dist/utils/FormPage/getPageActions.js +15 -9
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getPageTitle.js +2 -2
- package/dist/utils/FormPage/getPageTitle.test.js +22 -22
- package/dist/utils/FormPage/getParagraphFromText.js +7 -5
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +1 -1
- package/dist/utils/FormPage/showFormPage.js +7 -3
- 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 +28 -21
- package/dist/utils/FormPage/useComponent.test.js +79 -78
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +6 -5
- package/dist/utils/Format/formatDataForComponent.test.js +77 -50
- package/dist/utils/Format/formatDataForForm.js +8 -6
- package/dist/utils/Format/formatDataForForm.test.js +15 -13
- package/dist/utils/Format/formatDataForPage.js +5 -4
- package/dist/utils/Format/formatDataForPage.test.js +23 -20
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +31 -28
- 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 +16 -24
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -14
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +34 -68
- 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 -46
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +20 -22
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +36 -35
- 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 +26 -21
- 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 +10 -8
- 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 +11 -7
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +41 -37
- 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 +35 -0
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +127 -0
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +16 -14
- 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 +4 -3
- 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 +26 -28
- package/dist/utils/Validate/additional/utils.js +22 -9
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +25 -19
- package/dist/utils/Validate/validateCollection.test.js +66 -74
- package/dist/utils/Validate/validateComponent.js +16 -18
- package/dist/utils/Validate/validateComponent.test.js +146 -167
- package/dist/utils/Validate/validateContainer.js +19 -14
- package/dist/utils/Validate/validateContainer.test.js +45 -49
- package/dist/utils/Validate/validateDate.js +17 -11
- package/dist/utils/Validate/validateDate.test.js +29 -28
- package/dist/utils/Validate/validateEmail.js +8 -6
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +7 -5
- package/dist/utils/Validate/validateMultifile.test.js +18 -17
- package/dist/utils/Validate/validatePage.js +18 -17
- package/dist/utils/Validate/validatePage.test.js +182 -185
- package/dist/utils/Validate/validateRegex.js +5 -3
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +6 -4
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +6 -4
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +14 -7
- package/dist/utils/Validate/validateTime.test.js +14 -14
- package/dist/utils/index.js +9 -7
- package/package.json +1 -1
|
@@ -2,22 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
var _getCYARowsForCollectionPage = _interopRequireDefault(require("./getCYARowsForCollectionPage"));
|
|
4
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
|
|
11
|
+
describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
12
|
+
var TEXT_COMP = {
|
|
9
13
|
id: 'testText',
|
|
10
14
|
fieldId: 'testText',
|
|
11
15
|
label: 'Test text',
|
|
12
16
|
type: 'text'
|
|
13
17
|
};
|
|
14
|
-
|
|
18
|
+
var DATE_COMP = {
|
|
15
19
|
id: 'testDate',
|
|
16
20
|
fieldId: 'testDate',
|
|
17
21
|
label: 'Test date',
|
|
18
22
|
type: 'date'
|
|
19
23
|
};
|
|
20
|
-
|
|
24
|
+
var PAGES = [{
|
|
21
25
|
id: 'page1',
|
|
22
26
|
collection: {
|
|
23
27
|
name: 'collection'
|
|
@@ -30,7 +34,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
30
34
|
},
|
|
31
35
|
components: [DATE_COMP]
|
|
32
36
|
}];
|
|
33
|
-
|
|
37
|
+
var MASTER_PAGE = {
|
|
34
38
|
id: 'page1',
|
|
35
39
|
collection: {
|
|
36
40
|
name: 'collection',
|
|
@@ -51,80 +55,73 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
51
55
|
},
|
|
52
56
|
childPages: PAGES
|
|
53
57
|
};
|
|
54
|
-
it('should return no rows for a collection if it does not exist in formData', ()
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
...MASTER_PAGE,
|
|
58
|
+
it('should return no rows for a collection if it does not exist in formData', function () {
|
|
59
|
+
var FORM_DATA = {};
|
|
60
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
58
61
|
formData: FORM_DATA
|
|
59
|
-
};
|
|
60
|
-
|
|
62
|
+
});
|
|
63
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
61
64
|
expect(ROWS.length).toEqual(0);
|
|
62
65
|
});
|
|
63
|
-
it('should return no rows for a collection if it has no entries', ()
|
|
64
|
-
|
|
66
|
+
it('should return no rows for a collection if it has no entries', function () {
|
|
67
|
+
var FORM_DATA = {
|
|
65
68
|
collection: []
|
|
66
69
|
};
|
|
67
|
-
|
|
68
|
-
...MASTER_PAGE,
|
|
70
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
69
71
|
formData: FORM_DATA
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
+
});
|
|
73
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
72
74
|
expect(ROWS.length).toEqual(0);
|
|
73
75
|
});
|
|
74
|
-
it('should accept the hideNameFromCYA collection flag', ()
|
|
75
|
-
|
|
76
|
+
it('should accept the hideNameFromCYA collection flag', function () {
|
|
77
|
+
var FORM_DATA = {
|
|
76
78
|
collection: [{
|
|
77
79
|
testText: 'hello'
|
|
78
80
|
}]
|
|
79
81
|
};
|
|
80
|
-
|
|
81
|
-
...MASTER_PAGE,
|
|
82
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
82
83
|
formData: FORM_DATA,
|
|
83
|
-
collection: {
|
|
84
|
-
...MASTER_PAGE.collection,
|
|
84
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
85
85
|
hideNameFromCYA: true
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
var TITLE_FIELD_ID = "".concat(PAGE.collection.name, "Title");
|
|
89
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
90
90
|
expect(ROWS[0].fieldId).not.toEqual(TITLE_FIELD_ID);
|
|
91
91
|
});
|
|
92
|
-
it('should format titles correctly when collection.labels.item is specified', ()
|
|
93
|
-
|
|
92
|
+
it('should format titles correctly when collection.labels.item is specified', function () {
|
|
93
|
+
var FORM_DATA = {
|
|
94
94
|
collection: [{
|
|
95
95
|
id: '01',
|
|
96
96
|
testText: 'value'
|
|
97
97
|
}]
|
|
98
98
|
};
|
|
99
|
-
|
|
100
|
-
...MASTER_PAGE,
|
|
99
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
101
100
|
formData: FORM_DATA
|
|
102
|
-
};
|
|
103
|
-
|
|
101
|
+
});
|
|
102
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
104
103
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
105
104
|
expect(ROWS[1].key).toEqual('Collection entry 1');
|
|
106
105
|
});
|
|
107
|
-
it('should provide default titles if collection.labels.item is not specified', ()
|
|
108
|
-
|
|
106
|
+
it('should provide default titles if collection.labels.item is not specified', function () {
|
|
107
|
+
var FORM_DATA = {
|
|
109
108
|
collection: [{
|
|
110
109
|
id: '01',
|
|
111
110
|
testText: 'value'
|
|
112
111
|
}]
|
|
113
112
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
collection: {
|
|
117
|
-
...MASTER_PAGE.collection,
|
|
113
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
114
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
118
115
|
labels: {}
|
|
119
|
-
},
|
|
116
|
+
}),
|
|
120
117
|
formData: FORM_DATA
|
|
121
|
-
};
|
|
122
|
-
|
|
118
|
+
});
|
|
119
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
123
120
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
124
121
|
expect(ROWS[1].key).toEqual('Item 1');
|
|
125
122
|
});
|
|
126
|
-
it('should return correctly formatted rows for mutliple entries', ()
|
|
127
|
-
|
|
123
|
+
it('should return correctly formatted rows for mutliple entries', function () {
|
|
124
|
+
var FORM_DATA = {
|
|
128
125
|
collection: [{
|
|
129
126
|
id: '01',
|
|
130
127
|
testText: 'value'
|
|
@@ -133,11 +130,10 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
133
130
|
testText: 'value'
|
|
134
131
|
}]
|
|
135
132
|
};
|
|
136
|
-
|
|
137
|
-
...MASTER_PAGE,
|
|
133
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
138
134
|
formData: FORM_DATA
|
|
139
|
-
};
|
|
140
|
-
|
|
135
|
+
});
|
|
136
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
141
137
|
expect(ROWS.length).toEqual(13); // Title row + component row for each item
|
|
142
138
|
expect(ROWS[0]).toMatchObject({
|
|
143
139
|
type: 'heading',
|
|
@@ -174,8 +170,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
174
170
|
key: 'Test date'
|
|
175
171
|
});
|
|
176
172
|
});
|
|
177
|
-
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined', ()
|
|
178
|
-
|
|
173
|
+
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined', function () {
|
|
174
|
+
var FORM_DATA = {
|
|
179
175
|
collectionActiveId: '02',
|
|
180
176
|
collection: [{
|
|
181
177
|
id: '01',
|
|
@@ -185,15 +181,13 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
185
181
|
testText: 'value'
|
|
186
182
|
}]
|
|
187
183
|
};
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
collection: {
|
|
191
|
-
...MASTER_PAGE.collection,
|
|
184
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
185
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
192
186
|
onlyShowActiveEntryOnCYA: true
|
|
193
|
-
},
|
|
187
|
+
}),
|
|
194
188
|
formData: FORM_DATA
|
|
195
|
-
};
|
|
196
|
-
|
|
189
|
+
});
|
|
190
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
197
191
|
expect(ROWS.length).toEqual(7); // Title row + component row for only the active item.
|
|
198
192
|
expect(ROWS[0]).toMatchObject({
|
|
199
193
|
type: 'heading',
|
|
@@ -215,8 +209,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
215
209
|
key: 'Test date'
|
|
216
210
|
});
|
|
217
211
|
});
|
|
218
|
-
it('should exclude components that should not be shown', ()
|
|
219
|
-
|
|
212
|
+
it('should exclude components that should not be shown', function () {
|
|
213
|
+
var FD = {
|
|
220
214
|
collection: [{
|
|
221
215
|
id: '01',
|
|
222
216
|
otherField: 'yes',
|
|
@@ -227,14 +221,12 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
227
221
|
testText: 'testing'
|
|
228
222
|
}]
|
|
229
223
|
};
|
|
230
|
-
|
|
231
|
-
...MASTER_PAGE,
|
|
224
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
232
225
|
collection: {
|
|
233
226
|
name: 'collection'
|
|
234
227
|
},
|
|
235
228
|
formData: FD,
|
|
236
|
-
childPages: [{
|
|
237
|
-
...PAGES[0],
|
|
229
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
238
230
|
components: [{
|
|
239
231
|
id: 'testText',
|
|
240
232
|
fieldId: 'testText',
|
|
@@ -246,9 +238,9 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
246
238
|
value: "yes"
|
|
247
239
|
}
|
|
248
240
|
}]
|
|
249
|
-
}]
|
|
250
|
-
};
|
|
251
|
-
|
|
241
|
+
})]
|
|
242
|
+
});
|
|
243
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
|
|
252
244
|
expect(ROWS.length).toEqual(4);
|
|
253
245
|
expect(ROWS[0]).toMatchObject({
|
|
254
246
|
type: 'heading',
|
|
@@ -267,30 +259,28 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
267
259
|
key: 'Test text'
|
|
268
260
|
});
|
|
269
261
|
});
|
|
270
|
-
it('should exclude pages that should not be shown', ()
|
|
271
|
-
|
|
262
|
+
it('should exclude pages that should not be shown', function () {
|
|
263
|
+
var FD = {
|
|
272
264
|
collection: [{
|
|
273
265
|
id: '01',
|
|
274
266
|
otherField: 'yes',
|
|
275
267
|
testText: 'testing'
|
|
276
268
|
}]
|
|
277
269
|
};
|
|
278
|
-
|
|
279
|
-
...MASTER_PAGE,
|
|
270
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
280
271
|
collection: {
|
|
281
272
|
name: 'collection'
|
|
282
273
|
},
|
|
283
274
|
formData: FD,
|
|
284
|
-
childPages: [{
|
|
285
|
-
...PAGES[0],
|
|
275
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
286
276
|
show_when: {
|
|
287
277
|
field: "otherField",
|
|
288
278
|
op: "!=",
|
|
289
279
|
value: "yes"
|
|
290
280
|
}
|
|
291
|
-
}, PAGES[1]]
|
|
292
|
-
};
|
|
293
|
-
|
|
281
|
+
}), PAGES[1]]
|
|
282
|
+
});
|
|
283
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
|
|
294
284
|
expect(ROWS.length).toEqual(3); // Missing the page with the text component on.
|
|
295
285
|
expect(ROWS[0]).toMatchObject({
|
|
296
286
|
type: 'heading',
|
|
@@ -305,28 +295,25 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
305
295
|
key: 'Test date'
|
|
306
296
|
});
|
|
307
297
|
});
|
|
308
|
-
it('should include rows for custom headings', ()
|
|
309
|
-
|
|
298
|
+
it('should include rows for custom headings', function () {
|
|
299
|
+
var FORM_DATA = {
|
|
310
300
|
collection: [{
|
|
311
301
|
id: '01',
|
|
312
302
|
testText: 'value'
|
|
313
303
|
}]
|
|
314
304
|
};
|
|
315
|
-
|
|
316
|
-
...MASTER_PAGE,
|
|
305
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
317
306
|
formData: FORM_DATA,
|
|
318
|
-
childPages: [{
|
|
319
|
-
|
|
320
|
-
collection: {
|
|
321
|
-
...PAGES[0].collection,
|
|
307
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
308
|
+
collection: _objectSpread(_objectSpread({}, PAGES[0].collection), {}, {
|
|
322
309
|
heading: {
|
|
323
310
|
size: 'm',
|
|
324
311
|
text: 'Custom page heading'
|
|
325
312
|
}
|
|
326
|
-
}
|
|
327
|
-
}]
|
|
328
|
-
};
|
|
329
|
-
|
|
313
|
+
})
|
|
314
|
+
})]
|
|
315
|
+
});
|
|
316
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
330
317
|
expect(ROWS.length).toEqual(7);
|
|
331
318
|
expect(ROWS[0]).toMatchObject({
|
|
332
319
|
type: 'heading',
|
|
@@ -349,106 +336,99 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
349
336
|
key: 'Test text'
|
|
350
337
|
});
|
|
351
338
|
});
|
|
352
|
-
it('should default to a title size of small if one is not specified', ()
|
|
353
|
-
|
|
339
|
+
it('should default to a title size of small if one is not specified', function () {
|
|
340
|
+
var FORM_DATA = {
|
|
354
341
|
collection: [{
|
|
355
342
|
id: '01',
|
|
356
343
|
testText: 'value'
|
|
357
344
|
}]
|
|
358
345
|
};
|
|
359
|
-
|
|
360
|
-
...MASTER_PAGE,
|
|
346
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
361
347
|
formData: FORM_DATA,
|
|
362
|
-
childPages: [{
|
|
363
|
-
|
|
364
|
-
collection: {
|
|
365
|
-
...PAGES[0].collection,
|
|
348
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
349
|
+
collection: _objectSpread(_objectSpread({}, PAGES[0].collection), {}, {
|
|
366
350
|
heading: {
|
|
367
351
|
text: 'Custom page heading'
|
|
368
352
|
}
|
|
369
|
-
}
|
|
370
|
-
}]
|
|
371
|
-
};
|
|
372
|
-
|
|
353
|
+
})
|
|
354
|
+
})]
|
|
355
|
+
});
|
|
356
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
373
357
|
expect(ROWS[5]).toMatchObject({
|
|
374
358
|
type: 'heading',
|
|
375
359
|
key: 'Custom page heading',
|
|
376
360
|
size: 's'
|
|
377
361
|
});
|
|
378
362
|
});
|
|
379
|
-
it('should position actions under the title if actionPosition flag is not specified', ()
|
|
380
|
-
|
|
363
|
+
it('should position actions under the title if actionPosition flag is not specified', function () {
|
|
364
|
+
var FORM_DATA = {
|
|
381
365
|
collection: [{
|
|
382
366
|
id: '01',
|
|
383
367
|
testText: 'value'
|
|
384
368
|
}]
|
|
385
369
|
};
|
|
386
|
-
|
|
387
|
-
...MASTER_PAGE,
|
|
370
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
388
371
|
formData: FORM_DATA
|
|
389
|
-
};
|
|
390
|
-
|
|
372
|
+
});
|
|
373
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
391
374
|
expect(ROWS[2].action.label).toEqual('Change');
|
|
392
375
|
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
393
376
|
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
394
377
|
});
|
|
395
|
-
it('should position actions under the title if actionPosition flag is top', ()
|
|
396
|
-
|
|
378
|
+
it('should position actions under the title if actionPosition flag is top', function () {
|
|
379
|
+
var FORM_DATA = {
|
|
397
380
|
collection: [{
|
|
398
381
|
id: '01',
|
|
399
382
|
testText: 'value'
|
|
400
383
|
}]
|
|
401
384
|
};
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
collection: {
|
|
405
|
-
...MASTER_PAGE.collection,
|
|
385
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
386
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
406
387
|
actionPosition: 'top'
|
|
407
|
-
},
|
|
388
|
+
}),
|
|
408
389
|
formData: FORM_DATA
|
|
409
|
-
};
|
|
410
|
-
|
|
390
|
+
});
|
|
391
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
411
392
|
expect(ROWS[2].action.label).toEqual('Change');
|
|
412
393
|
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
413
394
|
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
414
395
|
});
|
|
415
|
-
it('should position actions under all other rows if actionPosition flag is bottom', ()
|
|
416
|
-
|
|
396
|
+
it('should position actions under all other rows if actionPosition flag is bottom', function () {
|
|
397
|
+
var FORM_DATA = {
|
|
417
398
|
collection: [{
|
|
418
399
|
id: '01',
|
|
419
400
|
testText: 'value'
|
|
420
401
|
}]
|
|
421
402
|
};
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
collection: {
|
|
425
|
-
...MASTER_PAGE.collection,
|
|
403
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
404
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
426
405
|
actionPosition: 'bottom'
|
|
427
|
-
},
|
|
406
|
+
}),
|
|
428
407
|
formData: FORM_DATA
|
|
429
|
-
};
|
|
430
|
-
|
|
408
|
+
});
|
|
409
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
431
410
|
expect(ROWS[ROWS.length - 3].action.label).toEqual('Change');
|
|
432
411
|
expect(ROWS[ROWS.length - 2].action.label).toEqual('custom remove label');
|
|
433
412
|
expect(ROWS[ROWS.length - 1].action.label).toEqual('custom change label');
|
|
434
413
|
});
|
|
435
|
-
it('should ignore the result of the override function if it returns nullish', ()
|
|
436
|
-
|
|
414
|
+
it('should ignore the result of the override function if it returns nullish', function () {
|
|
415
|
+
var FORM_DATA = {
|
|
437
416
|
collection: [{
|
|
438
417
|
id: '01',
|
|
439
418
|
testText: 'value'
|
|
440
419
|
}]
|
|
441
420
|
};
|
|
442
|
-
|
|
443
|
-
...MASTER_PAGE,
|
|
421
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
444
422
|
formData: FORM_DATA
|
|
445
|
-
};
|
|
446
|
-
|
|
423
|
+
});
|
|
424
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, function () {
|
|
425
|
+
return null;
|
|
426
|
+
}, FORM_DATA);
|
|
447
427
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
448
428
|
expect(ROWS[5].key).toEqual("Test text");
|
|
449
429
|
});
|
|
450
|
-
it('should use the rows produced by the override function if provided', ()
|
|
451
|
-
|
|
430
|
+
it('should use the rows produced by the override function if provided', function () {
|
|
431
|
+
var FORM_DATA = {
|
|
452
432
|
collection: [{
|
|
453
433
|
id: '01',
|
|
454
434
|
testText: 'value'
|
|
@@ -456,23 +436,22 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
456
436
|
};
|
|
457
437
|
|
|
458
438
|
// eslint-disable-next-line arrow-body-style
|
|
459
|
-
|
|
439
|
+
var OVERRIDE = function OVERRIDE(page, comp) {
|
|
460
440
|
// This will be called for each component on the page,
|
|
461
441
|
// returning a custom row object.
|
|
462
442
|
return {
|
|
463
443
|
key: "CustomRowFor".concat(comp.label)
|
|
464
444
|
};
|
|
465
445
|
};
|
|
466
|
-
|
|
467
|
-
...MASTER_PAGE,
|
|
446
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
468
447
|
formData: FORM_DATA
|
|
469
|
-
};
|
|
470
|
-
|
|
448
|
+
});
|
|
449
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, OVERRIDE, FORM_DATA);
|
|
471
450
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
472
451
|
expect(ROWS[5].key).toEqual("CustomRowFor".concat(TEXT_COMP.label));
|
|
473
452
|
});
|
|
474
|
-
it('should create rows for nested collections correctly', ()
|
|
475
|
-
|
|
453
|
+
it('should create rows for nested collections correctly', function () {
|
|
454
|
+
var CUSTOM_FORM_DATA = {
|
|
476
455
|
parentActiveId: '001',
|
|
477
456
|
childActiveId: '001',
|
|
478
457
|
parent: [{
|
|
@@ -484,7 +463,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
484
463
|
}]
|
|
485
464
|
}]
|
|
486
465
|
};
|
|
487
|
-
|
|
466
|
+
var CHILD_MASTER_PAGE = {
|
|
488
467
|
id: 'childPage',
|
|
489
468
|
collection: {
|
|
490
469
|
name: 'parent.child',
|
|
@@ -508,7 +487,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
508
487
|
components: [TEXT_COMP]
|
|
509
488
|
}]
|
|
510
489
|
};
|
|
511
|
-
|
|
490
|
+
var PARENT_MASTER_PAGE = {
|
|
512
491
|
id: 'parentPage',
|
|
513
492
|
collection: {
|
|
514
493
|
name: 'parent',
|
|
@@ -522,11 +501,10 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
522
501
|
components: [TEXT_COMP]
|
|
523
502
|
}, CHILD_MASTER_PAGE]
|
|
524
503
|
};
|
|
525
|
-
|
|
526
|
-
...PARENT_MASTER_PAGE,
|
|
504
|
+
var PAGE = _objectSpread(_objectSpread({}, PARENT_MASTER_PAGE), {}, {
|
|
527
505
|
formData: CUSTOM_FORM_DATA
|
|
528
|
-
};
|
|
529
|
-
|
|
506
|
+
});
|
|
507
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, CUSTOM_FORM_DATA);
|
|
530
508
|
expect(ROWS.length).toEqual(8);
|
|
531
509
|
expect(ROWS[0]).toMatchObject({
|
|
532
510
|
type: 'heading',
|
|
@@ -10,41 +10,36 @@ var _getCYARow = _interopRequireDefault(require("./getCYARow"));
|
|
|
10
10
|
var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
|
|
11
11
|
var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
25
|
-
|
|
13
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
14
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
|
|
19
|
+
var getCYARowsForContainer = function getCYARowsForContainer(page, container, formData, onAction, fnOverride) {
|
|
20
|
+
if ((0, _showComponentCYA.default)(container, _objectSpread(_objectSpread({}, page.formData), formData))) {
|
|
21
|
+
var allComponents = (0, _elevateNestedComponents.default)(container.components, formData);
|
|
22
|
+
return allComponents.filter(function (c) {
|
|
23
|
+
return (0, _showComponentCYA.default)(c, _objectSpread(_objectSpread({}, page.formData), formData));
|
|
24
|
+
}).flatMap(function (component) {
|
|
25
|
+
var fd = formData ? formData[component.fieldId] : undefined;
|
|
26
26
|
if (typeof fnOverride === 'function') {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}, component, onAction);
|
|
27
|
+
var overrideRows = fnOverride(_objectSpread(_objectSpread({}, page), {}, {
|
|
28
|
+
formData: formData
|
|
29
|
+
}), component, onAction);
|
|
31
30
|
if (overrideRows) {
|
|
32
31
|
return overrideRows;
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
if (component.type === _models.ComponentTypes.CONTAINER) {
|
|
36
|
-
return getCYARowsForContainer(page, component, {
|
|
37
|
-
...fd,
|
|
38
|
-
...formData
|
|
39
|
-
}, onAction, fnOverride);
|
|
35
|
+
return getCYARowsForContainer(page, component, _objectSpread(_objectSpread({}, fd), formData), onAction, fnOverride);
|
|
40
36
|
}
|
|
41
37
|
if (component.type === _models.ComponentTypes.COLLECTION) {
|
|
42
38
|
return (0, _getCYARowsForCollection.default)(page, component, fd, onAction, fnOverride);
|
|
43
39
|
}
|
|
44
|
-
return (0, _getCYARow.default)({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}, component, onAction);
|
|
40
|
+
return (0, _getCYARow.default)(_objectSpread(_objectSpread({}, page), {}, {
|
|
41
|
+
formData: formData
|
|
42
|
+
}), component, onAction);
|
|
48
43
|
});
|
|
49
44
|
}
|
|
50
45
|
return null;
|