@ukhomeoffice/cop-react-form-renderer 6.7.0-alpha → 6.12.0
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 +143 -105
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +942 -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 +131 -102
- package/dist/components/CollectionSummary/CollectionSummary.scss +5 -0
- package/dist/components/CollectionSummary/CollectionSummary.test.js +233 -173
- package/dist/components/CollectionSummary/Confirmation.js +12 -14
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/RenderListView.js +57 -48
- package/dist/components/CollectionSummary/RenderListView.scss +1 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +77 -78
- package/dist/components/CollectionSummary/SummaryCard.js +156 -112
- package/dist/components/CollectionSummary/SummaryCard.scss +6 -0
- package/dist/components/CollectionSummary/SummaryCard.test.js +1023 -934
- package/dist/components/CollectionSummary/SummaryCardDetails.js +138 -94
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +15 -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 +73 -70
- 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 +93 -66
- 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 +39 -22
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +74 -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 +44 -44
- 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/json/actions.json +17 -0
- package/dist/json/actionsNoSave.json +17 -0
- 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 +113 -89
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +320 -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/deleteValues.js +22 -0
- package/dist/utils/Data/deleteValues.test.js +57 -0
- package/dist/utils/Data/getAutocompleteSource.js +26 -18
- package/dist/utils/Data/getAutocompleteSource.test.js +100 -85
- package/dist/utils/Data/getDataPath.js +28 -18
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +31 -24
- package/dist/utils/Data/getOptions.test.js +53 -35
- package/dist/utils/Data/getSourceData.js +19 -6
- package/dist/utils/Data/getSourceData.test.js +80 -84
- package/dist/utils/Data/index.js +3 -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/deleteValueInFormData.js +26 -0
- package/dist/utils/Operate/deleteValueInFormData.test.js +60 -0
- 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 +11 -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 +10 -7
- package/dist/utils/Validate/additional/index.test.js +78 -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/mustBeOneOf.js +21 -0
- package/dist/utils/Validate/additional/mustBeOneOf.test.js +36 -0
- 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,112 @@ 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
|
|
108
|
-
|
|
106
|
+
it('should hide titles when hideItemTitles is true', 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
|
-
|
|
113
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
114
|
+
formData: FORM_DATA,
|
|
115
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
116
|
+
hideItemTitles: true
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
120
|
+
expect(ROWS.length).toEqual(6); // Collection title, NO item title, action rows & component rows
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should hide titles when hideItemTitles is a show_when that is true', function () {
|
|
124
|
+
var FORM_DATA = {
|
|
125
|
+
shouldShow: false,
|
|
126
|
+
collection: [{
|
|
127
|
+
id: '01',
|
|
128
|
+
testText: 'value'
|
|
129
|
+
}]
|
|
130
|
+
};
|
|
131
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
132
|
+
formData: FORM_DATA,
|
|
133
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
134
|
+
hideItemTitles: [{
|
|
135
|
+
field: 'shouldShow',
|
|
136
|
+
op: '=',
|
|
137
|
+
value: false
|
|
138
|
+
}]
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
142
|
+
expect(ROWS.length).toEqual(6); // Collection title, NO item title, action rows & component rows
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should provide default titles if collection.labels.item is not specified', function () {
|
|
146
|
+
var FORM_DATA = {
|
|
147
|
+
collection: [{
|
|
148
|
+
id: '01',
|
|
149
|
+
testText: 'value'
|
|
150
|
+
}]
|
|
151
|
+
};
|
|
152
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
153
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
118
154
|
labels: {}
|
|
119
|
-
},
|
|
155
|
+
}),
|
|
120
156
|
formData: FORM_DATA
|
|
121
|
-
};
|
|
122
|
-
|
|
157
|
+
});
|
|
158
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
123
159
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
124
160
|
expect(ROWS[1].key).toEqual('Item 1');
|
|
125
161
|
});
|
|
126
|
-
it('should return correctly formatted rows for mutliple entries', ()
|
|
127
|
-
|
|
162
|
+
it('should return correctly formatted rows for mutliple entries', function () {
|
|
163
|
+
var FORM_DATA = {
|
|
128
164
|
collection: [{
|
|
129
165
|
id: '01',
|
|
130
166
|
testText: 'value'
|
|
@@ -133,11 +169,10 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
133
169
|
testText: 'value'
|
|
134
170
|
}]
|
|
135
171
|
};
|
|
136
|
-
|
|
137
|
-
...MASTER_PAGE,
|
|
172
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
138
173
|
formData: FORM_DATA
|
|
139
|
-
};
|
|
140
|
-
|
|
174
|
+
});
|
|
175
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
141
176
|
expect(ROWS.length).toEqual(13); // Title row + component row for each item
|
|
142
177
|
expect(ROWS[0]).toMatchObject({
|
|
143
178
|
type: 'heading',
|
|
@@ -174,22 +209,20 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
174
209
|
key: 'Test date'
|
|
175
210
|
});
|
|
176
211
|
});
|
|
177
|
-
it('should use values from top-level formData if they don\'t exist in the item', ()
|
|
178
|
-
|
|
212
|
+
it('should use values from top-level formData if they don\'t exist in the item', function () {
|
|
213
|
+
var FORM_DATA = {
|
|
179
214
|
testText: 'value',
|
|
180
215
|
collection: [{
|
|
181
216
|
id: '01'
|
|
182
217
|
}]
|
|
183
218
|
};
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
childPages: [{
|
|
187
|
-
...PAGES[0],
|
|
219
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
220
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
188
221
|
formData: FORM_DATA
|
|
189
|
-
}, PAGES[1]],
|
|
222
|
+
}), PAGES[1]],
|
|
190
223
|
formData: FORM_DATA
|
|
191
|
-
};
|
|
192
|
-
|
|
224
|
+
});
|
|
225
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
193
226
|
expect(ROWS.length).toEqual(7); // Title row + component row for each item
|
|
194
227
|
expect(ROWS[0]).toMatchObject({
|
|
195
228
|
type: 'heading',
|
|
@@ -211,8 +244,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
211
244
|
key: 'Test date'
|
|
212
245
|
});
|
|
213
246
|
});
|
|
214
|
-
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined', ()
|
|
215
|
-
|
|
247
|
+
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined', function () {
|
|
248
|
+
var FORM_DATA = {
|
|
216
249
|
collectionActiveId: '02',
|
|
217
250
|
collection: [{
|
|
218
251
|
id: '01',
|
|
@@ -222,15 +255,13 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
222
255
|
testText: 'value'
|
|
223
256
|
}]
|
|
224
257
|
};
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
collection: {
|
|
228
|
-
...MASTER_PAGE.collection,
|
|
258
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
259
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
229
260
|
onlyShowActiveEntryOnCYA: true
|
|
230
|
-
},
|
|
261
|
+
}),
|
|
231
262
|
formData: FORM_DATA
|
|
232
|
-
};
|
|
233
|
-
|
|
263
|
+
});
|
|
264
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
234
265
|
expect(ROWS.length).toEqual(7); // Title row + component row for only the active item.
|
|
235
266
|
expect(ROWS[0]).toMatchObject({
|
|
236
267
|
type: 'heading',
|
|
@@ -252,8 +283,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
252
283
|
key: 'Test date'
|
|
253
284
|
});
|
|
254
285
|
});
|
|
255
|
-
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is an array', ()
|
|
256
|
-
|
|
286
|
+
it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is an array', function () {
|
|
287
|
+
var FORM_DATA = {
|
|
257
288
|
text: 'blue',
|
|
258
289
|
collectionActiveId: '02',
|
|
259
290
|
collection: [{
|
|
@@ -264,19 +295,17 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
264
295
|
testText: 'value'
|
|
265
296
|
}]
|
|
266
297
|
};
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
collection: {
|
|
270
|
-
...MASTER_PAGE.collection,
|
|
298
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
299
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
271
300
|
onlyShowActiveEntryOnCYA: [{
|
|
272
301
|
field: 'text',
|
|
273
302
|
op: 'eq',
|
|
274
303
|
value: 'blue'
|
|
275
304
|
}]
|
|
276
|
-
},
|
|
305
|
+
}),
|
|
277
306
|
formData: FORM_DATA
|
|
278
|
-
};
|
|
279
|
-
|
|
307
|
+
});
|
|
308
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
280
309
|
expect(ROWS.length).toEqual(7); // Title row + component row for only the active item.
|
|
281
310
|
expect(ROWS[0]).toMatchObject({
|
|
282
311
|
type: 'heading',
|
|
@@ -298,8 +327,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
298
327
|
key: 'Test date'
|
|
299
328
|
});
|
|
300
329
|
});
|
|
301
|
-
it('should exclude components that should not be shown', ()
|
|
302
|
-
|
|
330
|
+
it('should exclude components that should not be shown', function () {
|
|
331
|
+
var FD = {
|
|
303
332
|
collection: [{
|
|
304
333
|
id: '01',
|
|
305
334
|
otherField: 'yes',
|
|
@@ -310,14 +339,12 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
310
339
|
testText: 'testing'
|
|
311
340
|
}]
|
|
312
341
|
};
|
|
313
|
-
|
|
314
|
-
...MASTER_PAGE,
|
|
342
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
315
343
|
collection: {
|
|
316
344
|
name: 'collection'
|
|
317
345
|
},
|
|
318
346
|
formData: FD,
|
|
319
|
-
childPages: [{
|
|
320
|
-
...PAGES[0],
|
|
347
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
321
348
|
components: [{
|
|
322
349
|
id: 'testText',
|
|
323
350
|
fieldId: 'testText',
|
|
@@ -329,9 +356,9 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
329
356
|
value: "yes"
|
|
330
357
|
}
|
|
331
358
|
}]
|
|
332
|
-
}]
|
|
333
|
-
};
|
|
334
|
-
|
|
359
|
+
})]
|
|
360
|
+
});
|
|
361
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
|
|
335
362
|
expect(ROWS.length).toEqual(4);
|
|
336
363
|
expect(ROWS[0]).toMatchObject({
|
|
337
364
|
type: 'heading',
|
|
@@ -350,30 +377,28 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
350
377
|
key: 'Test text'
|
|
351
378
|
});
|
|
352
379
|
});
|
|
353
|
-
it('should exclude pages that should not be shown', ()
|
|
354
|
-
|
|
380
|
+
it('should exclude pages that should not be shown', function () {
|
|
381
|
+
var FD = {
|
|
355
382
|
collection: [{
|
|
356
383
|
id: '01',
|
|
357
384
|
otherField: 'yes',
|
|
358
385
|
testText: 'testing'
|
|
359
386
|
}]
|
|
360
387
|
};
|
|
361
|
-
|
|
362
|
-
...MASTER_PAGE,
|
|
388
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
363
389
|
collection: {
|
|
364
390
|
name: 'collection'
|
|
365
391
|
},
|
|
366
392
|
formData: FD,
|
|
367
|
-
childPages: [{
|
|
368
|
-
...PAGES[0],
|
|
393
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
369
394
|
show_when: {
|
|
370
395
|
field: "otherField",
|
|
371
396
|
op: "!=",
|
|
372
397
|
value: "yes"
|
|
373
398
|
}
|
|
374
|
-
}, PAGES[1]]
|
|
375
|
-
};
|
|
376
|
-
|
|
399
|
+
}), PAGES[1]]
|
|
400
|
+
});
|
|
401
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
|
|
377
402
|
expect(ROWS.length).toEqual(3); // Missing the page with the text component on.
|
|
378
403
|
expect(ROWS[0]).toMatchObject({
|
|
379
404
|
type: 'heading',
|
|
@@ -388,28 +413,25 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
388
413
|
key: 'Test date'
|
|
389
414
|
});
|
|
390
415
|
});
|
|
391
|
-
it('should include rows for custom headings', ()
|
|
392
|
-
|
|
416
|
+
it('should include rows for custom headings', function () {
|
|
417
|
+
var FORM_DATA = {
|
|
393
418
|
collection: [{
|
|
394
419
|
id: '01',
|
|
395
420
|
testText: 'value'
|
|
396
421
|
}]
|
|
397
422
|
};
|
|
398
|
-
|
|
399
|
-
...MASTER_PAGE,
|
|
423
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
400
424
|
formData: FORM_DATA,
|
|
401
|
-
childPages: [{
|
|
402
|
-
|
|
403
|
-
collection: {
|
|
404
|
-
...PAGES[0].collection,
|
|
425
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
426
|
+
collection: _objectSpread(_objectSpread({}, PAGES[0].collection), {}, {
|
|
405
427
|
heading: {
|
|
406
428
|
size: 'm',
|
|
407
429
|
text: 'Custom page heading'
|
|
408
430
|
}
|
|
409
|
-
}
|
|
410
|
-
}]
|
|
411
|
-
};
|
|
412
|
-
|
|
431
|
+
})
|
|
432
|
+
})]
|
|
433
|
+
});
|
|
434
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
413
435
|
expect(ROWS.length).toEqual(7);
|
|
414
436
|
expect(ROWS[0]).toMatchObject({
|
|
415
437
|
type: 'heading',
|
|
@@ -432,106 +454,168 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
432
454
|
key: 'Test text'
|
|
433
455
|
});
|
|
434
456
|
});
|
|
435
|
-
it('should
|
|
436
|
-
|
|
457
|
+
it('should allow interpolation of custom headings', function () {
|
|
458
|
+
var FORM_DATA = {
|
|
437
459
|
collection: [{
|
|
438
460
|
id: '01',
|
|
439
461
|
testText: 'value'
|
|
440
462
|
}]
|
|
441
463
|
};
|
|
442
|
-
|
|
443
|
-
...MASTER_PAGE,
|
|
464
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
444
465
|
formData: FORM_DATA,
|
|
445
|
-
childPages: [{
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
...PAGES[0].collection,
|
|
466
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
467
|
+
collection: _objectSpread(_objectSpread({}, PAGES[0].collection), {}, {
|
|
468
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
449
469
|
heading: {
|
|
450
|
-
|
|
470
|
+
size: 'm',
|
|
471
|
+
text: 'interpolated text: ${testText}'
|
|
451
472
|
}
|
|
473
|
+
})
|
|
474
|
+
})]
|
|
475
|
+
});
|
|
476
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
477
|
+
expect(ROWS.length).toEqual(7);
|
|
478
|
+
expect(ROWS[0]).toMatchObject({
|
|
479
|
+
type: 'heading',
|
|
480
|
+
key: 'Collection'
|
|
481
|
+
});
|
|
482
|
+
expect(ROWS[1]).toMatchObject({
|
|
483
|
+
type: 'heading',
|
|
484
|
+
key: 'Collection entry 1'
|
|
485
|
+
});
|
|
486
|
+
expect(ROWS[2].action.label).toEqual('Change');
|
|
487
|
+
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
488
|
+
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
489
|
+
expect(ROWS[5]).toMatchObject({
|
|
490
|
+
type: 'heading',
|
|
491
|
+
key: 'interpolated text: value',
|
|
492
|
+
size: 'm'
|
|
493
|
+
});
|
|
494
|
+
expect(ROWS[6]).toMatchObject({
|
|
495
|
+
value: 'value',
|
|
496
|
+
key: 'Test text'
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
it('should alow configuration of collection name headings', function () {
|
|
500
|
+
var FORM_DATA = {
|
|
501
|
+
collection: [{
|
|
502
|
+
id: '01',
|
|
503
|
+
testText: 'value'
|
|
504
|
+
}]
|
|
505
|
+
};
|
|
506
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
507
|
+
formData: FORM_DATA,
|
|
508
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
509
|
+
collectionHeading: {
|
|
510
|
+
text: 'Custom collection heading',
|
|
511
|
+
size: 'm',
|
|
512
|
+
changeLinkPage: PAGES[0].id
|
|
452
513
|
}
|
|
514
|
+
}),
|
|
515
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
516
|
+
collection: _objectSpread({}, PAGES[0].collection)
|
|
517
|
+
})]
|
|
518
|
+
});
|
|
519
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
520
|
+
expect(ROWS.length).toEqual(6);
|
|
521
|
+
expect(ROWS[0]).toMatchObject({
|
|
522
|
+
type: 'headingWithAction',
|
|
523
|
+
key: 'Custom collection heading'
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
it('should default to a title size of small if one is not specified', function () {
|
|
527
|
+
var FORM_DATA = {
|
|
528
|
+
collection: [{
|
|
529
|
+
id: '01',
|
|
530
|
+
testText: 'value'
|
|
453
531
|
}]
|
|
454
532
|
};
|
|
455
|
-
|
|
533
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
534
|
+
formData: FORM_DATA,
|
|
535
|
+
childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
536
|
+
collection: _objectSpread(_objectSpread({}, PAGES[0].collection), {}, {
|
|
537
|
+
heading: {
|
|
538
|
+
text: 'Custom page heading'
|
|
539
|
+
}
|
|
540
|
+
})
|
|
541
|
+
})]
|
|
542
|
+
});
|
|
543
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
456
544
|
expect(ROWS[5]).toMatchObject({
|
|
457
545
|
type: 'heading',
|
|
458
546
|
key: 'Custom page heading',
|
|
459
547
|
size: 's'
|
|
460
548
|
});
|
|
461
549
|
});
|
|
462
|
-
it('should position actions under the title if actionPosition flag is not specified', ()
|
|
463
|
-
|
|
550
|
+
it('should position actions under the title if actionPosition flag is not specified', function () {
|
|
551
|
+
var FORM_DATA = {
|
|
464
552
|
collection: [{
|
|
465
553
|
id: '01',
|
|
466
554
|
testText: 'value'
|
|
467
555
|
}]
|
|
468
556
|
};
|
|
469
|
-
|
|
470
|
-
...MASTER_PAGE,
|
|
557
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
471
558
|
formData: FORM_DATA
|
|
472
|
-
};
|
|
473
|
-
|
|
559
|
+
});
|
|
560
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
474
561
|
expect(ROWS[2].action.label).toEqual('Change');
|
|
475
562
|
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
476
563
|
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
477
564
|
});
|
|
478
|
-
it('should position actions under the title if actionPosition flag is top', ()
|
|
479
|
-
|
|
565
|
+
it('should position actions under the title if actionPosition flag is top', function () {
|
|
566
|
+
var FORM_DATA = {
|
|
480
567
|
collection: [{
|
|
481
568
|
id: '01',
|
|
482
569
|
testText: 'value'
|
|
483
570
|
}]
|
|
484
571
|
};
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
collection: {
|
|
488
|
-
...MASTER_PAGE.collection,
|
|
572
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
573
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
489
574
|
actionPosition: 'top'
|
|
490
|
-
},
|
|
575
|
+
}),
|
|
491
576
|
formData: FORM_DATA
|
|
492
|
-
};
|
|
493
|
-
|
|
577
|
+
});
|
|
578
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
494
579
|
expect(ROWS[2].action.label).toEqual('Change');
|
|
495
580
|
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
496
581
|
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
497
582
|
});
|
|
498
|
-
it('should position actions under all other rows if actionPosition flag is bottom', ()
|
|
499
|
-
|
|
583
|
+
it('should position actions under all other rows if actionPosition flag is bottom', function () {
|
|
584
|
+
var FORM_DATA = {
|
|
500
585
|
collection: [{
|
|
501
586
|
id: '01',
|
|
502
587
|
testText: 'value'
|
|
503
588
|
}]
|
|
504
589
|
};
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
collection: {
|
|
508
|
-
...MASTER_PAGE.collection,
|
|
590
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
591
|
+
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
509
592
|
actionPosition: 'bottom'
|
|
510
|
-
},
|
|
593
|
+
}),
|
|
511
594
|
formData: FORM_DATA
|
|
512
|
-
};
|
|
513
|
-
|
|
595
|
+
});
|
|
596
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
|
|
514
597
|
expect(ROWS[ROWS.length - 3].action.label).toEqual('Change');
|
|
515
598
|
expect(ROWS[ROWS.length - 2].action.label).toEqual('custom remove label');
|
|
516
599
|
expect(ROWS[ROWS.length - 1].action.label).toEqual('custom change label');
|
|
517
600
|
});
|
|
518
|
-
it('should ignore the result of the override function if it returns nullish', ()
|
|
519
|
-
|
|
601
|
+
it('should ignore the result of the override function if it returns nullish', function () {
|
|
602
|
+
var FORM_DATA = {
|
|
520
603
|
collection: [{
|
|
521
604
|
id: '01',
|
|
522
605
|
testText: 'value'
|
|
523
606
|
}]
|
|
524
607
|
};
|
|
525
|
-
|
|
526
|
-
...MASTER_PAGE,
|
|
608
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
527
609
|
formData: FORM_DATA
|
|
528
|
-
};
|
|
529
|
-
|
|
610
|
+
});
|
|
611
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, function () {
|
|
612
|
+
return null;
|
|
613
|
+
}, FORM_DATA);
|
|
530
614
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
531
615
|
expect(ROWS[5].key).toEqual("Test text");
|
|
532
616
|
});
|
|
533
|
-
it('should use the rows produced by the override function if provided', ()
|
|
534
|
-
|
|
617
|
+
it('should use the rows produced by the override function if provided', function () {
|
|
618
|
+
var FORM_DATA = {
|
|
535
619
|
collection: [{
|
|
536
620
|
id: '01',
|
|
537
621
|
testText: 'value'
|
|
@@ -539,23 +623,22 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
539
623
|
};
|
|
540
624
|
|
|
541
625
|
// eslint-disable-next-line arrow-body-style
|
|
542
|
-
|
|
626
|
+
var OVERRIDE = function OVERRIDE(page, comp) {
|
|
543
627
|
// This will be called for each component on the page,
|
|
544
628
|
// returning a custom row object.
|
|
545
629
|
return {
|
|
546
630
|
key: "CustomRowFor".concat(comp.label)
|
|
547
631
|
};
|
|
548
632
|
};
|
|
549
|
-
|
|
550
|
-
...MASTER_PAGE,
|
|
633
|
+
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
551
634
|
formData: FORM_DATA
|
|
552
|
-
};
|
|
553
|
-
|
|
635
|
+
});
|
|
636
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, OVERRIDE, FORM_DATA);
|
|
554
637
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
555
638
|
expect(ROWS[5].key).toEqual("CustomRowFor".concat(TEXT_COMP.label));
|
|
556
639
|
});
|
|
557
|
-
it('should create rows for nested collections correctly', ()
|
|
558
|
-
|
|
640
|
+
it('should create rows for nested collections correctly', function () {
|
|
641
|
+
var CUSTOM_FORM_DATA = {
|
|
559
642
|
parentActiveId: '001',
|
|
560
643
|
childActiveId: '001',
|
|
561
644
|
parent: [{
|
|
@@ -567,7 +650,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
567
650
|
}]
|
|
568
651
|
}]
|
|
569
652
|
};
|
|
570
|
-
|
|
653
|
+
var CHILD_MASTER_PAGE = {
|
|
571
654
|
id: 'childPage',
|
|
572
655
|
collection: {
|
|
573
656
|
name: 'parent.child',
|
|
@@ -591,7 +674,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
591
674
|
components: [TEXT_COMP]
|
|
592
675
|
}]
|
|
593
676
|
};
|
|
594
|
-
|
|
677
|
+
var PARENT_MASTER_PAGE = {
|
|
595
678
|
id: 'parentPage',
|
|
596
679
|
collection: {
|
|
597
680
|
name: 'parent',
|
|
@@ -605,11 +688,10 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
605
688
|
components: [TEXT_COMP]
|
|
606
689
|
}, CHILD_MASTER_PAGE]
|
|
607
690
|
};
|
|
608
|
-
|
|
609
|
-
...PARENT_MASTER_PAGE,
|
|
691
|
+
var PAGE = _objectSpread(_objectSpread({}, PARENT_MASTER_PAGE), {}, {
|
|
610
692
|
formData: CUSTOM_FORM_DATA
|
|
611
|
-
};
|
|
612
|
-
|
|
693
|
+
});
|
|
694
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, CUSTOM_FORM_DATA);
|
|
613
695
|
expect(ROWS.length).toEqual(8);
|
|
614
696
|
expect(ROWS[0]).toMatchObject({
|
|
615
697
|
type: 'heading',
|
|
@@ -638,4 +720,80 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
|
|
|
638
720
|
key: 'Test text'
|
|
639
721
|
});
|
|
640
722
|
});
|
|
723
|
+
it('should create rows for the Collection component correctly', function () {
|
|
724
|
+
var FORM_DATA = {
|
|
725
|
+
collection: [{
|
|
726
|
+
id: '01',
|
|
727
|
+
testCollection: [{
|
|
728
|
+
testText: 'collection value'
|
|
729
|
+
}],
|
|
730
|
+
otherComp: 'one'
|
|
731
|
+
}]
|
|
732
|
+
};
|
|
733
|
+
var COLLECTION_COMP = {
|
|
734
|
+
id: 'testCollection',
|
|
735
|
+
fieldId: 'testCollection',
|
|
736
|
+
label: 'Test collection',
|
|
737
|
+
type: 'collection',
|
|
738
|
+
item: [{
|
|
739
|
+
id: 'testText',
|
|
740
|
+
fieldId: 'testText',
|
|
741
|
+
type: 'text',
|
|
742
|
+
label: 'Some nice text'
|
|
743
|
+
}],
|
|
744
|
+
show_when: [{
|
|
745
|
+
field: 'otherComp',
|
|
746
|
+
op: 'eq',
|
|
747
|
+
value: 'one'
|
|
748
|
+
}]
|
|
749
|
+
};
|
|
750
|
+
var MASTER_PAGE_WITH_COLLECTION = {
|
|
751
|
+
id: 'page1',
|
|
752
|
+
collection: {
|
|
753
|
+
name: 'collection',
|
|
754
|
+
labels: {
|
|
755
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
756
|
+
item: 'Collection entry ${index}'
|
|
757
|
+
},
|
|
758
|
+
actions: [{
|
|
759
|
+
type: 'change'
|
|
760
|
+
}, {
|
|
761
|
+
type: 'remove',
|
|
762
|
+
label: 'custom remove label'
|
|
763
|
+
}, {
|
|
764
|
+
type: 'change',
|
|
765
|
+
label: 'custom change label',
|
|
766
|
+
page: 'confirmDelete'
|
|
767
|
+
}]
|
|
768
|
+
},
|
|
769
|
+
childPages: [{
|
|
770
|
+
id: 'page1',
|
|
771
|
+
collection: {
|
|
772
|
+
name: 'collection'
|
|
773
|
+
},
|
|
774
|
+
components: [COLLECTION_COMP]
|
|
775
|
+
}],
|
|
776
|
+
formData: FORM_DATA
|
|
777
|
+
};
|
|
778
|
+
var ROWS = (0, _getCYARowsForCollectionPage.default)(MASTER_PAGE_WITH_COLLECTION, null, null, FORM_DATA);
|
|
779
|
+
expect(ROWS.length).toEqual(7); // Title row + component row for each item
|
|
780
|
+
expect(ROWS[0]).toMatchObject({
|
|
781
|
+
type: 'heading',
|
|
782
|
+
key: 'Collection'
|
|
783
|
+
});
|
|
784
|
+
expect(ROWS[1]).toMatchObject({
|
|
785
|
+
type: 'heading',
|
|
786
|
+
key: 'Collection entry 1'
|
|
787
|
+
});
|
|
788
|
+
expect(ROWS[2].action.label).toEqual('Change');
|
|
789
|
+
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
790
|
+
expect(ROWS[4].action.label).toEqual('custom change label');
|
|
791
|
+
expect(ROWS[5]).toMatchObject({
|
|
792
|
+
key: 'Item 1'
|
|
793
|
+
});
|
|
794
|
+
expect(ROWS[6]).toMatchObject({
|
|
795
|
+
value: 'collection value',
|
|
796
|
+
key: 'Some nice text'
|
|
797
|
+
});
|
|
798
|
+
});
|
|
641
799
|
});
|