@ukhomeoffice/cop-react-form-renderer 5.45.2-alpha → 5.48.1-bravo
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +12 -12
- package/dist/components/CheckYourAnswers/Answer.test.js +127 -92
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +131 -101
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +769 -464
- package/dist/components/CollectionPage/CollectionPage.js +58 -66
- package/dist/components/CollectionPage/CollectionPage.test.js +342 -300
- package/dist/components/CollectionSummary/BannerStrip.js +12 -12
- package/dist/components/CollectionSummary/BannerStrip.test.js +59 -63
- package/dist/components/CollectionSummary/CollectionSummary.js +88 -61
- package/dist/components/CollectionSummary/CollectionSummary.test.js +96 -102
- package/dist/components/CollectionSummary/Confirmation.js +12 -14
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/SummaryCard.js +148 -109
- package/dist/components/CollectionSummary/SummaryCard.scss +1 -1
- package/dist/components/CollectionSummary/SummaryCard.test.js +927 -905
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +29 -23
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +73 -61
- package/dist/components/FormComponent/Collection.js +107 -73
- package/dist/components/FormComponent/Collection.test.js +945 -809
- package/dist/components/FormComponent/Container.js +38 -40
- package/dist/components/FormComponent/Container.test.js +345 -314
- package/dist/components/FormComponent/FormComponent.js +70 -67
- package/dist/components/FormComponent/FormComponent.test.js +342 -284
- package/dist/components/FormComponent/helpers/addLabel.js +7 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +5 -3
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +4 -3
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +80 -65
- package/dist/components/FormPage/FormPage.test.js +163 -127
- package/dist/components/FormRenderer/FormRenderer.js +181 -144
- package/dist/components/FormRenderer/FormRenderer.test.js +1115 -730
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +3 -1
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +5 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +47 -11
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +3 -1
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +20 -16
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -17
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +5 -3
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +24 -13
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +4 -2
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -7
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +91 -97
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +73 -71
- package/dist/components/FormRenderer/helpers/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +51 -59
- package/dist/components/FormRenderer/onCYAAction.test.js +152 -164
- package/dist/components/FormRenderer/onPageAction.js +40 -44
- package/dist/components/FormRenderer/onPageAction.test.js +206 -223
- package/dist/components/FormRenderer/onTaskAction.js +13 -9
- package/dist/components/FormRenderer/onTaskAction.test.js +88 -93
- package/dist/components/PageActions/ActionButton.js +15 -12
- package/dist/components/PageActions/ActionButton.test.js +78 -56
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +115 -86
- package/dist/components/SummaryList/GroupAction.js +17 -9
- package/dist/components/SummaryList/GroupAction.test.js +33 -37
- package/dist/components/SummaryList/RowAction.js +16 -11
- package/dist/components/SummaryList/RowAction.test.js +33 -37
- package/dist/components/SummaryList/SummaryList.js +26 -21
- package/dist/components/SummaryList/SummaryList.test.js +166 -143
- package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
- package/dist/components/SummaryList/SummaryListRow.js +4 -6
- package/dist/components/SummaryList/SummaryListTitleRow.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +29 -19
- package/dist/components/TaskList/Task.test.js +76 -83
- package/dist/components/TaskList/TaskList.js +71 -45
- package/dist/components/TaskList/TaskList.test.js +111 -113
- package/dist/components/TaskList/TaskState.js +5 -7
- package/dist/components/TaskList/TaskState.test.js +45 -52
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +79 -58
- package/dist/context/HooksContext/HooksContext.test.js +35 -26
- package/dist/context/HooksContext/index.js +4 -3
- package/dist/context/ValidationContext/ValidationContext.js +72 -32
- package/dist/context/ValidationContext/ValidationContext.test.js +59 -47
- package/dist/context/ValidationContext/index.js +4 -3
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +10 -9
- package/dist/hooks/useAxios.js +40 -14
- package/dist/hooks/useGetRequest.js +97 -61
- package/dist/hooks/useHooks.js +3 -1
- package/dist/hooks/useRefData.js +39 -26
- package/dist/hooks/useValidation.js +3 -1
- package/dist/index.js +14 -13
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +38 -44
- package/dist/models/TaskStates.js +28 -30
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +31 -30
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +54 -52
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +25 -15
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +35 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +31 -17
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +44 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +24 -18
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +36 -33
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +60 -58
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +88 -79
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +124 -146
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +20 -25
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +97 -103
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +18 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +76 -70
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +24 -24
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +1 -1
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +18 -9
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +22 -27
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +11 -7
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.js +19 -19
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +16 -12
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +30 -29
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +17 -17
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +17 -17
- package/dist/utils/Component/addShowWhen.js +8 -4
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +32 -27
- package/dist/utils/Component/cleanAttributes.js +13 -10
- package/dist/utils/Component/cleanAttributes.test.js +18 -17
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +95 -88
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +17 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +59 -46
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +48 -39
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -23
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +18 -20
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +25 -20
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +9 -10
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +8 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +26 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +175 -155
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +70 -57
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +38 -31
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +29 -20
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +8 -9
- package/dist/utils/Component/getDefaultValue.js +8 -6
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +22 -23
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +4 -2
- package/dist/utils/Component/isEditable.test.js +15 -14
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +29 -27
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +7 -7
- package/dist/utils/Condition/meetsAllConditions.test.js +17 -17
- package/dist/utils/Condition/meetsCondition.js +17 -14
- package/dist/utils/Condition/meetsCondition.test.js +376 -376
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +18 -13
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +5 -3
- package/dist/utils/Container/getEditableComponents.test.js +45 -43
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +20 -16
- package/dist/utils/Container/setupNesting.test.js +30 -27
- package/dist/utils/Container/showContainer.js +7 -3
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +48 -38
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +26 -18
- package/dist/utils/Data/getAutocompleteSource.test.js +86 -80
- package/dist/utils/Data/getDataPath.js +28 -18
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +25 -19
- package/dist/utils/Data/getOptions.test.js +20 -20
- package/dist/utils/Data/getSourceData.js +19 -6
- package/dist/utils/Data/getSourceData.test.js +80 -84
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/refDataToOptions.js +13 -10
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +8 -7
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +21 -13
- package/dist/utils/Data/setupFormData.test.js +50 -51
- package/dist/utils/Data/setupRefDataUrlForComponent.js +26 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +9 -5
- package/dist/utils/FormPage/applyConditionalProperties.test.js +18 -15
- package/dist/utils/FormPage/getFormPage.js +16 -15
- package/dist/utils/FormPage/getFormPage.test.js +46 -47
- package/dist/utils/FormPage/getFormPages.js +12 -7
- package/dist/utils/FormPage/getFormPages.test.js +23 -20
- package/dist/utils/FormPage/getPageActions.js +15 -9
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getPageTitle.js +2 -2
- package/dist/utils/FormPage/getPageTitle.test.js +22 -22
- package/dist/utils/FormPage/getParagraphFromText.js +7 -5
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +1 -1
- package/dist/utils/FormPage/showFormPage.js +7 -3
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +28 -21
- package/dist/utils/FormPage/useComponent.test.js +79 -78
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +6 -5
- package/dist/utils/Format/formatDataForComponent.test.js +77 -50
- package/dist/utils/Format/formatDataForForm.js +8 -6
- package/dist/utils/Format/formatDataForForm.test.js +15 -13
- package/dist/utils/Format/formatDataForPage.js +5 -4
- package/dist/utils/Format/formatDataForPage.test.js +23 -20
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +31 -28
- package/dist/utils/Hub/index.js +1 -1
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +16 -24
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -14
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +34 -68
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -46
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +20 -22
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +36 -35
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +26 -21
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +10 -8
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +11 -7
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +41 -37
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +35 -0
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +127 -0
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +16 -14
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +4 -3
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +26 -28
- package/dist/utils/Validate/additional/utils.js +22 -9
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +25 -19
- package/dist/utils/Validate/validateCollection.test.js +66 -74
- package/dist/utils/Validate/validateComponent.js +16 -18
- package/dist/utils/Validate/validateComponent.test.js +146 -167
- package/dist/utils/Validate/validateContainer.js +19 -14
- package/dist/utils/Validate/validateContainer.test.js +45 -49
- package/dist/utils/Validate/validateDate.js +17 -11
- package/dist/utils/Validate/validateDate.test.js +29 -28
- package/dist/utils/Validate/validateEmail.js +8 -6
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +7 -5
- package/dist/utils/Validate/validateMultifile.test.js +18 -17
- package/dist/utils/Validate/validatePage.js +18 -17
- package/dist/utils/Validate/validatePage.test.js +182 -185
- package/dist/utils/Validate/validateRegex.js +5 -3
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +6 -4
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +6 -4
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +14 -7
- package/dist/utils/Validate/validateTime.test.js +14 -14
- package/dist/utils/index.js +9 -7
- package/package.json +1 -1
|
@@ -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]
|
|
@@ -302,14 +298,13 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
302
298
|
expect(setDataArgs[setDataCalls - 1]).toEqual(argsUsed.data); // Data is reset in the case of an error.
|
|
303
299
|
};
|
|
304
300
|
|
|
305
|
-
it("should handle the ".concat(_models.PageAction.TYPES.CANCEL, " Page Action type"), ()
|
|
306
|
-
|
|
301
|
+
it("should handle the ".concat(_models.PageAction.TYPES.CANCEL, " Page Action type"), function () {
|
|
302
|
+
var ACTION = {
|
|
307
303
|
type: _models.PageAction.TYPES.CANCEL
|
|
308
304
|
};
|
|
309
|
-
|
|
310
|
-
...ARGS,
|
|
305
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
311
306
|
action: ACTION
|
|
312
|
-
};
|
|
307
|
+
});
|
|
313
308
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
314
309
|
expect(MOCK_HOOKS.onCancelArgs.length).toEqual(1);
|
|
315
310
|
expect(MOCK_HOOKS.onCancelArgs[0]).toMatchObject({});
|
|
@@ -318,14 +313,13 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
318
313
|
expect(_helpers.default.canActionProceedCalls).toEqual(0);
|
|
319
314
|
expect(MOCK_VALIDATE.pageCalls).toEqual(0);
|
|
320
315
|
});
|
|
321
|
-
it("should handle the ".concat(_models.PageAction.TYPES.NAVIGATE, " Page Action type"), ()
|
|
322
|
-
|
|
316
|
+
it("should handle the ".concat(_models.PageAction.TYPES.NAVIGATE, " Page Action type"), function () {
|
|
317
|
+
var ACTION = {
|
|
323
318
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
324
319
|
};
|
|
325
|
-
|
|
326
|
-
...ARGS,
|
|
320
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
327
321
|
action: ACTION
|
|
328
|
-
};
|
|
322
|
+
});
|
|
329
323
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
330
324
|
preActionChecks();
|
|
331
325
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
@@ -335,28 +329,26 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
335
329
|
// hooks.navigate.
|
|
336
330
|
});
|
|
337
331
|
|
|
338
|
-
it("should handle the ".concat(_models.PageAction.TYPES.SUBMIT, " Page Action type"), ()
|
|
339
|
-
|
|
332
|
+
it("should handle the ".concat(_models.PageAction.TYPES.SUBMIT, " Page Action type"), function () {
|
|
333
|
+
var ACTION = {
|
|
340
334
|
type: _models.PageAction.TYPES.SUBMIT
|
|
341
335
|
};
|
|
342
|
-
|
|
343
|
-
...ARGS,
|
|
336
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
344
337
|
action: ACTION
|
|
345
|
-
};
|
|
338
|
+
});
|
|
346
339
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
347
340
|
preActionChecks();
|
|
348
341
|
expect(setPagePointCalls).toEqual(1);
|
|
349
342
|
expect(setPagePointArgs[0]).toEqual('submit');
|
|
350
343
|
postActionChecks(CUSTOM_ARGS);
|
|
351
344
|
});
|
|
352
|
-
it("should handle the ".concat(_models.PageAction.TYPES.SAVE_AND_NAVIGATE, " Page Action type"), ()
|
|
353
|
-
|
|
345
|
+
it("should handle the ".concat(_models.PageAction.TYPES.SAVE_AND_NAVIGATE, " Page Action type"), function () {
|
|
346
|
+
var ACTION = {
|
|
354
347
|
type: _models.PageAction.TYPES.SAVE_AND_NAVIGATE
|
|
355
348
|
};
|
|
356
|
-
|
|
357
|
-
...ARGS,
|
|
349
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
358
350
|
action: ACTION
|
|
359
|
-
};
|
|
351
|
+
});
|
|
360
352
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
361
353
|
preActionChecks();
|
|
362
354
|
// All the actions does in this case is set a function
|
|
@@ -364,23 +356,22 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
364
356
|
postActionChecks(CUSTOM_ARGS);
|
|
365
357
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
366
358
|
});
|
|
367
|
-
it("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_ADD, " Page Action type"), ()
|
|
368
|
-
|
|
359
|
+
it("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_ADD, " Page Action type"), function () {
|
|
360
|
+
var FORM_STATE = {
|
|
369
361
|
page: {
|
|
370
362
|
formData: {
|
|
371
363
|
'testCollection': []
|
|
372
364
|
}
|
|
373
365
|
}
|
|
374
366
|
};
|
|
375
|
-
|
|
367
|
+
var ACTION = {
|
|
376
368
|
type: _models.PageAction.TYPES.COLLECTION_ADD,
|
|
377
369
|
collection: 'testCollection'
|
|
378
370
|
};
|
|
379
|
-
|
|
380
|
-
...ARGS,
|
|
371
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
381
372
|
action: ACTION,
|
|
382
373
|
formState: FORM_STATE
|
|
383
|
-
};
|
|
374
|
+
});
|
|
384
375
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
385
376
|
preActionChecks();
|
|
386
377
|
expect(FORM_STATE.page.formData["".concat(ACTION.collection, "ActiveId")]).toBeDefined();
|
|
@@ -390,24 +381,23 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
390
381
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
391
382
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
392
383
|
});
|
|
393
|
-
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_DUPLICATE, " Page Action type"), ()
|
|
394
|
-
it("calling handlers.navigate if the duplication was successful", ()
|
|
395
|
-
|
|
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 = {
|
|
396
387
|
page: {
|
|
397
388
|
formData: {
|
|
398
389
|
'testCollection': []
|
|
399
390
|
}
|
|
400
391
|
}
|
|
401
392
|
};
|
|
402
|
-
|
|
393
|
+
var ACTION = {
|
|
403
394
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
404
395
|
collection: 'testCollection'
|
|
405
396
|
};
|
|
406
|
-
|
|
407
|
-
...ARGS,
|
|
397
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
408
398
|
action: ACTION,
|
|
409
399
|
formState: FORM_STATE
|
|
410
|
-
};
|
|
400
|
+
});
|
|
411
401
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
412
402
|
preActionChecks();
|
|
413
403
|
expect(_utils.default.CollectionPage.duplicateActiveEntryCalls).toEqual(1);
|
|
@@ -417,23 +407,22 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
417
407
|
// that's called as part of the onSubmit hook's onSuccess callback.
|
|
418
408
|
expect(_handlers.default.navigateCalls).toEqual(1);
|
|
419
409
|
});
|
|
420
|
-
it("calling onPageChange if the duplication was unsuccessful", ()
|
|
421
|
-
|
|
410
|
+
it("calling onPageChange if the duplication was unsuccessful", function () {
|
|
411
|
+
var FORM_STATE = {
|
|
422
412
|
page: {
|
|
423
413
|
formData: {
|
|
424
414
|
'testCollection': []
|
|
425
415
|
}
|
|
426
416
|
}
|
|
427
417
|
};
|
|
428
|
-
|
|
418
|
+
var ACTION = {
|
|
429
419
|
type: _models.PageAction.TYPES.COLLECTION_DUPLICATE,
|
|
430
420
|
collection: 'testCollection'
|
|
431
421
|
};
|
|
432
|
-
|
|
433
|
-
...ARGS,
|
|
422
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
434
423
|
action: ACTION,
|
|
435
424
|
formState: FORM_STATE
|
|
436
|
-
};
|
|
425
|
+
});
|
|
437
426
|
_utils.default.CollectionPage.duplicateActiveEntryResult = false;
|
|
438
427
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
439
428
|
preActionChecks();
|
|
@@ -447,9 +436,9 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
447
436
|
expect(onPageChangeCalls).toEqual(1);
|
|
448
437
|
});
|
|
449
438
|
});
|
|
450
|
-
describe("should handle the ".concat(_models.PageAction.TYPES.COLLECTION_REMOVE, " Page Action type"), ()
|
|
451
|
-
it("should store a reference to the removed item if action.recordRemoval is true", ()
|
|
452
|
-
|
|
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 = {
|
|
453
442
|
page: {
|
|
454
443
|
formData: {
|
|
455
444
|
testCollectionActiveId: 'removeMe',
|
|
@@ -461,16 +450,15 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
461
450
|
}
|
|
462
451
|
}
|
|
463
452
|
};
|
|
464
|
-
|
|
453
|
+
var ACTION = {
|
|
465
454
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
466
455
|
collection: 'testCollection',
|
|
467
456
|
recordRemoval: true
|
|
468
457
|
};
|
|
469
|
-
|
|
470
|
-
...ARGS,
|
|
458
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
471
459
|
action: ACTION,
|
|
472
460
|
formState: FORM_STATE
|
|
473
|
-
};
|
|
461
|
+
});
|
|
474
462
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
475
463
|
preActionChecks();
|
|
476
464
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -484,8 +472,8 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
484
472
|
// This action type uses the default onPageChange.
|
|
485
473
|
expect(onPageChangeCalls).toEqual(1);
|
|
486
474
|
});
|
|
487
|
-
it("should not store a reference to the removed item if action.recordRemoval is false", ()
|
|
488
|
-
|
|
475
|
+
it("should not store a reference to the removed item if action.recordRemoval is false", function () {
|
|
476
|
+
var FORM_STATE = {
|
|
489
477
|
page: {
|
|
490
478
|
formData: {
|
|
491
479
|
testCollectionActiveId: 'removeMe',
|
|
@@ -497,16 +485,15 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
497
485
|
}
|
|
498
486
|
}
|
|
499
487
|
};
|
|
500
|
-
|
|
488
|
+
var ACTION = {
|
|
501
489
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
502
490
|
collection: 'testCollection',
|
|
503
491
|
recordRemoval: false
|
|
504
492
|
};
|
|
505
|
-
|
|
506
|
-
...ARGS,
|
|
493
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
507
494
|
action: ACTION,
|
|
508
495
|
formState: FORM_STATE
|
|
509
|
-
};
|
|
496
|
+
});
|
|
510
497
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
511
498
|
preActionChecks();
|
|
512
499
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -518,8 +505,8 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
518
505
|
// This action type uses the default onPageChange.
|
|
519
506
|
expect(onPageChangeCalls).toEqual(1);
|
|
520
507
|
});
|
|
521
|
-
it("should not store a reference to the removed item if action.recordRemoval is not defined", ()
|
|
522
|
-
|
|
508
|
+
it("should not store a reference to the removed item if action.recordRemoval is not defined", function () {
|
|
509
|
+
var FORM_STATE = {
|
|
523
510
|
page: {
|
|
524
511
|
formData: {
|
|
525
512
|
testCollectionActiveId: 'removeMe',
|
|
@@ -531,15 +518,14 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
531
518
|
}
|
|
532
519
|
}
|
|
533
520
|
};
|
|
534
|
-
|
|
521
|
+
var ACTION = {
|
|
535
522
|
type: _models.PageAction.TYPES.COLLECTION_REMOVE,
|
|
536
523
|
collection: 'testCollection'
|
|
537
524
|
};
|
|
538
|
-
|
|
539
|
-
...ARGS,
|
|
525
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
540
526
|
action: ACTION,
|
|
541
527
|
formState: FORM_STATE
|
|
542
|
-
};
|
|
528
|
+
});
|
|
543
529
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
544
530
|
preActionChecks();
|
|
545
531
|
expect(FORM_STATE.page.formData.testCollection).toEqual([{
|
|
@@ -552,17 +538,18 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
552
538
|
expect(onPageChangeCalls).toEqual(1);
|
|
553
539
|
});
|
|
554
540
|
});
|
|
555
|
-
describe('if validation fails', ()
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
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 = {
|
|
560
548
|
type: actionType
|
|
561
549
|
};
|
|
562
|
-
|
|
563
|
-
...ARGS,
|
|
550
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
564
551
|
action: ACTION
|
|
565
|
-
};
|
|
552
|
+
});
|
|
566
553
|
_helpers.default.canActionProceedResult = false;
|
|
567
554
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
568
555
|
expect(_helpers.default.canActionProceedCalls).toEqual(1);
|
|
@@ -573,18 +560,20 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
573
560
|
});
|
|
574
561
|
});
|
|
575
562
|
});
|
|
576
|
-
describe('adding a field to formData if specified on the action', ()
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
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 = {
|
|
581
570
|
page: {
|
|
582
571
|
formData: {
|
|
583
572
|
testCollection: []
|
|
584
573
|
}
|
|
585
574
|
}
|
|
586
575
|
};
|
|
587
|
-
|
|
576
|
+
var ACTION = {
|
|
588
577
|
type: actionType,
|
|
589
578
|
collection: 'testCollection',
|
|
590
579
|
addToFormData: {
|
|
@@ -592,11 +581,10 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
592
581
|
value: '123'
|
|
593
582
|
}
|
|
594
583
|
};
|
|
595
|
-
|
|
596
|
-
...ARGS,
|
|
584
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
597
585
|
formState: FORM_STATE,
|
|
598
586
|
action: ACTION
|
|
599
|
-
};
|
|
587
|
+
});
|
|
600
588
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
601
589
|
preActionChecks();
|
|
602
590
|
postActionChecks(CUSTOM_ARGS);
|
|
@@ -605,15 +593,15 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
605
593
|
});
|
|
606
594
|
});
|
|
607
595
|
});
|
|
608
|
-
it("should work for the ".concat(_models.PageAction.TYPES.NAVIGATE, " action type"), ()
|
|
609
|
-
|
|
596
|
+
it("should work for the ".concat(_models.PageAction.TYPES.NAVIGATE, " action type"), function () {
|
|
597
|
+
var FORM_STATE = {
|
|
610
598
|
page: {
|
|
611
599
|
formData: {
|
|
612
600
|
testCollection: []
|
|
613
601
|
}
|
|
614
602
|
}
|
|
615
603
|
};
|
|
616
|
-
|
|
604
|
+
var ACTION = {
|
|
617
605
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
618
606
|
collection: 'testCollection',
|
|
619
607
|
addToFormData: {
|
|
@@ -621,11 +609,10 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
621
609
|
value: '123'
|
|
622
610
|
}
|
|
623
611
|
};
|
|
624
|
-
|
|
625
|
-
...ARGS,
|
|
612
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
626
613
|
formState: FORM_STATE,
|
|
627
614
|
action: ACTION
|
|
628
|
-
};
|
|
615
|
+
});
|
|
629
616
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
630
617
|
preActionChecks();
|
|
631
618
|
// Not doing the usual post-action checks here
|
|
@@ -635,15 +622,15 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
635
622
|
alpha: '123'
|
|
636
623
|
});
|
|
637
624
|
});
|
|
638
|
-
it('should work for an array of formData', ()
|
|
639
|
-
|
|
625
|
+
it('should work for an array of formData', function () {
|
|
626
|
+
var FORM_STATE = {
|
|
640
627
|
page: {
|
|
641
628
|
formData: {
|
|
642
629
|
testCollection: []
|
|
643
630
|
}
|
|
644
631
|
}
|
|
645
632
|
};
|
|
646
|
-
|
|
633
|
+
var ACTION = {
|
|
647
634
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
648
635
|
collection: 'testCollection',
|
|
649
636
|
addToFormData: [{
|
|
@@ -654,11 +641,10 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
654
641
|
value: '456'
|
|
655
642
|
}]
|
|
656
643
|
};
|
|
657
|
-
|
|
658
|
-
...ARGS,
|
|
644
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
659
645
|
formState: FORM_STATE,
|
|
660
646
|
action: ACTION
|
|
661
|
-
};
|
|
647
|
+
});
|
|
662
648
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
663
649
|
preActionChecks();
|
|
664
650
|
// Not doing the usual post-action checks here
|
|
@@ -672,37 +658,34 @@ describe('components.FormRenderer.onPageAction', () => {
|
|
|
672
658
|
});
|
|
673
659
|
});
|
|
674
660
|
});
|
|
675
|
-
describe('recording patchLabel fields correctly when it is defined', ()
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
661
|
+
describe('recording patchLabel fields correctly when it is defined', function () {
|
|
662
|
+
var VALID_ACTIONS = Object.values(_models.PageAction.TYPES).filter(function (a) {
|
|
663
|
+
return a !== _models.PageAction.TYPES.CANCEL && a !== _models.PageAction.TYPES.NAVIGATE;
|
|
664
|
+
});
|
|
665
|
+
VALID_ACTIONS.forEach(function (actionType) {
|
|
666
|
+
it("should work for the ".concat(actionType, " action type"), function () {
|
|
667
|
+
var FORM_STATE = {
|
|
680
668
|
page: {
|
|
681
669
|
formData: {
|
|
682
670
|
testCollection: []
|
|
683
671
|
}
|
|
684
672
|
}
|
|
685
673
|
};
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
const PATCH = {
|
|
692
|
-
[KEY]: VALUE
|
|
693
|
-
};
|
|
694
|
-
const ACTION = {
|
|
674
|
+
var KEY = 'testField';
|
|
675
|
+
var VALUE = 'testValue';
|
|
676
|
+
var PATCH_LABEL = _defineProperty({}, KEY, VALUE);
|
|
677
|
+
var PATCH = _defineProperty({}, KEY, VALUE);
|
|
678
|
+
var ACTION = {
|
|
695
679
|
type: actionType,
|
|
696
680
|
collection: 'testCollection'
|
|
697
681
|
};
|
|
698
|
-
|
|
699
|
-
...ARGS,
|
|
682
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
700
683
|
action: ACTION,
|
|
701
684
|
formState: FORM_STATE,
|
|
702
685
|
patch: PATCH,
|
|
703
686
|
patchLabel: PATCH_LABEL,
|
|
704
687
|
type: _models.FormTypes.HUB
|
|
705
|
-
};
|
|
688
|
+
});
|
|
706
689
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
707
690
|
preActionChecks();
|
|
708
691
|
postActionChecks(CUSTOM_ARGS); // Specific check for patchLabel done in here.
|