@ukhomeoffice/cop-react-form-renderer 6.7.0-alpha → 6.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +22 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +180 -92
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +137 -103
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +861 -463
- package/dist/components/CollectionPage/CollectionPage.js +63 -73
- package/dist/components/CollectionPage/CollectionPage.test.js +366 -316
- package/dist/components/CollectionSummary/BannerStrip.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.test.js +76 -80
- package/dist/components/CollectionSummary/CollectionSummary.js +126 -99
- package/dist/components/CollectionSummary/CollectionSummary.test.js +188 -152
- package/dist/components/CollectionSummary/Confirmation.js +12 -14
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/RenderListView.js +52 -46
- package/dist/components/CollectionSummary/RenderListView.scss +1 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +77 -78
- package/dist/components/CollectionSummary/SummaryCard.js +152 -110
- package/dist/components/CollectionSummary/SummaryCard.test.js +1018 -929
- package/dist/components/CollectionSummary/SummaryCardDetails.js +137 -94
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +13 -4
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +331 -128
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +35 -30
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +74 -62
- package/dist/components/FormComponent/Collection.js +108 -74
- package/dist/components/FormComponent/Collection.test.js +1081 -909
- package/dist/components/FormComponent/Container.js +39 -40
- package/dist/components/FormComponent/Container.test.js +412 -312
- package/dist/components/FormComponent/FormComponent.js +72 -69
- package/dist/components/FormComponent/FormComponent.test.js +414 -353
- package/dist/components/FormComponent/helpers/addLabel.js +7 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +5 -3
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +4 -3
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +80 -65
- package/dist/components/FormPage/FormPage.test.js +163 -127
- package/dist/components/FormRenderer/FormRenderer.js +180 -143
- package/dist/components/FormRenderer/FormRenderer.test.js +1115 -730
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +3 -1
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +15 -15
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +3 -1
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +20 -16
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -17
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +5 -3
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +24 -13
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +4 -2
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -7
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +97 -103
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +78 -71
- package/dist/components/FormRenderer/helpers/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +51 -59
- package/dist/components/FormRenderer/onCYAAction.test.js +152 -164
- package/dist/components/FormRenderer/onPageAction.js +39 -43
- package/dist/components/FormRenderer/onPageAction.test.js +208 -223
- package/dist/components/FormRenderer/onTaskAction.js +13 -9
- package/dist/components/FormRenderer/onTaskAction.test.js +88 -93
- package/dist/components/PageActions/ActionButton.js +15 -12
- package/dist/components/PageActions/ActionButton.test.js +78 -56
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +115 -86
- package/dist/components/SummaryList/GroupAction.js +17 -9
- package/dist/components/SummaryList/GroupAction.test.js +33 -37
- package/dist/components/SummaryList/RowAction.js +16 -11
- package/dist/components/SummaryList/RowAction.test.js +33 -37
- package/dist/components/SummaryList/SummaryList.js +34 -21
- package/dist/components/SummaryList/SummaryList.scss +15 -0
- package/dist/components/SummaryList/SummaryList.test.js +226 -143
- package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +53 -0
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.scss +38 -0
- package/dist/components/SummaryList/SummaryListRow.js +4 -6
- package/dist/components/SummaryList/SummaryListTitleRow.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +29 -19
- package/dist/components/TaskList/Task.test.js +76 -83
- package/dist/components/TaskList/TaskList.js +92 -49
- package/dist/components/TaskList/TaskList.scss +24 -0
- package/dist/components/TaskList/TaskList.test.js +255 -113
- package/dist/components/TaskList/TaskState.js +5 -7
- package/dist/components/TaskList/TaskState.test.js +45 -52
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +80 -57
- package/dist/context/HooksContext/HooksContext.test.js +35 -26
- package/dist/context/HooksContext/index.js +4 -3
- package/dist/context/ValidationContext/ValidationContext.js +94 -43
- package/dist/context/ValidationContext/ValidationContext.test.js +68 -56
- package/dist/context/ValidationContext/index.js +4 -3
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +10 -9
- package/dist/hooks/useAxios.js +40 -14
- package/dist/hooks/useGetRequest.js +97 -61
- package/dist/hooks/useHooks.js +3 -1
- package/dist/hooks/useRefData.js +39 -26
- package/dist/hooks/useValidation.js +3 -1
- package/dist/index.js +14 -13
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +38 -44
- package/dist/models/TaskStates.js +28 -29
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +31 -30
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +54 -52
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +25 -15
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +35 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +31 -17
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +44 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +24 -18
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +36 -33
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +61 -58
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +108 -87
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +281 -162
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +20 -25
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +97 -103
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +18 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +76 -70
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +42 -0
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +56 -0
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +22 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +38 -47
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +11 -7
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getErrorsForCollection.js +24 -24
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +22 -20
- package/dist/utils/CollectionPage/getQuickEditPage.js +31 -35
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +27 -15
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +43 -31
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +26 -26
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +16 -10
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
- package/dist/utils/Component/addShowWhen.js +8 -4
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +32 -27
- package/dist/utils/Component/cleanAttributes.js +13 -10
- package/dist/utils/Component/cleanAttributes.test.js +18 -17
- package/dist/utils/Component/elevateNestedComponents.js +7 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +68 -30
- package/dist/utils/Component/getComponent.js +94 -88
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +17 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +59 -46
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +48 -39
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -23
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +18 -20
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +25 -20
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +9 -10
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +8 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +26 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +175 -155
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +72 -57
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +38 -31
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +29 -20
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +8 -9
- package/dist/utils/Component/getDefaultValue.js +8 -6
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +21 -22
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +4 -2
- package/dist/utils/Component/isEditable.test.js +15 -14
- package/dist/utils/Component/optionIsSelected.js +6 -1
- package/dist/utils/Component/optionIsSelected.test.js +35 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +29 -27
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +8 -8
- package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
- package/dist/utils/Condition/meetsCondition.js +25 -16
- package/dist/utils/Condition/meetsCondition.test.js +402 -402
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +18 -13
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +5 -3
- package/dist/utils/Container/getEditableComponents.test.js +45 -43
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +20 -16
- package/dist/utils/Container/setupNesting.test.js +30 -27
- package/dist/utils/Container/showContainer.js +7 -3
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +48 -38
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +26 -18
- package/dist/utils/Data/getAutocompleteSource.test.js +86 -80
- package/dist/utils/Data/getDataPath.js +28 -18
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +30 -24
- package/dist/utils/Data/getOptions.test.js +27 -27
- package/dist/utils/Data/getSourceData.js +19 -6
- package/dist/utils/Data/getSourceData.test.js +80 -84
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/nestInRefdataOptions.js +16 -9
- package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
- package/dist/utils/Data/refDataToOptions.js +13 -10
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +8 -7
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +21 -13
- package/dist/utils/Data/setupFormData.test.js +50 -51
- package/dist/utils/Data/setupRefDataUrlForComponent.js +26 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +9 -5
- package/dist/utils/FormPage/applyConditionalProperties.test.js +18 -15
- package/dist/utils/FormPage/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- package/dist/utils/FormPage/getFormPage.js +16 -15
- package/dist/utils/FormPage/getFormPage.test.js +46 -47
- package/dist/utils/FormPage/getFormPages.js +12 -7
- package/dist/utils/FormPage/getFormPages.test.js +23 -20
- package/dist/utils/FormPage/getPageActions.js +15 -9
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getParagraphFromText.js +7 -5
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +4 -2
- package/dist/utils/FormPage/showFormPage.js +7 -3
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +28 -21
- package/dist/utils/FormPage/useComponent.test.js +79 -77
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +6 -5
- package/dist/utils/Format/formatDataForComponent.test.js +78 -50
- package/dist/utils/Format/formatDataForForm.js +8 -6
- package/dist/utils/Format/formatDataForForm.test.js +16 -13
- package/dist/utils/Format/formatDataForPage.js +5 -4
- package/dist/utils/Format/formatDataForPage.test.js +25 -20
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +31 -28
- package/dist/utils/Hub/index.js +1 -1
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +16 -24
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -14
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +34 -68
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +52 -46
- package/dist/utils/Operate/getLength.js +50 -0
- package/dist/utils/Operate/getLength.test.js +89 -0
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +20 -22
- package/dist/utils/Operate/runPageOperations.js +9 -7
- package/dist/utils/Operate/runPageOperations.test.js +36 -35
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +27 -21
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +6 -6
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +11 -7
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +41 -37
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +4 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +39 -35
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +16 -14
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +4 -3
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +26 -28
- package/dist/utils/Validate/additional/utils.js +22 -9
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +25 -19
- package/dist/utils/Validate/validateCollection.test.js +66 -74
- package/dist/utils/Validate/validateComponent.js +21 -18
- package/dist/utils/Validate/validateComponent.test.js +176 -166
- package/dist/utils/Validate/validateContainer.js +20 -15
- package/dist/utils/Validate/validateContainer.test.js +52 -58
- package/dist/utils/Validate/validateDate.js +21 -15
- package/dist/utils/Validate/validateDate.test.js +32 -31
- package/dist/utils/Validate/validateEmail.js +8 -6
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +7 -5
- package/dist/utils/Validate/validateMultifile.test.js +18 -17
- package/dist/utils/Validate/validatePage.js +22 -19
- package/dist/utils/Validate/validatePage.test.js +203 -215
- package/dist/utils/Validate/validateRegex.js +5 -3
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +6 -4
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +6 -4
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +26 -11
- package/dist/utils/Validate/validateTime.test.js +62 -16
- package/dist/utils/index.js +9 -7
- package/package.json +2 -2
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +0 -37
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +0 -41
|
@@ -6,107 +6,115 @@ var _handlers = _interopRequireDefault(require("./handlers"));
|
|
|
6
6
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
7
7
|
var _onPageAction = _interopRequireDefault(require("./onPageAction"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (typeof validator === 'function') {
|
|
35
|
-
validator();
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
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); }
|
|
15
|
+
jest.mock('./handlers', function () {
|
|
16
|
+
return {
|
|
17
|
+
navigateCalls: 0,
|
|
18
|
+
navigate: function navigate() {
|
|
19
|
+
this.navigateCalls += 1;
|
|
20
|
+
},
|
|
21
|
+
submissionErrorCalls: 0,
|
|
22
|
+
submissionErrorArgs: [],
|
|
23
|
+
submissionError: function submissionError(errors, addErrors) {
|
|
24
|
+
this.submissionErrorCalls += 1;
|
|
25
|
+
this.submissionErrorArgs.push(errors);
|
|
26
|
+
if (typeof addErrors === 'function') {
|
|
27
|
+
addErrors(errors);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
reset: function reset() {
|
|
31
|
+
this.navigateCalls = 0;
|
|
32
|
+
this.submissionErrorCalls = 0;
|
|
33
|
+
this.submissionErrorArgs = [];
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
cleanHiddenNestedData(patch) {
|
|
41
|
-
this.cleanHiddenNestedDataCalls += 1;
|
|
42
|
-
return patch;
|
|
43
|
-
},
|
|
44
|
-
getNextPageIdCalls: 0,
|
|
45
|
-
getNextPageId() {
|
|
46
|
-
this.getNextPageIdCalls += 1;
|
|
47
|
-
return 'page2';
|
|
48
|
-
},
|
|
49
|
-
getSubmissionStatusCalls: 0,
|
|
50
|
-
getSubmissionStatus() {
|
|
51
|
-
this.getSubmissionStatusCalls += 1;
|
|
52
|
-
return 'Good to go!';
|
|
53
|
-
},
|
|
54
|
-
reset() {
|
|
55
|
-
this.canActionProceedCalls = 0;
|
|
56
|
-
this.canActionProceedResult = true;
|
|
57
|
-
this.canCYASubmitResult = true;
|
|
58
|
-
this.cleanHiddenNestedDataCalls = 0;
|
|
59
|
-
this.getFormStateCalls = 0;
|
|
60
|
-
this.getSubmissionStatusCalls = 0;
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
63
|
-
jest.mock('../../utils', () => {
|
|
64
|
-
const originalModule = jest.requireActual('../../utils');
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
jest.mock('./helpers', function () {
|
|
65
38
|
return {
|
|
66
|
-
|
|
39
|
+
canActionProceedCalls: 0,
|
|
40
|
+
canActionProceedResult: true,
|
|
41
|
+
canActionProceed: function canActionProceed(action, page, validator) {
|
|
42
|
+
this.canActionProceedCalls += 1;
|
|
43
|
+
if (typeof validator === 'function') {
|
|
44
|
+
validator();
|
|
45
|
+
}
|
|
46
|
+
return this.canActionProceedResult;
|
|
47
|
+
},
|
|
48
|
+
cleanHiddenNestedDataCalls: 0,
|
|
49
|
+
cleanHiddenNestedData: function cleanHiddenNestedData(patch) {
|
|
50
|
+
this.cleanHiddenNestedDataCalls += 1;
|
|
51
|
+
return patch;
|
|
52
|
+
},
|
|
53
|
+
getNextPageIdCalls: 0,
|
|
54
|
+
getNextPageId: function getNextPageId() {
|
|
55
|
+
this.getNextPageIdCalls += 1;
|
|
56
|
+
return 'page2';
|
|
57
|
+
},
|
|
58
|
+
getSubmissionStatusCalls: 0,
|
|
59
|
+
getSubmissionStatus: function getSubmissionStatus() {
|
|
60
|
+
this.getSubmissionStatusCalls += 1;
|
|
61
|
+
return 'Good to go!';
|
|
62
|
+
},
|
|
63
|
+
reset: function reset() {
|
|
64
|
+
this.canActionProceedCalls = 0;
|
|
65
|
+
this.canActionProceedResult = true;
|
|
66
|
+
this.canCYASubmitResult = true;
|
|
67
|
+
this.cleanHiddenNestedDataCalls = 0;
|
|
68
|
+
this.getFormStateCalls = 0;
|
|
69
|
+
this.getSubmissionStatusCalls = 0;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
jest.mock('../../utils', function () {
|
|
74
|
+
var originalModule = jest.requireActual('../../utils');
|
|
75
|
+
return _objectSpread(_objectSpread({}, originalModule.default), {}, {
|
|
67
76
|
Format: {
|
|
68
77
|
formCalls: 0,
|
|
69
|
-
form(
|
|
78
|
+
form: function form(_form, data) {
|
|
70
79
|
this.formCalls += 1;
|
|
71
80
|
return data;
|
|
72
81
|
}
|
|
73
82
|
},
|
|
74
|
-
CollectionPage: {
|
|
75
|
-
...originalModule.default.CollectionPage,
|
|
83
|
+
CollectionPage: _objectSpread(_objectSpread({}, originalModule.default.CollectionPage), {}, {
|
|
76
84
|
duplicateActiveEntryCalls: 0,
|
|
77
85
|
duplicateActiveEntryResult: true,
|
|
78
|
-
duplicateActiveEntry() {
|
|
86
|
+
duplicateActiveEntry: function duplicateActiveEntry() {
|
|
79
87
|
this.duplicateActiveEntryCalls += 1;
|
|
80
88
|
return this.duplicateActiveEntryResult;
|
|
81
89
|
},
|
|
82
90
|
addEntryCalls: 0,
|
|
83
91
|
addEntryResult: true,
|
|
84
|
-
addEntry(collectionName, formData) {
|
|
92
|
+
addEntry: function addEntry(collectionName, formData) {
|
|
85
93
|
originalModule.default.CollectionPage.addEntry(collectionName, formData);
|
|
86
94
|
this.addEntryCalls += 1;
|
|
87
95
|
return this.addEntryResult;
|
|
88
96
|
}
|
|
89
|
-
},
|
|
90
|
-
reset() {
|
|
97
|
+
}),
|
|
98
|
+
reset: function reset() {
|
|
91
99
|
this.Format.formCalls = 0;
|
|
92
100
|
this.CollectionPage.duplicateActiveEntryCalls = 0;
|
|
93
101
|
this.duplicateActiveEntryResult = true;
|
|
94
102
|
this.CollectionPage.addEntryCalls = 0;
|
|
95
103
|
this.addEntryResult = true;
|
|
96
104
|
}
|
|
97
|
-
};
|
|
105
|
+
});
|
|
98
106
|
});
|
|
99
|
-
describe('components.FormRenderer.onPageAction', ()
|
|
100
|
-
|
|
107
|
+
describe('components.FormRenderer.onPageAction', function () {
|
|
108
|
+
var MOCK_HOOKS = {
|
|
101
109
|
onSubmitCalls: 0,
|
|
102
110
|
onSubmitArgs: [],
|
|
103
|
-
onSubmit(type, payload, onSuccess, onError, changedFieldName, changedFieldValue) {
|
|
111
|
+
onSubmit: function onSubmit(type, payload, onSuccess, onError, changedFieldName, changedFieldValue) {
|
|
104
112
|
this.onSubmitCalls += 1;
|
|
105
113
|
this.onSubmitArgs.push({
|
|
106
|
-
type,
|
|
107
|
-
payload,
|
|
108
|
-
changedFieldName,
|
|
109
|
-
changedFieldValue
|
|
114
|
+
type: type,
|
|
115
|
+
payload: payload,
|
|
116
|
+
changedFieldName: changedFieldName,
|
|
117
|
+
changedFieldValue: changedFieldValue
|
|
110
118
|
});
|
|
111
119
|
if (typeof onSuccess === 'function') {
|
|
112
120
|
onSuccess();
|
|
@@ -119,14 +127,14 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
119
127
|
}
|
|
120
128
|
},
|
|
121
129
|
onFormCompleteCalls: 0,
|
|
122
|
-
onFormComplete() {
|
|
130
|
+
onFormComplete: function onFormComplete() {
|
|
123
131
|
this.onFormCompleteCalls += 1;
|
|
124
132
|
},
|
|
125
133
|
onCancelArgs: [],
|
|
126
|
-
onCancel(data) {
|
|
134
|
+
onCancel: function onCancel(data) {
|
|
127
135
|
this.onCancelArgs.push(data);
|
|
128
136
|
},
|
|
129
|
-
reset() {
|
|
137
|
+
reset: function reset() {
|
|
130
138
|
this.onSubmitCalls = 0;
|
|
131
139
|
this.onSubmitArgs = [];
|
|
132
140
|
this.onFormCompleteCalls = 0;
|
|
@@ -134,54 +142,54 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
134
142
|
this.onActionCalls = 0;
|
|
135
143
|
},
|
|
136
144
|
onActionCalls: 0,
|
|
137
|
-
onAction(formData, patch) {
|
|
145
|
+
onAction: function onAction(formData, patch) {
|
|
138
146
|
this.onActionCalls += 1;
|
|
139
147
|
return {
|
|
140
|
-
formData,
|
|
141
|
-
patch
|
|
148
|
+
formData: formData,
|
|
149
|
+
patch: patch
|
|
142
150
|
};
|
|
143
151
|
}
|
|
144
152
|
};
|
|
145
|
-
|
|
153
|
+
var MOCK_VALIDATE = {
|
|
146
154
|
pageCalls: 0,
|
|
147
|
-
page() {
|
|
155
|
+
page: function page() {
|
|
148
156
|
MOCK_VALIDATE.pageCalls += 1;
|
|
149
157
|
},
|
|
150
|
-
reset() {
|
|
158
|
+
reset: function reset() {
|
|
151
159
|
this.pageCalls = 0;
|
|
152
160
|
}
|
|
153
161
|
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
var setPagePointCalls = 0;
|
|
163
|
+
var setPagePointArgs = [];
|
|
164
|
+
var mockSetPagePoint = function mockSetPagePoint(point) {
|
|
157
165
|
setPagePointCalls += 1;
|
|
158
166
|
setPagePointArgs.push(point);
|
|
159
167
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
168
|
+
var setDataCalls = 0;
|
|
169
|
+
var setDataArgs = [];
|
|
170
|
+
var mockSetData = function mockSetData(data) {
|
|
163
171
|
setDataCalls += 1;
|
|
164
172
|
setDataArgs.push(data);
|
|
165
173
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
174
|
+
var onPageChangeCalls = 0;
|
|
175
|
+
var onPageChangeArgs = [];
|
|
176
|
+
var mockOnPageChange = function mockOnPageChange(pageId) {
|
|
169
177
|
onPageChangeCalls += 1;
|
|
170
178
|
onPageChangeArgs.push(pageId);
|
|
171
179
|
};
|
|
172
|
-
|
|
173
|
-
|
|
180
|
+
var addErrorsArgs = [];
|
|
181
|
+
var mockAddErrors = function mockAddErrors(errors) {
|
|
174
182
|
addErrorsArgs.push(errors);
|
|
175
183
|
};
|
|
176
|
-
|
|
177
|
-
|
|
184
|
+
var setSubmittedArgs = [];
|
|
185
|
+
var mockSetSubmitted = function mockSetSubmitted(newSubmitted) {
|
|
178
186
|
setSubmittedArgs.push(newSubmitted);
|
|
179
187
|
};
|
|
180
|
-
|
|
181
|
-
|
|
188
|
+
var mockSubmitting = false;
|
|
189
|
+
var mockSetSubmitting = function mockSetSubmitting(submitting) {
|
|
182
190
|
mockSubmitting = submitting;
|
|
183
191
|
};
|
|
184
|
-
|
|
192
|
+
var COMPONENTS = [{
|
|
185
193
|
id: 'alpha',
|
|
186
194
|
fieldId: 'alpha'
|
|
187
195
|
}, {
|
|
@@ -194,26 +202,18 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
194
202
|
id: 'delta',
|
|
195
203
|
fieldId: 'delta'
|
|
196
204
|
}];
|
|
197
|
-
|
|
205
|
+
var PAGES = [{
|
|
198
206
|
id: 'page1',
|
|
199
|
-
components: [{
|
|
200
|
-
...COMPONENTS[0]
|
|
201
|
-
}, {
|
|
202
|
-
...COMPONENTS[1]
|
|
203
|
-
}]
|
|
207
|
+
components: [_objectSpread({}, COMPONENTS[0]), _objectSpread({}, COMPONENTS[1])]
|
|
204
208
|
}, {
|
|
205
209
|
id: 'page2',
|
|
206
|
-
components: [{
|
|
207
|
-
...COMPONENTS[2]
|
|
208
|
-
}, {
|
|
209
|
-
...COMPONENTS[3]
|
|
210
|
-
}]
|
|
210
|
+
components: [_objectSpread({}, COMPONENTS[2]), _objectSpread({}, COMPONENTS[3])]
|
|
211
211
|
}];
|
|
212
|
-
|
|
212
|
+
var CURRENT_TASK = {
|
|
213
213
|
name: 'testTask',
|
|
214
214
|
fullPages: PAGES
|
|
215
215
|
};
|
|
216
|
-
|
|
216
|
+
var ARGS = {
|
|
217
217
|
action: {
|
|
218
218
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
219
219
|
},
|
|
@@ -241,7 +241,7 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
241
241
|
submitting: mockSubmitting,
|
|
242
242
|
setSubmitting: mockSetSubmitting
|
|
243
243
|
};
|
|
244
|
-
beforeEach(()
|
|
244
|
+
beforeEach(function () {
|
|
245
245
|
_handlers.default.reset();
|
|
246
246
|
_helpers.default.reset();
|
|
247
247
|
_utils.default.reset();
|
|
@@ -257,12 +257,12 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
257
257
|
setSubmittedArgs = [];
|
|
258
258
|
mockSetSubmitting(false);
|
|
259
259
|
});
|
|
260
|
-
|
|
260
|
+
var preActionChecks = function preActionChecks() {
|
|
261
261
|
expect(_helpers.default.canActionProceedCalls).toEqual(1);
|
|
262
262
|
expect(MOCK_VALIDATE.pageCalls).toEqual(1);
|
|
263
263
|
expect(_helpers.default.cleanHiddenNestedDataCalls).toEqual(1);
|
|
264
264
|
};
|
|
265
|
-
|
|
265
|
+
var postActionChecks = function postActionChecks(argsUsed) {
|
|
266
266
|
expect(_utils.default.Format.formCalls).toEqual(1);
|
|
267
267
|
expect(_helpers.default.getSubmissionStatusCalls).toEqual(1);
|
|
268
268
|
// setData is always called once in the error callback
|
|
@@ -270,12 +270,8 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
270
270
|
// to this if patch is valid.
|
|
271
271
|
if (argsUsed.patch) {
|
|
272
272
|
expect(setDataCalls).toEqual(2);
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
...argsUsed.patch,
|
|
276
|
-
...argsUsed.formState.page.formData
|
|
277
|
-
};
|
|
278
|
-
const submissionData = _utils.default.Format.form(null, dataUsed, null);
|
|
273
|
+
var dataUsed = _objectSpread(_objectSpread(_objectSpread({}, argsUsed.data), argsUsed.patch), argsUsed.formState.page.formData);
|
|
274
|
+
var submissionData = _utils.default.Format.form(null, dataUsed, null);
|
|
279
275
|
submissionData.formStatus = _helpers.default.getSubmissionStatus();
|
|
280
276
|
expect(setDataArgs[0]).toEqual(submissionData);
|
|
281
277
|
} else {
|
|
@@ -283,7 +279,7 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
283
279
|
}
|
|
284
280
|
expect(MOCK_HOOKS.onSubmitCalls).toEqual(1);
|
|
285
281
|
if (argsUsed.type === _models.FormTypes.HUB && Object.keys(argsUsed.patchLabel).length > 0) {
|
|
286
|
-
|
|
282
|
+
var firstKey = Object.keys(argsUsed.patchLabel)[0];
|
|
287
283
|
expect(MOCK_HOOKS.onSubmitArgs[0]).toMatchObject({
|
|
288
284
|
changedFieldName: firstKey,
|
|
289
285
|
changedFieldValue: argsUsed.patchLabel[firstKey]
|
|
@@ -301,14 +297,14 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
301
297
|
expect(_handlers.default.submissionErrorCalls).toEqual(1);
|
|
302
298
|
expect(setDataArgs[setDataCalls - 1]).toEqual(argsUsed.data); // Data is reset in the case of an error.
|
|
303
299
|
};
|
|
304
|
-
|
|
305
|
-
|
|
300
|
+
|
|
301
|
+
it("should handle the ".concat(_models.PageAction.TYPES.CANCEL, " Page Action type"), function () {
|
|
302
|
+
var ACTION = {
|
|
306
303
|
type: _models.PageAction.TYPES.CANCEL
|
|
307
304
|
};
|
|
308
|
-
|
|
309
|
-
...ARGS,
|
|
305
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
310
306
|
action: ACTION
|
|
311
|
-
};
|
|
307
|
+
});
|
|
312
308
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
313
309
|
expect(MOCK_HOOKS.onCancelArgs.length).toEqual(1);
|
|
314
310
|
expect(MOCK_HOOKS.onCancelArgs[0]).toMatchObject({});
|
|
@@ -317,14 +313,13 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
317
313
|
expect(_helpers.default.canActionProceedCalls).toEqual(0);
|
|
318
314
|
expect(MOCK_VALIDATE.pageCalls).toEqual(0);
|
|
319
315
|
});
|
|
320
|
-
it("should handle the ".concat(_models.PageAction.TYPES.NAVIGATE, " Page Action type"), ()
|
|
321
|
-
|
|
316
|
+
it("should handle the ".concat(_models.PageAction.TYPES.NAVIGATE, " Page Action type"), function () {
|
|
317
|
+
var ACTION = {
|
|
322
318
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
323
319
|
};
|
|
324
|
-
|
|
325
|
-
...ARGS,
|
|
320
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
326
321
|
action: ACTION
|
|
327
|
-
};
|
|
322
|
+
});
|
|
328
323
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
329
324
|
preActionChecks();
|
|
330
325
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
@@ -333,28 +328,27 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
333
328
|
// as a navigate action should stop at calling
|
|
334
329
|
// hooks.navigate.
|
|
335
330
|
});
|
|
336
|
-
|
|
337
|
-
|
|
331
|
+
|
|
332
|
+
it("should handle the ".concat(_models.PageAction.TYPES.SUBMIT, " Page Action type"), function () {
|
|
333
|
+
var ACTION = {
|
|
338
334
|
type: _models.PageAction.TYPES.SUBMIT
|
|
339
335
|
};
|
|
340
|
-
|
|
341
|
-
...ARGS,
|
|
336
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
342
337
|
action: ACTION
|
|
343
|
-
};
|
|
338
|
+
});
|
|
344
339
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
345
340
|
preActionChecks();
|
|
346
341
|
expect(setPagePointCalls).toEqual(1);
|
|
347
342
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
348
343
|
postActionChecks(CUSTOM_ARGS);
|
|
349
344
|
});
|
|
350
|
-
it("should handle the ".concat(_models.PageAction.TYPES.SAVE_AND_NAVIGATE, " Page Action type"), ()
|
|
351
|
-
|
|
345
|
+
it("should handle the ".concat(_models.PageAction.TYPES.SAVE_AND_NAVIGATE, " Page Action type"), function () {
|
|
346
|
+
var ACTION = {
|
|
352
347
|
type: _models.PageAction.TYPES.SAVE_AND_NAVIGATE
|
|
353
348
|
};
|
|
354
|
-
|
|
355
|
-
...ARGS,
|
|
349
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
356
350
|
action: ACTION
|
|
357
|
-
};
|
|
351
|
+
});
|
|
358
352
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
359
353
|
preActionChecks();
|
|
360
354
|
// All the actions does in this case is set a function
|
|
@@ -362,23 +356,22 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
362
356
|
postActionChecks(CUSTOM_ARGS);
|
|
363
357
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
364
358
|
});
|
|
365
|
-
it("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_ADD, " Page Action type"), ()
|
|
366
|
-
|
|
359
|
+
it("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_ADD, " Page Action type"), function () {
|
|
360
|
+
var FORM_STATE = {
|
|
367
361
|
page: {
|
|
368
362
|
formData: {
|
|
369
363
|
'testCollection': []
|
|
370
364
|
}
|
|
371
365
|
}
|
|
372
366
|
};
|
|
373
|
-
|
|
367
|
+
var ACTION = {
|
|
374
368
|
type: _models.PageAction.TYPES.COLLECTION_ADD,
|
|
375
369
|
collection: 'testCollection'
|
|
376
370
|
};
|
|
377
|
-
|
|
378
|
-
...ARGS,
|
|
371
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
379
372
|
action: ACTION,
|
|
380
373
|
formState: FORM_STATE
|
|
381
|
-
};
|
|
374
|
+
});
|
|
382
375
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
383
376
|
preActionChecks();
|
|
384
377
|
expect(FORM_STATE.page.formData["".concat(ACTION.collection, "ActiveId")]).toBeDefined();
|
|
@@ -388,24 +381,23 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
388
381
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
389
382
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
390
383
|
});
|
|
391
|
-
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_DUPLICATE, " Page Action type"), ()
|
|
392
|
-
it("calling handlers.navigate if the duplication was successful", ()
|
|
393
|
-
|
|
384
|
+
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_DUPLICATE, " Page Action type"), function () {
|
|
385
|
+
it("calling handlers.navigate if the duplication was successful", function () {
|
|
386
|
+
var FORM_STATE = {
|
|
394
387
|
page: {
|
|
395
388
|
formData: {
|
|
396
389
|
'testCollection': []
|
|
397
390
|
}
|
|
398
391
|
}
|
|
399
392
|
};
|
|
400
|
-
|
|
393
|
+
var ACTION = {
|
|
401
394
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
402
395
|
collection: 'testCollection'
|
|
403
396
|
};
|
|
404
|
-
|
|
405
|
-
...ARGS,
|
|
397
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
406
398
|
action: ACTION,
|
|
407
399
|
formState: FORM_STATE
|
|
408
|
-
};
|
|
400
|
+
});
|
|
409
401
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
410
402
|
preActionChecks();
|
|
411
403
|
expect(_utils.default.CollectionPage.duplicateActiveEntryCalls).toEqual(1);
|
|
@@ -415,23 +407,22 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
415
407
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
416
408
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
417
409
|
});
|
|
418
|
-
it("calling onPageChange if the duplication was unsuccessful", ()
|
|
419
|
-
|
|
410
|
+
it("calling onPageChange if the duplication was unsuccessful", function () {
|
|
411
|
+
var FORM_STATE = {
|
|
420
412
|
page: {
|
|
421
413
|
formData: {
|
|
422
414
|
'testCollection': []
|
|
423
415
|
}
|
|
424
416
|
}
|
|
425
417
|
};
|
|
426
|
-
|
|
418
|
+
var ACTION = {
|
|
427
419
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
428
420
|
collection: 'testCollection'
|
|
429
421
|
};
|
|
430
|
-
|
|
431
|
-
...ARGS,
|
|
422
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
432
423
|
action: ACTION,
|
|
433
424
|
formState: FORM_STATE
|
|
434
|
-
};
|
|
425
|
+
});
|
|
435
426
|
_utils.default.CollectionPage.duplicateActiveEntryResult = false;
|
|
436
427
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
437
428
|
preActionChecks();
|
|
@@ -445,9 +436,9 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
445
436
|
expect(onPageChangeCalls).toEqual(1);
|
|
446
437
|
});
|
|
447
438
|
});
|
|
448
|
-
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_REMOVE, " Page Action type"), ()
|
|
449
|
-
it("should store a reference to the removed item if action.recordRemoval is true", ()
|
|
450
|
-
|
|
439
|
+
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_REMOVE, " Page Action type"), function () {
|
|
440
|
+
it("should store a reference to the removed item if action.recordRemoval is true", function () {
|
|
441
|
+
var FORM_STATE = {
|
|
451
442
|
page: {
|
|
452
443
|
formData: {
|
|
453
444
|
testCollectionActiveId: 'removeMe',
|
|
@@ -459,16 +450,15 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
459
450
|
}
|
|
460
451
|
}
|
|
461
452
|
};
|
|
462
|
-
|
|
453
|
+
var ACTION = {
|
|
463
454
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
464
455
|
collection: 'testCollection',
|
|
465
456
|
recordRemoval: true
|
|
466
457
|
};
|
|
467
|
-
|
|
468
|
-
...ARGS,
|
|
458
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
469
459
|
action: ACTION,
|
|
470
460
|
formState: FORM_STATE
|
|
471
|
-
};
|
|
461
|
+
});
|
|
472
462
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
473
463
|
preActionChecks();
|
|
474
464
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -482,8 +472,8 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
482
472
|
// This action type uses the default onPageChange.
|
|
483
473
|
expect(onPageChangeCalls).toEqual(1);
|
|
484
474
|
});
|
|
485
|
-
it("should not store a reference to the removed item if action.recordRemoval is false", ()
|
|
486
|
-
|
|
475
|
+
it("should not store a reference to the removed item if action.recordRemoval is false", function () {
|
|
476
|
+
var FORM_STATE = {
|
|
487
477
|
page: {
|
|
488
478
|
formData: {
|
|
489
479
|
testCollectionActiveId: 'removeMe',
|
|
@@ -495,16 +485,15 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
495
485
|
}
|
|
496
486
|
}
|
|
497
487
|
};
|
|
498
|
-
|
|
488
|
+
var ACTION = {
|
|
499
489
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
500
490
|
collection: 'testCollection',
|
|
501
491
|
recordRemoval: false
|
|
502
492
|
};
|
|
503
|
-
|
|
504
|
-
...ARGS,
|
|
493
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
505
494
|
action: ACTION,
|
|
506
495
|
formState: FORM_STATE
|
|
507
|
-
};
|
|
496
|
+
});
|
|
508
497
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
509
498
|
preActionChecks();
|
|
510
499
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -516,8 +505,8 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
516
505
|
// This action type uses the default onPageChange.
|
|
517
506
|
expect(onPageChangeCalls).toEqual(1);
|
|
518
507
|
});
|
|
519
|
-
it("should not store a reference to the removed item if action.recordRemoval is not defined", ()
|
|
520
|
-
|
|
508
|
+
it("should not store a reference to the removed item if action.recordRemoval is not defined", function () {
|
|
509
|
+
var FORM_STATE = {
|
|
521
510
|
page: {
|
|
522
511
|
formData: {
|
|
523
512
|
testCollectionActiveId: 'removeMe',
|
|
@@ -529,15 +518,14 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
529
518
|
}
|
|
530
519
|
}
|
|
531
520
|
};
|
|
532
|
-
|
|
521
|
+
var ACTION = {
|
|
533
522
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
534
523
|
collection: 'testCollection'
|
|
535
524
|
};
|
|
536
|
-
|
|
537
|
-
...ARGS,
|
|
525
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
538
526
|
action: ACTION,
|
|
539
527
|
formState: FORM_STATE
|
|
540
|
-
};
|
|
528
|
+
});
|
|
541
529
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
542
530
|
preActionChecks();
|
|
543
531
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -550,17 +538,18 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
550
538
|
expect(onPageChangeCalls).toEqual(1);
|
|
551
539
|
});
|
|
552
540
|
});
|
|
553
|
-
describe('if validation fails', ()
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
541
|
+
describe('if validation fails', function () {
|
|
542
|
+
var VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(function (a) {
|
|
543
|
+
return a !== _models.PageAction.TYPES.CANCEL;
|
|
544
|
+
});
|
|
545
|
+
VALID_ACTIONS.forEach(function (actionType) {
|
|
546
|
+
it("should not continue for the ".concat(actionType, " action type"), function () {
|
|
547
|
+
var ACTION = {
|
|
558
548
|
type: actionType
|
|
559
549
|
};
|
|
560
|
-
|
|
561
|
-
...ARGS,
|
|
550
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
562
551
|
action: ACTION
|
|
563
|
-
};
|
|
552
|
+
});
|
|
564
553
|
_helpers.default.canActionProceedResult = false;
|
|
565
554
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
566
555
|
expect(_helpers.default.canActionProceedCalls).toEqual(1);
|
|
@@ -571,18 +560,20 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
571
560
|
});
|
|
572
561
|
});
|
|
573
562
|
});
|
|
574
|
-
describe('adding a field to formData if specified on the action', ()
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
563
|
+
describe('adding a field to formData if specified on the action', function () {
|
|
564
|
+
var VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(function (a) {
|
|
565
|
+
return a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE;
|
|
566
|
+
});
|
|
567
|
+
VALID_ACTIONS.forEach(function (actionType) {
|
|
568
|
+
it("should work for the ".concat(actionType, " action type"), function () {
|
|
569
|
+
var FORM_STATE = {
|
|
579
570
|
page: {
|
|
580
571
|
formData: {
|
|
581
572
|
testCollection: []
|
|
582
573
|
}
|
|
583
574
|
}
|
|
584
575
|
};
|
|
585
|
-
|
|
576
|
+
var ACTION = {
|
|
586
577
|
type: actionType,
|
|
587
578
|
collection: 'testCollection',
|
|
588
579
|
addToFormData: [{
|
|
@@ -596,11 +587,10 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
596
587
|
isCollection: true
|
|
597
588
|
}]
|
|
598
589
|
};
|
|
599
|
-
|
|
600
|
-
...ARGS,
|
|
590
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
601
591
|
formState: FORM_STATE,
|
|
602
592
|
action: ACTION
|
|
603
|
-
};
|
|
593
|
+
});
|
|
604
594
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
605
595
|
preActionChecks();
|
|
606
596
|
postActionChecks(CUSTOM_ARGS);
|
|
@@ -610,15 +600,15 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
610
600
|
expect(FORM_STATE.page.formData.parent[0].child[0].id).toEqual('12345');
|
|
611
601
|
});
|
|
612
602
|
});
|
|
613
|
-
it("should work for the ".concat(_models.PageAction.TYPES.NAVIGATE, " action type"), ()
|
|
614
|
-
|
|
603
|
+
it("should work for the ".concat(_models.PageAction.TYPES.NAVIGATE, " action type"), function () {
|
|
604
|
+
var FORM_STATE = {
|
|
615
605
|
page: {
|
|
616
606
|
formData: {
|
|
617
607
|
testCollection: []
|
|
618
608
|
}
|
|
619
609
|
}
|
|
620
610
|
};
|
|
621
|
-
|
|
611
|
+
var ACTION = {
|
|
622
612
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
623
613
|
collection: 'testCollection',
|
|
624
614
|
addToFormData: [{
|
|
@@ -632,11 +622,10 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
632
622
|
isCollection: true
|
|
633
623
|
}]
|
|
634
624
|
};
|
|
635
|
-
|
|
636
|
-
...ARGS,
|
|
625
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
637
626
|
formState: FORM_STATE,
|
|
638
627
|
action: ACTION
|
|
639
|
-
};
|
|
628
|
+
});
|
|
640
629
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
641
630
|
preActionChecks();
|
|
642
631
|
// Not doing the usual post-action checks here
|
|
@@ -647,15 +636,15 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
647
636
|
});
|
|
648
637
|
expect(FORM_STATE.page.formData.parent[0].child[0].id).toEqual('12345');
|
|
649
638
|
});
|
|
650
|
-
it('should work for an array of formData', ()
|
|
651
|
-
|
|
639
|
+
it('should work for an array of formData', function () {
|
|
640
|
+
var FORM_STATE = {
|
|
652
641
|
page: {
|
|
653
642
|
formData: {
|
|
654
643
|
testCollection: []
|
|
655
644
|
}
|
|
656
645
|
}
|
|
657
646
|
};
|
|
658
|
-
|
|
647
|
+
var ACTION = {
|
|
659
648
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
660
649
|
collection: 'testCollection',
|
|
661
650
|
addToFormData: [{
|
|
@@ -666,11 +655,10 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
666
655
|
value: '456'
|
|
667
656
|
}]
|
|
668
657
|
};
|
|
669
|
-
|
|
670
|
-
...ARGS,
|
|
658
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
671
659
|
formState: FORM_STATE,
|
|
672
660
|
action: ACTION
|
|
673
|
-
};
|
|
661
|
+
});
|
|
674
662
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
675
663
|
preActionChecks();
|
|
676
664
|
// Not doing the usual post-action checks here
|
|
@@ -684,37 +672,34 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
684
672
|
});
|
|
685
673
|
});
|
|
686
674
|
});
|
|
687
|
-
describe('recording patchLabel fields correctly when it is defined', ()
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
675
|
+
describe('recording patchLabel fields correctly when it is defined', function () {
|
|
676
|
+
var VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(function (a) {
|
|
677
|
+
return a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE;
|
|
678
|
+
});
|
|
679
|
+
VALID_ACTIONS.forEach(function (actionType) {
|
|
680
|
+
it("should work for the ".concat(actionType, " action type"), function () {
|
|
681
|
+
var FORM_STATE = {
|
|
692
682
|
page: {
|
|
693
683
|
formData: {
|
|
694
684
|
testCollection: []
|
|
695
685
|
}
|
|
696
686
|
}
|
|
697
687
|
};
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
const PATCH = {
|
|
704
|
-
[KEY]: VALUE
|
|
705
|
-
};
|
|
706
|
-
const ACTION = {
|
|
688
|
+
var KEY = 'testField';
|
|
689
|
+
var VALUE = 'testValue';
|
|
690
|
+
var PATCH_LABEL = _defineProperty({}, KEY, VALUE);
|
|
691
|
+
var PATCH = _defineProperty({}, KEY, VALUE);
|
|
692
|
+
var ACTION = {
|
|
707
693
|
type: actionType,
|
|
708
694
|
collection: 'testCollection'
|
|
709
695
|
};
|
|
710
|
-
|
|
711
|
-
...ARGS,
|
|
696
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
712
697
|
action: ACTION,
|
|
713
698
|
formState: FORM_STATE,
|
|
714
699
|
patch: PATCH,
|
|
715
700
|
patchLabel: PATCH_LABEL,
|
|
716
701
|
type: _models.FormTypes.HUB
|
|
717
|
-
};
|
|
702
|
+
});
|
|
718
703
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
719
704
|
preActionChecks();
|
|
720
705
|
postActionChecks(CUSTOM_ARGS); // Specific check for patchLabel done in here.
|