@ukhomeoffice/cop-react-form-renderer 6.7.0-alpha → 6.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +22 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +180 -92
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +137 -103
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +861 -463
- package/dist/components/CollectionPage/CollectionPage.js +63 -73
- package/dist/components/CollectionPage/CollectionPage.test.js +366 -316
- package/dist/components/CollectionSummary/BannerStrip.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.test.js +76 -80
- package/dist/components/CollectionSummary/CollectionSummary.js +126 -99
- package/dist/components/CollectionSummary/CollectionSummary.test.js +188 -152
- package/dist/components/CollectionSummary/Confirmation.js +12 -14
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/RenderListView.js +52 -46
- package/dist/components/CollectionSummary/RenderListView.scss +1 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +77 -78
- package/dist/components/CollectionSummary/SummaryCard.js +152 -110
- package/dist/components/CollectionSummary/SummaryCard.test.js +1018 -929
- package/dist/components/CollectionSummary/SummaryCardDetails.js +137 -94
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +13 -4
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +331 -128
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +35 -30
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +74 -62
- package/dist/components/FormComponent/Collection.js +108 -74
- package/dist/components/FormComponent/Collection.test.js +1081 -909
- package/dist/components/FormComponent/Container.js +39 -40
- package/dist/components/FormComponent/Container.test.js +412 -312
- package/dist/components/FormComponent/FormComponent.js +72 -69
- package/dist/components/FormComponent/FormComponent.test.js +414 -353
- 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 +180 -143
- 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 +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +15 -15
- 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 +97 -103
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +78 -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 +39 -43
- package/dist/components/FormRenderer/onPageAction.test.js +208 -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 +34 -21
- package/dist/components/SummaryList/SummaryList.scss +15 -0
- package/dist/components/SummaryList/SummaryList.test.js +226 -143
- package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +53 -0
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.scss +38 -0
- 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 +92 -49
- package/dist/components/TaskList/TaskList.scss +24 -0
- package/dist/components/TaskList/TaskList.test.js +255 -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 +80 -57
- package/dist/context/HooksContext/HooksContext.test.js +35 -26
- package/dist/context/HooksContext/index.js +4 -3
- package/dist/context/ValidationContext/ValidationContext.js +94 -43
- package/dist/context/ValidationContext/ValidationContext.test.js +68 -56
- 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 -29
- 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 +61 -58
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +108 -87
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +281 -162
- 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/getSummaryListRowForDetails.js +42 -0
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +56 -0
- 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 +18 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +22 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +38 -47
- 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/getErrorsForCollection.js +24 -24
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +22 -20
- package/dist/utils/CollectionPage/getQuickEditPage.js +31 -35
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +27 -15
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +43 -31
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +26 -26
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +16 -10
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
- 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 +7 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +68 -30
- package/dist/utils/Component/getComponent.js +94 -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 +72 -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 +21 -22
- 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 +6 -1
- package/dist/utils/Component/optionIsSelected.test.js +35 -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 +8 -8
- package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
- package/dist/utils/Condition/meetsCondition.js +25 -16
- 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 +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 +30 -24
- package/dist/utils/Data/getOptions.test.js +27 -27
- 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/nestInRefdataOptions.js +16 -9
- package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
- 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/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- 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/getParagraphFromText.js +7 -5
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +4 -2
- 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 -77
- 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 +78 -50
- package/dist/utils/Format/formatDataForForm.js +8 -6
- package/dist/utils/Format/formatDataForForm.test.js +16 -13
- package/dist/utils/Format/formatDataForPage.js +5 -4
- package/dist/utils/Format/formatDataForPage.test.js +25 -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 +52 -46
- package/dist/utils/Operate/getLength.js +50 -0
- package/dist/utils/Operate/getLength.test.js +89 -0
- 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 +9 -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 +27 -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 +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 +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 +4 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +39 -35
- 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 +21 -18
- package/dist/utils/Validate/validateComponent.test.js +176 -166
- package/dist/utils/Validate/validateContainer.js +20 -15
- package/dist/utils/Validate/validateContainer.test.js +52 -58
- package/dist/utils/Validate/validateDate.js +21 -15
- package/dist/utils/Validate/validateDate.test.js +32 -31
- 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 +22 -19
- package/dist/utils/Validate/validatePage.test.js +203 -215
- 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 +26 -11
- package/dist/utils/Validate/validateTime.test.js +62 -16
- package/dist/utils/index.js +9 -7
- package/package.json +2 -2
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +0 -37
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +0 -41
|
@@ -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,22 +170,20 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
174
170
|
key: 'Test date'
|
|
175
171
|
});
|
|
176
172
|
});
|
|
177
|
-
it('should use values from top-level formData if they don\'t exist in the item', ()
|
|
178
|
-
|
|
173
|
+
it('should use values from top-level formData if they don\'t exist in the item', function () {
|
|
174
|
+
var FORM_DATA = {
|
|
179
175
|
testText: 'value',
|
|
180
176
|
collection: [{
|
|
181
177
|
id: '01'
|
|
182
178
|
}]
|
|
183
179
|
};
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
childPages: [{
|
|
187
|
-
...PAGES[0],
|
|
180
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
181
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
188
182
|
formData: FORM_DATA
|
|
189
|
-
}, PAGES[1]],
|
|
183
|
+
}), PAGES[1]],
|
|
190
184
|
formData: FORM_DATA
|
|
191
|
-
};
|
|
192
|
-
|
|
185
|
+
});
|
|
186
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
193
187
|
expect(ROWS.length).toEqual(7); // Title row + component row for each item
|
|
194
188
|
expect(ROWS[0]).toMatchObject({
|
|
195
189
|
type: 'heading',
|
|
@@ -211,8 +205,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
211
205
|
key: 'Test date'
|
|
212
206
|
});
|
|
213
207
|
});
|
|
214
|
-
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined', ()
|
|
215
|
-
|
|
208
|
+
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined', function () {
|
|
209
|
+
var FORM_DATA = {
|
|
216
210
|
collectionActiveId: '02',
|
|
217
211
|
collection: [{
|
|
218
212
|
id: '01',
|
|
@@ -222,15 +216,13 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
222
216
|
testText: 'value'
|
|
223
217
|
}]
|
|
224
218
|
};
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
collection: {
|
|
228
|
-
...MASTER_PAGE.collection,
|
|
219
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
220
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
229
221
|
onlyShowActiveEntryOnCYA: true
|
|
230
|
-
},
|
|
222
|
+
}),
|
|
231
223
|
formData: FORM_DATA
|
|
232
|
-
};
|
|
233
|
-
|
|
224
|
+
});
|
|
225
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
234
226
|
expect(ROWS.length).toEqual(7); // Title row + component row for only the active item.
|
|
235
227
|
expect(ROWS[0]).toMatchObject({
|
|
236
228
|
type: 'heading',
|
|
@@ -252,8 +244,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
252
244
|
key: 'Test date'
|
|
253
245
|
});
|
|
254
246
|
});
|
|
255
|
-
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is an array', ()
|
|
256
|
-
|
|
247
|
+
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is an array', function () {
|
|
248
|
+
var FORM_DATA = {
|
|
257
249
|
text: 'blue',
|
|
258
250
|
collectionActiveId: '02',
|
|
259
251
|
collection: [{
|
|
@@ -264,19 +256,17 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
264
256
|
testText: 'value'
|
|
265
257
|
}]
|
|
266
258
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
collection: {
|
|
270
|
-
...MASTER_PAGE.collection,
|
|
259
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
260
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
271
261
|
onlyShowActiveEntryOnCYA: [{
|
|
272
262
|
field: 'text',
|
|
273
263
|
op: 'eq',
|
|
274
264
|
value: 'blue'
|
|
275
265
|
}]
|
|
276
|
-
},
|
|
266
|
+
}),
|
|
277
267
|
formData: FORM_DATA
|
|
278
|
-
};
|
|
279
|
-
|
|
268
|
+
});
|
|
269
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
280
270
|
expect(ROWS.length).toEqual(7); // Title row + component row for only the active item.
|
|
281
271
|
expect(ROWS[0]).toMatchObject({
|
|
282
272
|
type: 'heading',
|
|
@@ -298,8 +288,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
298
288
|
key: 'Test date'
|
|
299
289
|
});
|
|
300
290
|
});
|
|
301
|
-
it('should exclude components that should not be shown', ()
|
|
302
|
-
|
|
291
|
+
it('should exclude components that should not be shown', function () {
|
|
292
|
+
var FD = {
|
|
303
293
|
collection: [{
|
|
304
294
|
id: '01',
|
|
305
295
|
otherField: 'yes',
|
|
@@ -310,14 +300,12 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
310
300
|
testText: 'testing'
|
|
311
301
|
}]
|
|
312
302
|
};
|
|
313
|
-
|
|
314
|
-
...MASTER_PAGE,
|
|
303
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
315
304
|
collection: {
|
|
316
305
|
name: 'collection'
|
|
317
306
|
},
|
|
318
307
|
formData: FD,
|
|
319
|
-
childPages: [{
|
|
320
|
-
...PAGES[0],
|
|
308
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
321
309
|
components: [{
|
|
322
310
|
id: 'testText',
|
|
323
311
|
fieldId: 'testText',
|
|
@@ -329,9 +317,9 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
329
317
|
value: "yes"
|
|
330
318
|
}
|
|
331
319
|
}]
|
|
332
|
-
}]
|
|
333
|
-
};
|
|
334
|
-
|
|
320
|
+
})]
|
|
321
|
+
});
|
|
322
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
|
|
335
323
|
expect(ROWS.length).toEqual(4);
|
|
336
324
|
expect(ROWS[0]).toMatchObject({
|
|
337
325
|
type: 'heading',
|
|
@@ -350,30 +338,28 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
350
338
|
key: 'Test text'
|
|
351
339
|
});
|
|
352
340
|
});
|
|
353
|
-
it('should exclude pages that should not be shown', ()
|
|
354
|
-
|
|
341
|
+
it('should exclude pages that should not be shown', function () {
|
|
342
|
+
var FD = {
|
|
355
343
|
collection: [{
|
|
356
344
|
id: '01',
|
|
357
345
|
otherField: 'yes',
|
|
358
346
|
testText: 'testing'
|
|
359
347
|
}]
|
|
360
348
|
};
|
|
361
|
-
|
|
362
|
-
...MASTER_PAGE,
|
|
349
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
363
350
|
collection: {
|
|
364
351
|
name: 'collection'
|
|
365
352
|
},
|
|
366
353
|
formData: FD,
|
|
367
|
-
childPages: [{
|
|
368
|
-
...PAGES[0],
|
|
354
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
369
355
|
show_when: {
|
|
370
356
|
field: "otherField",
|
|
371
357
|
op: "!=",
|
|
372
358
|
value: "yes"
|
|
373
359
|
}
|
|
374
|
-
}, PAGES[1]]
|
|
375
|
-
};
|
|
376
|
-
|
|
360
|
+
}), PAGES[1]]
|
|
361
|
+
});
|
|
362
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
|
|
377
363
|
expect(ROWS.length).toEqual(3); // Missing the page with the text component on.
|
|
378
364
|
expect(ROWS[0]).toMatchObject({
|
|
379
365
|
type: 'heading',
|
|
@@ -388,28 +374,25 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
388
374
|
key: 'Test date'
|
|
389
375
|
});
|
|
390
376
|
});
|
|
391
|
-
it('should include rows for custom headings', ()
|
|
392
|
-
|
|
377
|
+
it('should include rows for custom headings', function () {
|
|
378
|
+
var FORM_DATA = {
|
|
393
379
|
collection: [{
|
|
394
380
|
id: '01',
|
|
395
381
|
testText: 'value'
|
|
396
382
|
}]
|
|
397
383
|
};
|
|
398
|
-
|
|
399
|
-
...MASTER_PAGE,
|
|
384
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
400
385
|
formData: FORM_DATA,
|
|
401
|
-
childPages: [{
|
|
402
|
-
|
|
403
|
-
collection: {
|
|
404
|
-
...PAGES[0].collection,
|
|
386
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
387
|
+
collection: _objectSpread(_objectSpread({}, PAGES[0].collection), {}, {
|
|
405
388
|
heading: {
|
|
406
389
|
size: 'm',
|
|
407
390
|
text: 'Custom page heading'
|
|
408
391
|
}
|
|
409
|
-
}
|
|
410
|
-
}]
|
|
411
|
-
};
|
|
412
|
-
|
|
392
|
+
})
|
|
393
|
+
})]
|
|
394
|
+
});
|
|
395
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
413
396
|
expect(ROWS.length).toEqual(7);
|
|
414
397
|
expect(ROWS[0]).toMatchObject({
|
|
415
398
|
type: 'heading',
|
|
@@ -432,106 +415,168 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
432
415
|
key: 'Test text'
|
|
433
416
|
});
|
|
434
417
|
});
|
|
435
|
-
it('should
|
|
436
|
-
|
|
418
|
+
it('should allow interpolation of custom headings', function () {
|
|
419
|
+
var FORM_DATA = {
|
|
437
420
|
collection: [{
|
|
438
421
|
id: '01',
|
|
439
422
|
testText: 'value'
|
|
440
423
|
}]
|
|
441
424
|
};
|
|
442
|
-
|
|
443
|
-
...MASTER_PAGE,
|
|
425
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
444
426
|
formData: FORM_DATA,
|
|
445
|
-
childPages: [{
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
...PAGES[0].collection,
|
|
427
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
428
|
+
collection: _objectSpread(_objectSpread({}, PAGES[0].collection), {}, {
|
|
429
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
449
430
|
heading: {
|
|
450
|
-
|
|
431
|
+
size: 'm',
|
|
432
|
+
text: 'interpolated text: ${testText}'
|
|
451
433
|
}
|
|
434
|
+
})
|
|
435
|
+
})]
|
|
436
|
+
});
|
|
437
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
438
|
+
expect(ROWS.length).toEqual(7);
|
|
439
|
+
expect(ROWS[0]).toMatchObject({
|
|
440
|
+
type: 'heading',
|
|
441
|
+
key: 'Collection'
|
|
442
|
+
});
|
|
443
|
+
expect(ROWS[1]).toMatchObject({
|
|
444
|
+
type: 'heading',
|
|
445
|
+
key: 'Collection entry 1'
|
|
446
|
+
});
|
|
447
|
+
expect(ROWS[2].action.label).toEqual('Change');
|
|
448
|
+
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
449
|
+
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
450
|
+
expect(ROWS[5]).toMatchObject({
|
|
451
|
+
type: 'heading',
|
|
452
|
+
key: 'interpolated text: value',
|
|
453
|
+
size: 'm'
|
|
454
|
+
});
|
|
455
|
+
expect(ROWS[6]).toMatchObject({
|
|
456
|
+
value: 'value',
|
|
457
|
+
key: 'Test text'
|
|
458
|
+
});
|
|
459
|
+
});
|
|
460
|
+
it('should alow configuration of collection name headings', function () {
|
|
461
|
+
var FORM_DATA = {
|
|
462
|
+
collection: [{
|
|
463
|
+
id: '01',
|
|
464
|
+
testText: 'value'
|
|
465
|
+
}]
|
|
466
|
+
};
|
|
467
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
468
|
+
formData: FORM_DATA,
|
|
469
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
470
|
+
collectionHeading: {
|
|
471
|
+
text: 'Custom collection heading',
|
|
472
|
+
size: 'm',
|
|
473
|
+
changeLinkPage: PAGES[0].id
|
|
452
474
|
}
|
|
475
|
+
}),
|
|
476
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
477
|
+
collection: _objectSpread({}, PAGES[0].collection)
|
|
478
|
+
})]
|
|
479
|
+
});
|
|
480
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
481
|
+
expect(ROWS.length).toEqual(6);
|
|
482
|
+
expect(ROWS[0]).toMatchObject({
|
|
483
|
+
type: 'headingWithAction',
|
|
484
|
+
key: 'Custom collection heading'
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
it('should default to a title size of small if one is not specified', function () {
|
|
488
|
+
var FORM_DATA = {
|
|
489
|
+
collection: [{
|
|
490
|
+
id: '01',
|
|
491
|
+
testText: 'value'
|
|
453
492
|
}]
|
|
454
493
|
};
|
|
455
|
-
|
|
494
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
495
|
+
formData: FORM_DATA,
|
|
496
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
497
|
+
collection: _objectSpread(_objectSpread({}, PAGES[0].collection), {}, {
|
|
498
|
+
heading: {
|
|
499
|
+
text: 'Custom page heading'
|
|
500
|
+
}
|
|
501
|
+
})
|
|
502
|
+
})]
|
|
503
|
+
});
|
|
504
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
456
505
|
expect(ROWS[5]).toMatchObject({
|
|
457
506
|
type: 'heading',
|
|
458
507
|
key: 'Custom page heading',
|
|
459
508
|
size: 's'
|
|
460
509
|
});
|
|
461
510
|
});
|
|
462
|
-
it('should position actions under the title if actionPosition flag is not specified', ()
|
|
463
|
-
|
|
511
|
+
it('should position actions under the title if actionPosition flag is not specified', function () {
|
|
512
|
+
var FORM_DATA = {
|
|
464
513
|
collection: [{
|
|
465
514
|
id: '01',
|
|
466
515
|
testText: 'value'
|
|
467
516
|
}]
|
|
468
517
|
};
|
|
469
|
-
|
|
470
|
-
...MASTER_PAGE,
|
|
518
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
471
519
|
formData: FORM_DATA
|
|
472
|
-
};
|
|
473
|
-
|
|
520
|
+
});
|
|
521
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
474
522
|
expect(ROWS[2].action.label).toEqual('Change');
|
|
475
523
|
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
476
524
|
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
477
525
|
});
|
|
478
|
-
it('should position actions under the title if actionPosition flag is top', ()
|
|
479
|
-
|
|
526
|
+
it('should position actions under the title if actionPosition flag is top', function () {
|
|
527
|
+
var FORM_DATA = {
|
|
480
528
|
collection: [{
|
|
481
529
|
id: '01',
|
|
482
530
|
testText: 'value'
|
|
483
531
|
}]
|
|
484
532
|
};
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
collection: {
|
|
488
|
-
...MASTER_PAGE.collection,
|
|
533
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
534
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
489
535
|
actionPosition: 'top'
|
|
490
|
-
},
|
|
536
|
+
}),
|
|
491
537
|
formData: FORM_DATA
|
|
492
|
-
};
|
|
493
|
-
|
|
538
|
+
});
|
|
539
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
494
540
|
expect(ROWS[2].action.label).toEqual('Change');
|
|
495
541
|
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
496
542
|
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
497
543
|
});
|
|
498
|
-
it('should position actions under all other rows if actionPosition flag is bottom', ()
|
|
499
|
-
|
|
544
|
+
it('should position actions under all other rows if actionPosition flag is bottom', function () {
|
|
545
|
+
var FORM_DATA = {
|
|
500
546
|
collection: [{
|
|
501
547
|
id: '01',
|
|
502
548
|
testText: 'value'
|
|
503
549
|
}]
|
|
504
550
|
};
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
collection: {
|
|
508
|
-
...MASTER_PAGE.collection,
|
|
551
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
552
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
509
553
|
actionPosition: 'bottom'
|
|
510
|
-
},
|
|
554
|
+
}),
|
|
511
555
|
formData: FORM_DATA
|
|
512
|
-
};
|
|
513
|
-
|
|
556
|
+
});
|
|
557
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
514
558
|
expect(ROWS[ROWS.length - 3].action.label).toEqual('Change');
|
|
515
559
|
expect(ROWS[ROWS.length - 2].action.label).toEqual('custom remove label');
|
|
516
560
|
expect(ROWS[ROWS.length - 1].action.label).toEqual('custom change label');
|
|
517
561
|
});
|
|
518
|
-
it('should ignore the result of the override function if it returns nullish', ()
|
|
519
|
-
|
|
562
|
+
it('should ignore the result of the override function if it returns nullish', function () {
|
|
563
|
+
var FORM_DATA = {
|
|
520
564
|
collection: [{
|
|
521
565
|
id: '01',
|
|
522
566
|
testText: 'value'
|
|
523
567
|
}]
|
|
524
568
|
};
|
|
525
|
-
|
|
526
|
-
...MASTER_PAGE,
|
|
569
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
527
570
|
formData: FORM_DATA
|
|
528
|
-
};
|
|
529
|
-
|
|
571
|
+
});
|
|
572
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, function () {
|
|
573
|
+
return null;
|
|
574
|
+
}, FORM_DATA);
|
|
530
575
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
531
576
|
expect(ROWS[5].key).toEqual("Test text");
|
|
532
577
|
});
|
|
533
|
-
it('should use the rows produced by the override function if provided', ()
|
|
534
|
-
|
|
578
|
+
it('should use the rows produced by the override function if provided', function () {
|
|
579
|
+
var FORM_DATA = {
|
|
535
580
|
collection: [{
|
|
536
581
|
id: '01',
|
|
537
582
|
testText: 'value'
|
|
@@ -539,23 +584,22 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
539
584
|
};
|
|
540
585
|
|
|
541
586
|
// eslint-disable-next-line arrow-body-style
|
|
542
|
-
|
|
587
|
+
var OVERRIDE = function OVERRIDE(page, comp) {
|
|
543
588
|
// This will be called for each component on the page,
|
|
544
589
|
// returning a custom row object.
|
|
545
590
|
return {
|
|
546
591
|
key: "CustomRowFor".concat(comp.label)
|
|
547
592
|
};
|
|
548
593
|
};
|
|
549
|
-
|
|
550
|
-
...MASTER_PAGE,
|
|
594
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
551
595
|
formData: FORM_DATA
|
|
552
|
-
};
|
|
553
|
-
|
|
596
|
+
});
|
|
597
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, OVERRIDE, FORM_DATA);
|
|
554
598
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
555
599
|
expect(ROWS[5].key).toEqual("CustomRowFor".concat(TEXT_COMP.label));
|
|
556
600
|
});
|
|
557
|
-
it('should create rows for nested collections correctly', ()
|
|
558
|
-
|
|
601
|
+
it('should create rows for nested collections correctly', function () {
|
|
602
|
+
var CUSTOM_FORM_DATA = {
|
|
559
603
|
parentActiveId: '001',
|
|
560
604
|
childActiveId: '001',
|
|
561
605
|
parent: [{
|
|
@@ -567,7 +611,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
567
611
|
}]
|
|
568
612
|
}]
|
|
569
613
|
};
|
|
570
|
-
|
|
614
|
+
var CHILD_MASTER_PAGE = {
|
|
571
615
|
id: 'childPage',
|
|
572
616
|
collection: {
|
|
573
617
|
name: 'parent.child',
|
|
@@ -591,7 +635,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
591
635
|
components: [TEXT_COMP]
|
|
592
636
|
}]
|
|
593
637
|
};
|
|
594
|
-
|
|
638
|
+
var PARENT_MASTER_PAGE = {
|
|
595
639
|
id: 'parentPage',
|
|
596
640
|
collection: {
|
|
597
641
|
name: 'parent',
|
|
@@ -605,11 +649,10 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
605
649
|
components: [TEXT_COMP]
|
|
606
650
|
}, CHILD_MASTER_PAGE]
|
|
607
651
|
};
|
|
608
|
-
|
|
609
|
-
...PARENT_MASTER_PAGE,
|
|
652
|
+
var PAGE = _objectSpread(_objectSpread({}, PARENT_MASTER_PAGE), {}, {
|
|
610
653
|
formData: CUSTOM_FORM_DATA
|
|
611
|
-
};
|
|
612
|
-
|
|
654
|
+
});
|
|
655
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, CUSTOM_FORM_DATA);
|
|
613
656
|
expect(ROWS.length).toEqual(8);
|
|
614
657
|
expect(ROWS[0]).toMatchObject({
|
|
615
658
|
type: 'heading',
|
|
@@ -638,4 +681,80 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
638
681
|
key: 'Test text'
|
|
639
682
|
});
|
|
640
683
|
});
|
|
684
|
+
it('should create rows for the Collection component correctly', function () {
|
|
685
|
+
var FORM_DATA = {
|
|
686
|
+
collection: [{
|
|
687
|
+
id: '01',
|
|
688
|
+
testCollection: [{
|
|
689
|
+
testText: 'collection value'
|
|
690
|
+
}],
|
|
691
|
+
otherComp: 'one'
|
|
692
|
+
}]
|
|
693
|
+
};
|
|
694
|
+
var COLLECTION_COMP = {
|
|
695
|
+
id: 'testCollection',
|
|
696
|
+
fieldId: 'testCollection',
|
|
697
|
+
label: 'Test collection',
|
|
698
|
+
type: 'collection',
|
|
699
|
+
item: [{
|
|
700
|
+
id: 'testText',
|
|
701
|
+
fieldId: 'testText',
|
|
702
|
+
type: 'text',
|
|
703
|
+
label: 'Some nice text'
|
|
704
|
+
}],
|
|
705
|
+
show_when: [{
|
|
706
|
+
field: 'otherComp',
|
|
707
|
+
op: 'eq',
|
|
708
|
+
value: 'one'
|
|
709
|
+
}]
|
|
710
|
+
};
|
|
711
|
+
var MASTER_PAGE_WITH_COLLECTION = {
|
|
712
|
+
id: 'page1',
|
|
713
|
+
collection: {
|
|
714
|
+
name: 'collection',
|
|
715
|
+
labels: {
|
|
716
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
717
|
+
item: 'Collection entry ${index}'
|
|
718
|
+
},
|
|
719
|
+
actions: [{
|
|
720
|
+
type: 'change'
|
|
721
|
+
}, {
|
|
722
|
+
type: 'remove',
|
|
723
|
+
label: 'custom remove label'
|
|
724
|
+
}, {
|
|
725
|
+
type: 'change',
|
|
726
|
+
label: 'custom change label',
|
|
727
|
+
page: 'confirmDelete'
|
|
728
|
+
}]
|
|
729
|
+
},
|
|
730
|
+
childPages: [{
|
|
731
|
+
id: 'page1',
|
|
732
|
+
collection: {
|
|
733
|
+
name: 'collection'
|
|
734
|
+
},
|
|
735
|
+
components: [COLLECTION_COMP]
|
|
736
|
+
}],
|
|
737
|
+
formData: FORM_DATA
|
|
738
|
+
};
|
|
739
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(MASTER_PAGE_WITH_COLLECTION, null, null, FORM_DATA);
|
|
740
|
+
expect(ROWS.length).toEqual(7); // Title row + component row for each item
|
|
741
|
+
expect(ROWS[0]).toMatchObject({
|
|
742
|
+
type: 'heading',
|
|
743
|
+
key: 'Collection'
|
|
744
|
+
});
|
|
745
|
+
expect(ROWS[1]).toMatchObject({
|
|
746
|
+
type: 'heading',
|
|
747
|
+
key: 'Collection entry 1'
|
|
748
|
+
});
|
|
749
|
+
expect(ROWS[2].action.label).toEqual('Change');
|
|
750
|
+
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
751
|
+
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
752
|
+
expect(ROWS[5]).toMatchObject({
|
|
753
|
+
key: 'Item 1'
|
|
754
|
+
});
|
|
755
|
+
expect(ROWS[6]).toMatchObject({
|
|
756
|
+
value: 'collection value',
|
|
757
|
+
key: 'Some nice text'
|
|
758
|
+
});
|
|
759
|
+
});
|
|
641
760
|
});
|