@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
|
@@ -7,22 +7,26 @@ exports.default = void 0;
|
|
|
7
7
|
var _models = require("../../models");
|
|
8
8
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
+
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); }
|
|
16
|
+
var onTaskAction = function onTaskAction(currentTask, pages, setCurrentTask, hubDetails, data, onPageChange) {
|
|
11
17
|
if (currentTask) {
|
|
12
|
-
|
|
18
|
+
var task = currentTask;
|
|
13
19
|
task.fullPages = [];
|
|
14
|
-
task.pages.forEach(page
|
|
20
|
+
task.pages.forEach(function (page) {
|
|
15
21
|
task.fullPages.push(_helpers.default.getPage(page, pages));
|
|
16
22
|
});
|
|
17
23
|
setCurrentTask(currentTask);
|
|
18
|
-
|
|
19
|
-
...task
|
|
20
|
-
};
|
|
24
|
+
var state = _objectSpread({}, task);
|
|
21
25
|
if (task.state === _models.TaskStates.TYPES.COMPLETE && !task.alwaysShowFirstPage) {
|
|
22
26
|
if (hubDetails !== null && hubDetails !== void 0 && hubDetails.noTaskCYAs) {
|
|
23
27
|
// If the task is complete and there are no CYA's then show user first page
|
|
24
28
|
/* eslint-disable prefer-destructuring */
|
|
25
|
-
|
|
29
|
+
var currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
26
30
|
onPageChange(task.pages[0] || currentPage);
|
|
27
31
|
} else if (task.customCYA) {
|
|
28
32
|
onPageChange(task.customCYA);
|
|
@@ -30,9 +34,9 @@ const onTaskAction = (currentTask, pages, setCurrentTask, hubDetails, data, onPa
|
|
|
30
34
|
onPageChange(_models.FormPages.CYA, state);
|
|
31
35
|
}
|
|
32
36
|
} else if (task.state === _models.TaskStates.TYPES.IN_PROGRESS && !task.alwaysShowFirstPage) {
|
|
33
|
-
|
|
37
|
+
var _currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
34
38
|
/* eslint-enable prefer-destructuring */
|
|
35
|
-
onPageChange(
|
|
39
|
+
onPageChange(_currentPage || currentTask.pages[0], state);
|
|
36
40
|
} else if (task.firstPage) {
|
|
37
41
|
onPageChange(task.firstPage, state);
|
|
38
42
|
} else {
|
|
@@ -4,31 +4,39 @@ var _models = require("../../models");
|
|
|
4
4
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
5
5
|
var _onTaskAction = _interopRequireDefault(require("./onTaskAction"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
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); }
|
|
13
|
+
jest.mock('./helpers', function () {
|
|
14
|
+
return {
|
|
15
|
+
getPageArgs: [],
|
|
16
|
+
getPage: function getPage(page, pages) {
|
|
17
|
+
this.getPageArgs.push({
|
|
18
|
+
page: page,
|
|
19
|
+
pages: pages
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
reset: function reset() {
|
|
23
|
+
this.getPageArgs = [];
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
describe('components.FormRenderer.onTaskAction', function () {
|
|
28
|
+
var setCurrentTaskArgs = [];
|
|
29
|
+
var mockSetCurrentTask = function mockSetCurrentTask(task) {
|
|
22
30
|
setCurrentTaskArgs.push(task);
|
|
23
31
|
};
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
var onPageChangeArgs = [];
|
|
33
|
+
var mockOnPageChange = function mockOnPageChange(page, state) {
|
|
26
34
|
onPageChangeArgs.push({
|
|
27
|
-
page,
|
|
28
|
-
state
|
|
35
|
+
page: page,
|
|
36
|
+
state: state
|
|
29
37
|
});
|
|
30
38
|
};
|
|
31
|
-
|
|
39
|
+
var PAGES = [{
|
|
32
40
|
id: 'page1'
|
|
33
41
|
}, {
|
|
34
42
|
id: 'page2'
|
|
@@ -37,7 +45,7 @@ describe('components.FormRenderer.onTaskAction', () => {
|
|
|
37
45
|
}, {
|
|
38
46
|
id: 'customCya'
|
|
39
47
|
}];
|
|
40
|
-
|
|
48
|
+
var DATA = {
|
|
41
49
|
formStatus: {
|
|
42
50
|
tasks: {
|
|
43
51
|
task1: {
|
|
@@ -50,7 +58,7 @@ describe('components.FormRenderer.onTaskAction', () => {
|
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
};
|
|
53
|
-
|
|
61
|
+
var ARGS = {
|
|
54
62
|
currentTask: null,
|
|
55
63
|
pages: PAGES,
|
|
56
64
|
setCurrentTask: mockSetCurrentTask,
|
|
@@ -58,76 +66,70 @@ describe('components.FormRenderer.onTaskAction', () => {
|
|
|
58
66
|
data: DATA,
|
|
59
67
|
onPageChange: mockOnPageChange
|
|
60
68
|
};
|
|
61
|
-
|
|
69
|
+
var genericChecks = function genericChecks(currentTask) {
|
|
62
70
|
expect(_helpers.default.getPageArgs.length).toEqual(currentTask.pages.length);
|
|
63
71
|
expect(currentTask.fullPages.length).toEqual(currentTask.pages.length);
|
|
64
72
|
expect(setCurrentTaskArgs.length).toEqual(1);
|
|
65
73
|
expect(setCurrentTaskArgs[0]).toEqual(currentTask);
|
|
66
74
|
};
|
|
67
|
-
beforeEach(()
|
|
75
|
+
beforeEach(function () {
|
|
68
76
|
setCurrentTaskArgs = [];
|
|
69
77
|
onPageChangeArgs = [];
|
|
70
78
|
_helpers.default.reset();
|
|
71
79
|
});
|
|
72
|
-
it('should do nothing if currentTask is null', ()
|
|
80
|
+
it('should do nothing if currentTask is null', function () {
|
|
73
81
|
_onTaskAction.default.apply(void 0, Object.values(ARGS));
|
|
74
82
|
expect(_helpers.default.getPageArgs.length).toEqual(0);
|
|
75
83
|
expect(setCurrentTaskArgs.length).toEqual(0);
|
|
76
84
|
expect(onPageChangeArgs.length).toEqual(0);
|
|
77
85
|
});
|
|
78
|
-
describe("when currentTask has a state of ".concat(_models.TaskStates.TYPES.COMPLETE), ()
|
|
79
|
-
|
|
86
|
+
describe("when currentTask has a state of ".concat(_models.TaskStates.TYPES.COMPLETE), function () {
|
|
87
|
+
var TASK = {
|
|
80
88
|
name: 'task1',
|
|
81
89
|
state: _models.TaskStates.TYPES.COMPLETE,
|
|
82
90
|
pages: ['page1', 'page2', 'page3']
|
|
83
91
|
};
|
|
84
|
-
it('should handle task CYAs not being shown', ()
|
|
85
|
-
|
|
86
|
-
...ARGS,
|
|
92
|
+
it('should handle task CYAs not being shown', function () {
|
|
93
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
87
94
|
currentTask: TASK,
|
|
88
95
|
hubDetails: {
|
|
89
96
|
noTaskCYAs: true
|
|
90
97
|
}
|
|
91
|
-
};
|
|
98
|
+
});
|
|
92
99
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
93
100
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
94
101
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
95
102
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.pages[0]);
|
|
96
103
|
});
|
|
97
|
-
it('should handle task CYAs not being shown and no pages being provided on currentTask', ()
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
currentTask: {
|
|
101
|
-
...TASK,
|
|
104
|
+
it('should handle task CYAs not being shown and no pages being provided on currentTask', function () {
|
|
105
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
106
|
+
currentTask: _objectSpread(_objectSpread({}, TASK), {}, {
|
|
102
107
|
pages: []
|
|
103
|
-
},
|
|
108
|
+
}),
|
|
104
109
|
hubDetails: {
|
|
105
110
|
noTaskCYAs: true
|
|
106
111
|
}
|
|
107
|
-
};
|
|
112
|
+
});
|
|
108
113
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
109
114
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
110
115
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
111
116
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.data.formStatus.tasks[CUSTOM_ARGS.currentTask.name].currentPage);
|
|
112
117
|
});
|
|
113
|
-
it('should handle a custom CYA being provided', ()
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
currentTask: {
|
|
117
|
-
...TASK,
|
|
118
|
+
it('should handle a custom CYA being provided', function () {
|
|
119
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
120
|
+
currentTask: _objectSpread(_objectSpread({}, TASK), {}, {
|
|
118
121
|
customCYA: 'customCya'
|
|
119
|
-
}
|
|
120
|
-
};
|
|
122
|
+
})
|
|
123
|
+
});
|
|
121
124
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
122
125
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
123
126
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
124
127
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.customCYA);
|
|
125
128
|
});
|
|
126
|
-
it('should handle navigation to a normal CYA page', ()
|
|
127
|
-
|
|
128
|
-
...ARGS,
|
|
129
|
+
it('should handle navigation to a normal CYA page', function () {
|
|
130
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
129
131
|
currentTask: TASK
|
|
130
|
-
};
|
|
132
|
+
});
|
|
131
133
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
132
134
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
133
135
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
@@ -135,69 +137,65 @@ describe('components.FormRenderer.onTaskAction', () => {
|
|
|
135
137
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
136
138
|
});
|
|
137
139
|
});
|
|
138
|
-
describe("when currentTask has a state of ".concat(_models.TaskStates.TYPES.IN_PROGRESS), ()
|
|
139
|
-
it('should handle page change when formStatus has a current page for the task', ()
|
|
140
|
-
|
|
140
|
+
describe("when currentTask has a state of ".concat(_models.TaskStates.TYPES.IN_PROGRESS), function () {
|
|
141
|
+
it('should handle page change when formStatus has a current page for the task', function () {
|
|
142
|
+
var TASK = {
|
|
141
143
|
name: 'task1',
|
|
142
144
|
state: _models.TaskStates.TYPES.IN_PROGRESS,
|
|
143
145
|
pages: ['page1', 'page2', 'page3']
|
|
144
146
|
};
|
|
145
|
-
|
|
146
|
-
...ARGS,
|
|
147
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
147
148
|
currentTask: TASK
|
|
148
|
-
};
|
|
149
|
+
});
|
|
149
150
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
150
151
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
151
152
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
152
153
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.data.formStatus.tasks[CUSTOM_ARGS.currentTask.name].currentPage);
|
|
153
154
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
154
155
|
});
|
|
155
|
-
it('should handle page change when formStatus does not have a current page for the task', ()
|
|
156
|
-
|
|
156
|
+
it('should handle page change when formStatus does not have a current page for the task', function () {
|
|
157
|
+
var TASK = {
|
|
157
158
|
name: 'taskNoCurrentPage',
|
|
158
159
|
state: _models.TaskStates.TYPES.IN_PROGRESS,
|
|
159
160
|
pages: ['page1', 'page2', 'page3']
|
|
160
161
|
};
|
|
161
|
-
|
|
162
|
-
...ARGS,
|
|
162
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
163
163
|
currentTask: TASK
|
|
164
|
-
};
|
|
164
|
+
});
|
|
165
165
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
166
166
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
167
167
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
168
168
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.pages[0]);
|
|
169
169
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
170
170
|
});
|
|
171
|
-
it('should navigate to firstPage if alwaysShowFirstPage is set if state is in progress', ()
|
|
172
|
-
|
|
171
|
+
it('should navigate to firstPage if alwaysShowFirstPage is set if state is in progress', function () {
|
|
172
|
+
var TASK = {
|
|
173
173
|
name: 'taskalwaysShowFirstPageInProgress',
|
|
174
174
|
state: _models.TaskStates.TYPES.IN_PROGRESS,
|
|
175
175
|
firstPage: 'page2',
|
|
176
176
|
alwaysShowFirstPage: true,
|
|
177
177
|
pages: ['page1', 'page2', 'page3']
|
|
178
178
|
};
|
|
179
|
-
|
|
180
|
-
...ARGS,
|
|
179
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
181
180
|
currentTask: TASK
|
|
182
|
-
};
|
|
181
|
+
});
|
|
183
182
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
184
183
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
185
184
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
186
185
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.pages[1]);
|
|
187
186
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
188
187
|
});
|
|
189
|
-
it('should navigate to firstPage if alwaysShowFirstPage is set if state is in progress', ()
|
|
190
|
-
|
|
188
|
+
it('should navigate to firstPage if alwaysShowFirstPage is set if state is in progress', function () {
|
|
189
|
+
var TASK = {
|
|
191
190
|
name: 'taskalwaysShowFirstPageComplete',
|
|
192
191
|
state: _models.TaskStates.TYPES.COMPLETE,
|
|
193
192
|
firstPage: 'page2',
|
|
194
193
|
alwaysShowFirstPage: true,
|
|
195
194
|
pages: ['page1', 'page2', 'page3']
|
|
196
195
|
};
|
|
197
|
-
|
|
198
|
-
...ARGS,
|
|
196
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
199
197
|
currentTask: TASK
|
|
200
|
-
};
|
|
198
|
+
});
|
|
201
199
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
202
200
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
203
201
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
@@ -205,47 +203,44 @@ describe('components.FormRenderer.onTaskAction', () => {
|
|
|
205
203
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
206
204
|
});
|
|
207
205
|
});
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
var otherStates = Object.values(_models.TaskStates.TYPES).filter(function (t) {
|
|
207
|
+
return t !== _models.TaskStates.TYPES.IN_PROGRESS && t !== _models.TaskStates.TYPES.COMPLETE;
|
|
208
|
+
});
|
|
209
|
+
otherStates.forEach(function (state) {
|
|
210
|
+
describe("when currentTask has a state of ".concat(state), function () {
|
|
211
|
+
var TASK = {
|
|
212
212
|
name: 'task1',
|
|
213
|
-
state,
|
|
213
|
+
state: state,
|
|
214
214
|
pages: ['page1', 'page2', 'page3']
|
|
215
215
|
};
|
|
216
|
-
it('should handle the task having a specific first page defined', ()
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
currentTask: {
|
|
220
|
-
...TASK,
|
|
216
|
+
it('should handle the task having a specific first page defined', function () {
|
|
217
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
218
|
+
currentTask: _objectSpread(_objectSpread({}, TASK), {}, {
|
|
221
219
|
firstPage: 'page2'
|
|
222
|
-
}
|
|
223
|
-
};
|
|
220
|
+
})
|
|
221
|
+
});
|
|
224
222
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
225
223
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
226
224
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
227
225
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.firstPage);
|
|
228
226
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
229
227
|
});
|
|
230
|
-
it('should handle the task having the first page defined as null', ()
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
currentTask: {
|
|
234
|
-
...TASK,
|
|
228
|
+
it('should handle the task having the first page defined as null', function () {
|
|
229
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
230
|
+
currentTask: _objectSpread(_objectSpread({}, TASK), {}, {
|
|
235
231
|
firstPage: null
|
|
236
|
-
}
|
|
237
|
-
};
|
|
232
|
+
})
|
|
233
|
+
});
|
|
238
234
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
239
235
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
240
236
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
241
237
|
expect(onPageChangeArgs[0].page).toEqual(CUSTOM_ARGS.currentTask.pages[0]);
|
|
242
238
|
expect(onPageChangeArgs[0].state).toEqual(CUSTOM_ARGS.currentTask);
|
|
243
239
|
});
|
|
244
|
-
it('should handle the task not having a specific first page defined', ()
|
|
245
|
-
|
|
246
|
-
...ARGS,
|
|
240
|
+
it('should handle the task not having a specific first page defined', function () {
|
|
241
|
+
var CUSTOM_ARGS = _objectSpread(_objectSpread({}, ARGS), {}, {
|
|
247
242
|
currentTask: TASK
|
|
248
|
-
};
|
|
243
|
+
});
|
|
249
244
|
_onTaskAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
250
245
|
genericChecks(CUSTOM_ARGS.currentTask);
|
|
251
246
|
expect(onPageChangeArgs.length).toEqual(1);
|
|
@@ -8,18 +8,19 @@ var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _models = require("../../models");
|
|
11
|
-
|
|
12
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } // Global imports
|
|
11
|
+
var _excluded = ["action", "onAction"]; // Global imports
|
|
13
12
|
// Local imports
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
+
var DEFAULT_LABEL = exports.DEFAULT_LABEL = 'Continue';
|
|
18
|
+
var ActionButton = function ActionButton(_ref) {
|
|
19
|
+
var _action = _ref.action,
|
|
20
|
+
onAction = _ref.onAction,
|
|
21
|
+
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
+
var action = typeof _action === 'string' ? _models.PageAction.DEFAULTS[_action] : _action;
|
|
23
|
+
var actionLabel = _models.PageAction.DEFAULTS[_action.type];
|
|
23
24
|
if (!action) {
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
@@ -28,7 +29,9 @@ const ActionButton = _ref => {
|
|
|
28
29
|
classModifiers: action.classModifiers,
|
|
29
30
|
start: action.start || false,
|
|
30
31
|
name: action.label,
|
|
31
|
-
onClick: action.disabled ? ()
|
|
32
|
+
onClick: action.disabled ? function () {} : function () {
|
|
33
|
+
return onAction(action);
|
|
34
|
+
}
|
|
32
35
|
}), action.label || (actionLabel === null || actionLabel === void 0 ? void 0 : actionLabel.label) || DEFAULT_LABEL);
|
|
33
36
|
};
|
|
34
37
|
ActionButton.propTypes = {
|
|
@@ -1,72 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
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); }
|
|
3
4
|
var _react = require("@testing-library/react");
|
|
4
5
|
var _react2 = _interopRequireDefault(require("react"));
|
|
5
6
|
var _models = require("../../models");
|
|
6
7
|
var _ActionButton = _interopRequireWildcard(require("./ActionButton"));
|
|
7
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
8
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
12
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
13
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } // Global imports
|
|
12
14
|
// Local imports
|
|
13
|
-
|
|
14
|
-
describe('
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const ON_ACTION = action => {
|
|
15
|
+
describe('components', function () {
|
|
16
|
+
describe('PageActions.ActionButton', function () {
|
|
17
|
+
var ON_ACTION_CALLS = [];
|
|
18
|
+
var ON_ACTION = function ON_ACTION(action) {
|
|
18
19
|
ON_ACTION_CALLS.push(action);
|
|
19
20
|
};
|
|
20
|
-
beforeEach(()
|
|
21
|
+
beforeEach(function () {
|
|
21
22
|
ON_ACTION_CALLS.length = 0;
|
|
22
23
|
});
|
|
23
|
-
it('should handle an unknown action identifier',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
it('should handle an unknown action identifier', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
25
|
+
var ACTION, _render, container;
|
|
26
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
27
|
+
while (1) switch (_context.prev = _context.next) {
|
|
28
|
+
case 0:
|
|
29
|
+
ACTION = 'unknown';
|
|
30
|
+
_render = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_ActionButton.default, {
|
|
31
|
+
action: ACTION,
|
|
32
|
+
onAction: ON_ACTION
|
|
33
|
+
})), container = _render.container;
|
|
34
|
+
expect(container.childNodes.length).toEqual(0);
|
|
35
|
+
case 3:
|
|
36
|
+
case "end":
|
|
37
|
+
return _context.stop();
|
|
38
|
+
}
|
|
39
|
+
}, _callee);
|
|
40
|
+
})));
|
|
41
|
+
it('should appropriately display a submit action', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
42
|
+
var ACTION, _render2, container, button;
|
|
43
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
44
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
ACTION = _models.PageAction.TYPES.SUBMIT;
|
|
47
|
+
_render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_ActionButton.default, {
|
|
48
|
+
action: ACTION,
|
|
49
|
+
onAction: ON_ACTION
|
|
50
|
+
})), container = _render2.container;
|
|
51
|
+
button = container.childNodes[0];
|
|
52
|
+
expect(button.tagName).toEqual('BUTTON');
|
|
53
|
+
expect(button.textContent).toEqual(_ActionButton.DEFAULT_LABEL);
|
|
44
54
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
// Click the button and make sure it fires the onAction handler.
|
|
56
|
+
_react.fireEvent.click(button, {});
|
|
57
|
+
expect(ON_ACTION_CALLS.length).toEqual(1);
|
|
58
|
+
expect(ON_ACTION_CALLS[0]).toEqual(_models.PageAction.DEFAULTS.submit);
|
|
59
|
+
case 8:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context2.stop();
|
|
62
|
+
}
|
|
63
|
+
}, _callee2);
|
|
64
|
+
})));
|
|
65
|
+
it('should appropriately display a custom action', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
66
|
+
var ACTION, _render3, container, button;
|
|
67
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
68
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
69
|
+
case 0:
|
|
70
|
+
ACTION = {
|
|
71
|
+
type: 'navigate',
|
|
72
|
+
url: '/alpha',
|
|
73
|
+
label: 'Alpha'
|
|
74
|
+
};
|
|
75
|
+
_render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_ActionButton.default, {
|
|
76
|
+
action: ACTION,
|
|
77
|
+
onAction: ON_ACTION
|
|
78
|
+
})), container = _render3.container;
|
|
79
|
+
button = container.childNodes[0];
|
|
80
|
+
expect(button.tagName).toEqual('BUTTON');
|
|
81
|
+
expect(button.textContent).toEqual(ACTION.label);
|
|
65
82
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
83
|
+
// Click the button and make sure it fires the onAction handler.
|
|
84
|
+
_react.fireEvent.click(button, {});
|
|
85
|
+
expect(ON_ACTION_CALLS.length).toEqual(1);
|
|
86
|
+
expect(ON_ACTION_CALLS[0]).toEqual(ACTION);
|
|
87
|
+
case 8:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context3.stop();
|
|
90
|
+
}
|
|
91
|
+
}, _callee3);
|
|
92
|
+
})));
|
|
71
93
|
});
|
|
72
94
|
});
|
|
@@ -13,19 +13,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
13
13
|
|
|
14
14
|
// Local imports
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
onAction
|
|
20
|
-
} = _ref;
|
|
16
|
+
var PageActions = function PageActions(_ref) {
|
|
17
|
+
var actions = _ref.actions,
|
|
18
|
+
onAction = _ref.onAction;
|
|
21
19
|
if (!actions || actions.length === 0) {
|
|
22
20
|
return null;
|
|
23
21
|
}
|
|
24
|
-
return /*#__PURE__*/_react.default.createElement(_copReactComponents.ButtonGroup, null, actions.map((action, index)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(_copReactComponents.ButtonGroup, null, actions.map(function (action, index) {
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
|
|
24
|
+
key: index,
|
|
25
|
+
action: action,
|
|
26
|
+
onAction: onAction
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
29
29
|
};
|
|
30
30
|
PageActions.propTypes = {
|
|
31
31
|
actions: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({}), _propTypes.default.string])).isRequired,
|