@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,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
var _getCYACollectionDeleteAction = _interopRequireDefault(require("./getCYACollectionDeleteAction"));
|
|
4
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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', function () {
|
|
12
|
+
describe('CheckYourAnswers', function () {
|
|
13
|
+
describe('getCYACollectionDeleteAction', function () {
|
|
14
|
+
it('should remove selected item from the form data', function () {
|
|
15
|
+
var PAGE = {
|
|
12
16
|
id: 'pageid',
|
|
13
17
|
collection: {
|
|
14
18
|
name: 'collectionName',
|
|
@@ -17,13 +21,11 @@ describe('utils', () => {
|
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
23
|
};
|
|
20
|
-
|
|
24
|
+
var ITEM = {
|
|
21
25
|
id: 2
|
|
22
26
|
};
|
|
23
|
-
|
|
24
|
-
page: {
|
|
25
|
-
...PAGE
|
|
26
|
-
},
|
|
27
|
+
var TEST_DATA = {
|
|
28
|
+
page: _objectSpread({}, PAGE),
|
|
27
29
|
collectionName: [{
|
|
28
30
|
id: 1
|
|
29
31
|
}, {
|
|
@@ -32,27 +34,27 @@ describe('utils', () => {
|
|
|
32
34
|
id: 3
|
|
33
35
|
}]
|
|
34
36
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
var data = null;
|
|
38
|
+
var ON_ACTION = function ON_ACTION(_, callback) {
|
|
37
39
|
data = callback(TEST_DATA);
|
|
38
40
|
};
|
|
39
|
-
|
|
41
|
+
var action = (0, _getCYACollectionDeleteAction.default)(PAGE, ITEM, ON_ACTION, 0, {}, {});
|
|
40
42
|
action.action.onAction();
|
|
41
43
|
expect(data.collectionName.length).toEqual(2);
|
|
42
44
|
expect(data.collectionName[0].id).toEqual(1);
|
|
43
45
|
expect(data.collectionName[1].id).toEqual(3);
|
|
44
46
|
});
|
|
45
|
-
it('should remove nested item from the form data', ()
|
|
46
|
-
|
|
47
|
+
it('should remove nested item from the form data', function () {
|
|
48
|
+
var PAGE = {
|
|
47
49
|
id: 'pageid',
|
|
48
50
|
collection: {
|
|
49
51
|
name: 'parent.child.grandchild'
|
|
50
52
|
}
|
|
51
53
|
};
|
|
52
|
-
|
|
54
|
+
var ITEM = {
|
|
53
55
|
id: '001'
|
|
54
56
|
};
|
|
55
|
-
|
|
57
|
+
var TEST_DATA = {
|
|
56
58
|
parentActiveId: '000',
|
|
57
59
|
childActiveId: '000',
|
|
58
60
|
grandchildActiveId: '000',
|
|
@@ -72,16 +74,16 @@ describe('utils', () => {
|
|
|
72
74
|
}]
|
|
73
75
|
}]
|
|
74
76
|
};
|
|
75
|
-
|
|
77
|
+
var ACTIVE_IDS = {
|
|
76
78
|
parentActiveId: '001',
|
|
77
79
|
childActiveId: '001',
|
|
78
80
|
grandchildActiveId: '001'
|
|
79
81
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
var data = null;
|
|
83
|
+
var ON_ACTION = function ON_ACTION(_, callback) {
|
|
82
84
|
data = callback(TEST_DATA);
|
|
83
85
|
};
|
|
84
|
-
|
|
86
|
+
var action = (0, _getCYACollectionDeleteAction.default)(PAGE, ITEM, ON_ACTION, 0, {}, ACTIVE_IDS);
|
|
85
87
|
action.action.onAction();
|
|
86
88
|
expect(data.parentActiveId).toEqual('001');
|
|
87
89
|
expect(data.childActiveId).toEqual('001');
|
|
@@ -89,17 +91,17 @@ describe('utils', () => {
|
|
|
89
91
|
expect(data.parent[1].child[1].grandchild.length).toEqual(1);
|
|
90
92
|
expect(data.parent[1].child[1].grandchild[0].id).toEqual('000');
|
|
91
93
|
});
|
|
92
|
-
it('should do nothing if activeIds are not provided', ()
|
|
93
|
-
|
|
94
|
+
it('should do nothing if activeIds are not provided', function () {
|
|
95
|
+
var PAGE = {
|
|
94
96
|
id: 'pageid',
|
|
95
97
|
collection: {
|
|
96
98
|
name: 'parent.child.grandchild'
|
|
97
99
|
}
|
|
98
100
|
};
|
|
99
|
-
|
|
101
|
+
var ITEM = {
|
|
100
102
|
id: '001'
|
|
101
103
|
};
|
|
102
|
-
|
|
104
|
+
var TEST_DATA = {
|
|
103
105
|
parentActiveId: '000',
|
|
104
106
|
childActiveId: '000',
|
|
105
107
|
grandchildActiveId: '000',
|
|
@@ -119,28 +121,28 @@ describe('utils', () => {
|
|
|
119
121
|
}]
|
|
120
122
|
}]
|
|
121
123
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
var data = null;
|
|
125
|
+
var ON_ACTION = function ON_ACTION(_, callback) {
|
|
124
126
|
data = callback(TEST_DATA);
|
|
125
127
|
};
|
|
126
|
-
|
|
128
|
+
var action = (0, _getCYACollectionDeleteAction.default)(PAGE, ITEM, ON_ACTION, 0, {});
|
|
127
129
|
action.action.onAction();
|
|
128
130
|
expect(data.parentActiveId).toEqual('000');
|
|
129
131
|
expect(data.childActiveId).toEqual('000');
|
|
130
132
|
expect(data.grandchildActiveId).toEqual('000');
|
|
131
133
|
expect(data.parent[1].child[1].grandchild.length).toEqual(2);
|
|
132
134
|
});
|
|
133
|
-
it('should do nothing if the activeIds point to an non-existant entry', ()
|
|
134
|
-
|
|
135
|
+
it('should do nothing if the activeIds point to an non-existant entry', function () {
|
|
136
|
+
var PAGE = {
|
|
135
137
|
id: 'pageid',
|
|
136
138
|
collection: {
|
|
137
139
|
name: 'parent.child.grandchild'
|
|
138
140
|
}
|
|
139
141
|
};
|
|
140
|
-
|
|
142
|
+
var ITEM = {
|
|
141
143
|
id: '001'
|
|
142
144
|
};
|
|
143
|
-
|
|
145
|
+
var TEST_DATA = {
|
|
144
146
|
parentActiveId: '000',
|
|
145
147
|
childActiveId: '000',
|
|
146
148
|
grandchildActiveId: '000',
|
|
@@ -160,21 +162,21 @@ describe('utils', () => {
|
|
|
160
162
|
}]
|
|
161
163
|
}]
|
|
162
164
|
};
|
|
163
|
-
|
|
165
|
+
var ACTIVE_IDS = {
|
|
164
166
|
parentActiveId: 'wrong',
|
|
165
167
|
childActiveId: 'bad',
|
|
166
168
|
grandchildActiveId: 'no'
|
|
167
169
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
var data = null;
|
|
171
|
+
var ON_ACTION = function ON_ACTION(_, callback) {
|
|
170
172
|
data = callback(TEST_DATA);
|
|
171
173
|
};
|
|
172
|
-
|
|
174
|
+
var action = (0, _getCYACollectionDeleteAction.default)(PAGE, ITEM, ON_ACTION, 0, {}, ACTIVE_IDS);
|
|
173
175
|
action.action.onAction();
|
|
174
176
|
expect(data.parent[1].child[1].grandchild.length).toEqual(2);
|
|
175
177
|
});
|
|
176
|
-
it('should get label to custom value', ()
|
|
177
|
-
|
|
178
|
+
it('should get label to custom value', function () {
|
|
179
|
+
var PAGE = {
|
|
178
180
|
id: 'pageid',
|
|
179
181
|
collection: {
|
|
180
182
|
name: 'collectionName',
|
|
@@ -183,10 +185,10 @@ describe('utils', () => {
|
|
|
183
185
|
}
|
|
184
186
|
}
|
|
185
187
|
};
|
|
186
|
-
|
|
188
|
+
var ITEM = {
|
|
187
189
|
id: 2
|
|
188
190
|
};
|
|
189
|
-
|
|
191
|
+
var action = (0, _getCYACollectionDeleteAction.default)(PAGE, ITEM, function () {}, 0, {
|
|
190
192
|
label: "customName"
|
|
191
193
|
}, {});
|
|
192
194
|
expect(action.action.label).toEqual('customName');
|
|
@@ -13,13 +13,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
13
13
|
|
|
14
14
|
// Local imports
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
var setNestedValue = function setNestedValue(component, page) {
|
|
17
17
|
var _component$data;
|
|
18
|
-
(_component$data = component.data) === null || _component$data === void 0 || (_component$data = _component$data.options) === null || _component$data === void 0 || _component$data.forEach(option
|
|
18
|
+
(_component$data = component.data) === null || _component$data === void 0 || (_component$data = _component$data.options) === null || _component$data === void 0 || _component$data.forEach(function (option) {
|
|
19
19
|
// check if option is selected and has nested component
|
|
20
20
|
if (Array.isArray(option.nested) && (0, _optionIsSelected.default)(page.formData[component.id], option)) {
|
|
21
|
-
option.nested.forEach(paramChild
|
|
22
|
-
|
|
21
|
+
option.nested.forEach(function (paramChild) {
|
|
22
|
+
var child = paramChild;
|
|
23
23
|
child.value = page.formData[child.id];
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -35,9 +35,9 @@ const setNestedValue = (component, page) => {
|
|
|
35
35
|
*
|
|
36
36
|
* @returns A configuration object for a Check your answers row.
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
var getCYARow = function getCYARow(page, component, onAction) {
|
|
39
39
|
var _page$cya_link;
|
|
40
|
-
|
|
40
|
+
var value = '';
|
|
41
41
|
if (page.formData && component.fieldId) {
|
|
42
42
|
value = page.formData[component.fieldId];
|
|
43
43
|
setNestedValue(component, page);
|
|
@@ -3,27 +3,29 @@
|
|
|
3
3
|
var _setupTests = require("../../setupTests");
|
|
4
4
|
var _getCYARow = _interopRequireDefault(require("./getCYARow"));
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
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); }
|
|
7
|
+
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; }
|
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
9
|
+
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
|
|
10
|
+
describe('utils', function () {
|
|
11
|
+
describe('CheckYourAnswers', function () {
|
|
12
|
+
describe('getCYARow', function () {
|
|
13
|
+
it('should get an appropriate row for a readonly text component', function () {
|
|
14
|
+
var PAGE = {
|
|
13
15
|
id: 'page',
|
|
14
16
|
formData: {
|
|
15
17
|
a: 'Bravo'
|
|
16
18
|
}
|
|
17
19
|
};
|
|
18
|
-
|
|
20
|
+
var COMPONENT = {
|
|
19
21
|
type: 'text',
|
|
20
22
|
readonly: true,
|
|
21
23
|
id: 'a',
|
|
22
24
|
fieldId: 'a',
|
|
23
25
|
label: 'Alpha'
|
|
24
26
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
28
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
27
29
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
28
30
|
pageId: PAGE.id,
|
|
29
31
|
fieldId: COMPONENT.fieldId,
|
|
@@ -33,19 +35,19 @@ describe('utils', () => {
|
|
|
33
35
|
action: null
|
|
34
36
|
});
|
|
35
37
|
});
|
|
36
|
-
it('should get an appropriate row for a readonly text component with no value', ()
|
|
37
|
-
|
|
38
|
+
it('should get an appropriate row for a readonly text component with no value', function () {
|
|
39
|
+
var PAGE = {
|
|
38
40
|
id: 'page',
|
|
39
41
|
formData: {}
|
|
40
42
|
};
|
|
41
|
-
|
|
43
|
+
var COMPONENT = {
|
|
42
44
|
type: 'text',
|
|
43
45
|
readonly: true,
|
|
44
46
|
id: 'a',
|
|
45
47
|
fieldId: 'a',
|
|
46
48
|
label: 'Alpha'
|
|
47
49
|
};
|
|
48
|
-
|
|
50
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
49
51
|
expect((0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION)).toEqual({
|
|
50
52
|
pageId: PAGE.id,
|
|
51
53
|
id: COMPONENT.id,
|
|
@@ -56,21 +58,21 @@ describe('utils', () => {
|
|
|
56
58
|
action: null
|
|
57
59
|
});
|
|
58
60
|
});
|
|
59
|
-
it('should get an appropriate row for a readonly non-editable component', ()
|
|
60
|
-
|
|
61
|
+
it('should get an appropriate row for a readonly non-editable component', function () {
|
|
62
|
+
var PAGE = {
|
|
61
63
|
id: 'page',
|
|
62
64
|
formData: {
|
|
63
65
|
a: 'BLAH'
|
|
64
66
|
}
|
|
65
67
|
};
|
|
66
|
-
|
|
68
|
+
var COMPONENT = {
|
|
67
69
|
type: 'blah',
|
|
68
70
|
readonly: true,
|
|
69
71
|
id: 'a',
|
|
70
72
|
fieldId: 'a',
|
|
71
73
|
label: 'Alpha'
|
|
72
74
|
};
|
|
73
|
-
|
|
75
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
74
76
|
expect((0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION)).toEqual({
|
|
75
77
|
pageId: PAGE.id,
|
|
76
78
|
id: COMPONENT.id,
|
|
@@ -80,22 +82,22 @@ describe('utils', () => {
|
|
|
80
82
|
action: null
|
|
81
83
|
});
|
|
82
84
|
});
|
|
83
|
-
it('should use the cya_label where there is no label', ()
|
|
84
|
-
|
|
85
|
+
it('should use the cya_label where there is no label', function () {
|
|
86
|
+
var PAGE = {
|
|
85
87
|
id: 'page',
|
|
86
88
|
formData: {
|
|
87
89
|
a: 'Bravo'
|
|
88
90
|
}
|
|
89
91
|
};
|
|
90
|
-
|
|
92
|
+
var COMPONENT = {
|
|
91
93
|
type: 'text',
|
|
92
94
|
readonly: true,
|
|
93
95
|
id: 'a',
|
|
94
96
|
fieldId: 'a',
|
|
95
97
|
cya_label: 'CYA Alpha'
|
|
96
98
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
100
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
99
101
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
100
102
|
pageId: PAGE.id,
|
|
101
103
|
fieldId: COMPONENT.fieldId,
|
|
@@ -105,22 +107,22 @@ describe('utils', () => {
|
|
|
105
107
|
value: 'Bravo'
|
|
106
108
|
});
|
|
107
109
|
});
|
|
108
|
-
it('should get an appropriate row for an editable text component', ()
|
|
109
|
-
|
|
110
|
+
it('should get an appropriate row for an editable text component', function () {
|
|
111
|
+
var PAGE = {
|
|
110
112
|
id: 'page',
|
|
111
113
|
formData: {
|
|
112
114
|
a: 'Bravo'
|
|
113
115
|
},
|
|
114
116
|
cya_link: {}
|
|
115
117
|
};
|
|
116
|
-
|
|
118
|
+
var COMPONENT = {
|
|
117
119
|
type: 'text',
|
|
118
120
|
id: 'a',
|
|
119
121
|
fieldId: 'a',
|
|
120
122
|
label: 'Alpha'
|
|
121
123
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
125
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
124
126
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
125
127
|
pageId: PAGE.id,
|
|
126
128
|
fieldId: COMPONENT.fieldId,
|
|
@@ -132,19 +134,18 @@ describe('utils', () => {
|
|
|
132
134
|
onAction: ON_ACTION
|
|
133
135
|
});
|
|
134
136
|
});
|
|
135
|
-
it('should update any nested components in radios with corresponding values from the stored formdata', ()
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
it('should update any nested components in radios with corresponding values from the stored formdata', function () {
|
|
138
|
+
var SELECTED_VALUE = 'selectedValue';
|
|
139
|
+
var NESTED_ID = 'nestedId';
|
|
140
|
+
var NESTED_VALUE = 'nestedValue';
|
|
141
|
+
var PAGE = {
|
|
140
142
|
id: 'page',
|
|
141
|
-
formData: {
|
|
142
|
-
a: SELECTED_VALUE
|
|
143
|
-
|
|
144
|
-
},
|
|
143
|
+
formData: _defineProperty({
|
|
144
|
+
a: SELECTED_VALUE
|
|
145
|
+
}, NESTED_ID, NESTED_VALUE),
|
|
145
146
|
cya_link: {}
|
|
146
147
|
};
|
|
147
|
-
|
|
148
|
+
var COMPONENT = {
|
|
148
149
|
type: 'radios',
|
|
149
150
|
id: 'a',
|
|
150
151
|
fieldId: 'a',
|
|
@@ -157,17 +158,17 @@ describe('utils', () => {
|
|
|
157
158
|
}]
|
|
158
159
|
}
|
|
159
160
|
};
|
|
160
|
-
|
|
161
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
|
|
161
162
|
expect(ROW.component.data.options[0].nested[0].value).toEqual(NESTED_VALUE);
|
|
162
163
|
});
|
|
163
|
-
it('should handle an undefined formData when attempting to set nested values in radios', ()
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
it('should handle an undefined formData when attempting to set nested values in radios', function () {
|
|
165
|
+
var SELECTED_VALUE = 'selectedValue';
|
|
166
|
+
var NESTED_ID = 'nestedId';
|
|
167
|
+
var PAGE = {
|
|
167
168
|
id: 'page',
|
|
168
169
|
cya_link: {}
|
|
169
170
|
};
|
|
170
|
-
|
|
171
|
+
var COMPONENT = {
|
|
171
172
|
type: 'radios',
|
|
172
173
|
id: 'a',
|
|
173
174
|
fieldId: 'a',
|
|
@@ -180,22 +181,21 @@ describe('utils', () => {
|
|
|
180
181
|
}]
|
|
181
182
|
}
|
|
182
183
|
};
|
|
183
|
-
|
|
184
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
|
|
184
185
|
expect(ROW.component.data.options[0].nested[0].value).toBeUndefined();
|
|
185
186
|
});
|
|
186
|
-
it('should update any nested components in checkboxes with corresponding values from the stored formdata', ()
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
it('should update any nested components in checkboxes with corresponding values from the stored formdata', function () {
|
|
188
|
+
var SELECTED_VALUE = 'selectedValue';
|
|
189
|
+
var NESTED_ID = 'nestedId';
|
|
190
|
+
var NESTED_VALUE = 'nestedValue';
|
|
191
|
+
var PAGE = {
|
|
191
192
|
id: 'page',
|
|
192
|
-
formData: {
|
|
193
|
-
a: [SELECTED_VALUE]
|
|
194
|
-
|
|
195
|
-
},
|
|
193
|
+
formData: _defineProperty({
|
|
194
|
+
a: [SELECTED_VALUE]
|
|
195
|
+
}, NESTED_ID, NESTED_VALUE),
|
|
196
196
|
cya_link: {}
|
|
197
197
|
};
|
|
198
|
-
|
|
198
|
+
var COMPONENT = {
|
|
199
199
|
type: 'checkboxes',
|
|
200
200
|
id: 'a',
|
|
201
201
|
fieldId: 'a',
|
|
@@ -208,17 +208,17 @@ describe('utils', () => {
|
|
|
208
208
|
}]
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
|
-
|
|
211
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
|
|
212
212
|
expect(ROW.component.data.options[0].nested[0].value).toEqual(NESTED_VALUE);
|
|
213
213
|
});
|
|
214
|
-
it('should handle an undefined formData when attempting to set nested values in checkboxes', ()
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
it('should handle an undefined formData when attempting to set nested values in checkboxes', function () {
|
|
215
|
+
var SELECTED_VALUE = 'selectedValue';
|
|
216
|
+
var NESTED_ID = 'nestedId';
|
|
217
|
+
var PAGE = {
|
|
218
218
|
id: 'page',
|
|
219
219
|
cya_link: {}
|
|
220
220
|
};
|
|
221
|
-
|
|
221
|
+
var COMPONENT = {
|
|
222
222
|
type: 'checkboxes',
|
|
223
223
|
id: 'a',
|
|
224
224
|
fieldId: 'a',
|
|
@@ -231,25 +231,25 @@ describe('utils', () => {
|
|
|
231
231
|
}]
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
-
|
|
234
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, function () {});
|
|
235
235
|
expect(ROW.component.data.options[0].nested[0].value).toBeUndefined();
|
|
236
236
|
});
|
|
237
|
-
it('should get an appropriate row for a readonly text component with no value and interpolated label', ()
|
|
238
|
-
|
|
237
|
+
it('should get an appropriate row for a readonly text component with no value and interpolated label', function () {
|
|
238
|
+
var PAGE = {
|
|
239
239
|
id: 'page',
|
|
240
240
|
formData: {
|
|
241
241
|
text: 'Smith'
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
244
|
// eslint-disable-next-line no-template-curly-in-string
|
|
245
|
-
|
|
245
|
+
var COMPONENT = {
|
|
246
246
|
type: 'text',
|
|
247
247
|
readonly: true,
|
|
248
248
|
id: 'a',
|
|
249
249
|
fieldId: 'a',
|
|
250
250
|
label: 'Alpha ${text}'
|
|
251
251
|
};
|
|
252
|
-
|
|
252
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
253
253
|
expect((0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION)).toEqual({
|
|
254
254
|
pageId: PAGE.id,
|
|
255
255
|
id: COMPONENT.id,
|
|
@@ -260,23 +260,23 @@ describe('utils', () => {
|
|
|
260
260
|
action: null
|
|
261
261
|
});
|
|
262
262
|
});
|
|
263
|
-
it('should use the interolated cya_label where there is no label', ()
|
|
264
|
-
|
|
263
|
+
it('should use the interolated cya_label where there is no label', function () {
|
|
264
|
+
var PAGE = {
|
|
265
265
|
id: 'page',
|
|
266
266
|
formData: {
|
|
267
267
|
a: 'Bravo'
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
270
|
// eslint-disable-next-line no-template-curly-in-string
|
|
271
|
-
|
|
271
|
+
var COMPONENT = {
|
|
272
272
|
type: 'text',
|
|
273
273
|
readonly: true,
|
|
274
274
|
id: 'a',
|
|
275
275
|
fieldId: 'a',
|
|
276
276
|
cya_label: 'CYA Alpha ${a}'
|
|
277
277
|
};
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
279
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
280
280
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
281
281
|
pageId: PAGE.id,
|
|
282
282
|
fieldId: COMPONENT.fieldId,
|
|
@@ -286,14 +286,14 @@ describe('utils', () => {
|
|
|
286
286
|
value: 'Bravo'
|
|
287
287
|
});
|
|
288
288
|
});
|
|
289
|
-
it('should use the cya_label where there is a label', ()
|
|
290
|
-
|
|
289
|
+
it('should use the cya_label where there is a label', function () {
|
|
290
|
+
var PAGE = {
|
|
291
291
|
id: 'page',
|
|
292
292
|
formData: {
|
|
293
293
|
a: 'Bravo'
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
|
-
|
|
296
|
+
var COMPONENT = {
|
|
297
297
|
type: 'text',
|
|
298
298
|
readonly: true,
|
|
299
299
|
id: 'a',
|
|
@@ -301,8 +301,8 @@ describe('utils', () => {
|
|
|
301
301
|
cya_label: 'CYA Alpha',
|
|
302
302
|
label: 'Alpha'
|
|
303
303
|
};
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
305
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
306
306
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
307
307
|
pageId: PAGE.id,
|
|
308
308
|
fieldId: COMPONENT.fieldId,
|
|
@@ -312,22 +312,22 @@ describe('utils', () => {
|
|
|
312
312
|
value: 'Bravo'
|
|
313
313
|
});
|
|
314
314
|
});
|
|
315
|
-
it('should use the label where there is no cya_label', ()
|
|
316
|
-
|
|
315
|
+
it('should use the label where there is no cya_label', function () {
|
|
316
|
+
var PAGE = {
|
|
317
317
|
id: 'page',
|
|
318
318
|
formData: {
|
|
319
319
|
a: 'Bravo'
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
|
-
|
|
322
|
+
var COMPONENT = {
|
|
323
323
|
type: 'text',
|
|
324
324
|
readonly: true,
|
|
325
325
|
id: 'a',
|
|
326
326
|
fieldId: 'a',
|
|
327
327
|
label: 'Alpha'
|
|
328
328
|
};
|
|
329
|
-
|
|
330
|
-
|
|
329
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
330
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
331
331
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
332
332
|
pageId: PAGE.id,
|
|
333
333
|
fieldId: COMPONENT.fieldId,
|
|
@@ -337,8 +337,8 @@ describe('utils', () => {
|
|
|
337
337
|
value: 'Bravo'
|
|
338
338
|
});
|
|
339
339
|
});
|
|
340
|
-
it('should not produce an action when the page is configured to have a single change link', ()
|
|
341
|
-
|
|
340
|
+
it('should not produce an action when the page is configured to have a single change link', function () {
|
|
341
|
+
var PAGE = {
|
|
342
342
|
id: 'page',
|
|
343
343
|
formData: {
|
|
344
344
|
a: 'Bravo'
|
|
@@ -349,15 +349,15 @@ describe('utils', () => {
|
|
|
349
349
|
singleChangeLink: true
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
|
-
|
|
352
|
+
var COMPONENT = {
|
|
353
353
|
type: 'text',
|
|
354
354
|
readonly: true,
|
|
355
355
|
id: 'a',
|
|
356
356
|
fieldId: 'a',
|
|
357
357
|
label: 'Alpha'
|
|
358
358
|
};
|
|
359
|
-
|
|
360
|
-
|
|
359
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
360
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
361
361
|
(0, _setupTests.expectObjectLike)(ROW, {
|
|
362
362
|
pageId: PAGE.id,
|
|
363
363
|
fieldId: COMPONENT.fieldId,
|