@ukhomeoffice/cop-react-form-renderer 6.5.1-peter → 6.7.0-alpha
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 +92 -127
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +101 -131
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +463 -769
- package/dist/components/CollectionPage/CollectionPage.js +73 -63
- package/dist/components/CollectionPage/CollectionPage.test.js +316 -366
- package/dist/components/CollectionSummary/BannerStrip.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.test.js +80 -76
- package/dist/components/CollectionSummary/CollectionSummary.js +97 -107
- package/dist/components/CollectionSummary/CollectionSummary.test.js +152 -142
- package/dist/components/CollectionSummary/Confirmation.js +14 -12
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +45 -51
- package/dist/components/CollectionSummary/RenderListView.test.js +78 -77
- package/dist/components/CollectionSummary/SummaryCard.js +104 -135
- package/dist/components/CollectionSummary/SummaryCard.test.js +930 -962
- package/dist/components/CollectionSummary/SummaryCardDetails.js +72 -71
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +128 -135
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +30 -35
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +62 -74
- package/dist/components/FormComponent/Collection.js +74 -108
- package/dist/components/FormComponent/Collection.test.js +909 -1081
- package/dist/components/FormComponent/Container.js +40 -38
- package/dist/components/FormComponent/Container.test.js +314 -345
- package/dist/components/FormComponent/FormComponent.js +69 -72
- package/dist/components/FormComponent/FormComponent.test.js +353 -414
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- 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 +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- 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 +65 -80
- package/dist/components/FormPage/FormPage.test.js +127 -163
- package/dist/components/FormRenderer/FormRenderer.js +143 -179
- package/dist/components/FormRenderer/FormRenderer.test.js +730 -1115
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- 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 +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +16 -20
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +17 -22
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +3 -5
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +5 -7
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -24
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- 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 +103 -97
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +62 -60
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +71 -78
- package/dist/components/FormRenderer/helpers/index.js +2 -4
- package/dist/components/FormRenderer/onCYAAction.js +59 -51
- package/dist/components/FormRenderer/onCYAAction.test.js +164 -152
- package/dist/components/FormRenderer/onPageAction.js +44 -47
- package/dist/components/FormRenderer/onPageAction.test.js +223 -213
- package/dist/components/FormRenderer/onTaskAction.js +9 -13
- package/dist/components/FormRenderer/onTaskAction.test.js +93 -88
- package/dist/components/PageActions/ActionButton.js +12 -15
- package/dist/components/PageActions/ActionButton.test.js +56 -78
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +86 -115
- package/dist/components/SummaryList/GroupAction.js +9 -17
- package/dist/components/SummaryList/GroupAction.test.js +37 -33
- package/dist/components/SummaryList/RowAction.js +11 -16
- package/dist/components/SummaryList/RowAction.test.js +37 -33
- package/dist/components/SummaryList/SummaryList.js +21 -26
- package/dist/components/SummaryList/SummaryList.test.js +143 -166
- package/dist/components/SummaryList/SummaryListHeadingRow.js +6 -4
- package/dist/components/SummaryList/SummaryListRow.js +6 -4
- package/dist/components/SummaryList/SummaryListTitleRow.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- 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 +19 -29
- package/dist/components/TaskList/Task.test.js +83 -76
- package/dist/components/TaskList/TaskList.js +45 -71
- package/dist/components/TaskList/TaskList.test.js +113 -111
- package/dist/components/TaskList/TaskState.js +7 -5
- package/dist/components/TaskList/TaskState.test.js +52 -45
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +57 -80
- package/dist/context/HooksContext/HooksContext.test.js +26 -35
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +43 -94
- package/dist/context/ValidationContext/ValidationContext.test.js +56 -68
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +9 -10
- package/dist/hooks/useAxios.js +14 -40
- package/dist/hooks/useGetRequest.js +61 -97
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +26 -39
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +13 -14
- 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 +44 -38
- package/dist/models/TaskStates.js +29 -28
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +52 -54
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +15 -25
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +33 -35
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -31
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +42 -44
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +18 -24
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +15 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +33 -36
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +58 -61
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +83 -89
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +164 -138
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +25 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +103 -97
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +13 -18
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +70 -76
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +11 -11
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +7 -7
- 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 +17 -18
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +18 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +55 -26
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getErrorsForCollection.js +24 -24
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +20 -22
- package/dist/utils/CollectionPage/getQuickEditPage.js +36 -28
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +26 -45
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +31 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +20 -20
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +4 -6
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
- package/dist/utils/Component/addShowWhen.js +4 -8
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +27 -32
- package/dist/utils/Component/cleanAttributes.js +10 -13
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +5 -5
- package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
- package/dist/utils/Component/getComponent.js +88 -94
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +18 -17
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +46 -59
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +39 -48
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +23 -33
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +20 -18
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +20 -25
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +9 -8
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +22 -26
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +155 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +17 -15
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +57 -72
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +17 -22
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +31 -38
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +20 -29
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +9 -8
- package/dist/utils/Component/getDefaultValue.js +6 -8
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +22 -21
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +1 -1
- package/dist/utils/Component/optionIsSelected.test.js +9 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +27 -29
- 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 +16 -25
- 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 +13 -18
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +3 -5
- package/dist/utils/Container/getEditableComponents.test.js +43 -45
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +16 -20
- package/dist/utils/Container/setupNesting.test.js +27 -30
- package/dist/utils/Container/showContainer.js +3 -7
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +38 -48
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +18 -26
- package/dist/utils/Data/getAutocompleteSource.test.js +80 -86
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +24 -30
- package/dist/utils/Data/getOptions.test.js +27 -27
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +84 -80
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/nestInRefdataOptions.js +9 -16
- package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
- package/dist/utils/Data/refDataToOptions.js +10 -13
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +13 -21
- package/dist/utils/Data/setupFormData.test.js +51 -50
- package/dist/utils/Data/setupRefDataUrlForComponent.js +20 -26
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +5 -9
- package/dist/utils/FormPage/applyConditionalProperties.test.js +15 -18
- package/dist/utils/FormPage/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- package/dist/utils/FormPage/getFormPage.js +15 -16
- package/dist/utils/FormPage/getFormPage.test.js +47 -46
- package/dist/utils/FormPage/getFormPages.js +7 -12
- package/dist/utils/FormPage/getFormPages.test.js +20 -23
- package/dist/utils/FormPage/getPageActions.js +9 -15
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +2 -4
- package/dist/utils/FormPage/showFormPage.js +3 -7
- 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 +21 -28
- package/dist/utils/FormPage/useComponent.test.js +77 -79
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +5 -6
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +6 -8
- package/dist/utils/Format/formatDataForForm.test.js +13 -16
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +28 -31
- 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 +24 -16
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +14 -16
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +68 -34
- 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 -52
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +22 -20
- package/dist/utils/Operate/runPageOperations.js +7 -7
- package/dist/utils/Operate/runPageOperations.test.js +35 -36
- 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 +21 -27
- 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 +7 -11
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -41
- 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 +8 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +64 -32
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +14 -16
- 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 +3 -4
- 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 +28 -26
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +19 -25
- package/dist/utils/Validate/validateCollection.test.js +74 -66
- package/dist/utils/Validate/validateComponent.js +17 -15
- package/dist/utils/Validate/validateComponent.test.js +167 -146
- package/dist/utils/Validate/validateContainer.js +15 -20
- package/dist/utils/Validate/validateContainer.test.js +58 -52
- package/dist/utils/Validate/validateDate.js +15 -21
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +6 -8
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +19 -22
- package/dist/utils/Validate/validatePage.test.js +215 -203
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +11 -18
- package/dist/utils/Validate/validateTime.test.js +16 -16
- package/dist/utils/index.js +7 -9
- package/package.json +2 -2
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-data.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/component-used-in-multiple-pages-form.json +0 -61
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-after.json +0 -429
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-before.json +0 -449
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-form.json +0 -15219
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-after.json +0 -516
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-before.json +0 -593
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab2-form.json +0 -15219
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-after.json +0 -84
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-before.json +0 -98
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-form.json +0 -9158
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collection-data-removed.json +0 -4
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-collections.json +0 -8
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-components.json +0 -5
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-entire-collection-removed.json +0 -3
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-component-removed.json +0 -10
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/data-with-nested-components.json +0 -11
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-for-nested-components.json +0 -96
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections-delete-entire.json +0 -47
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-collections.json +0 -46
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/form-with-components.json +0 -48
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test.json +0 -1605
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test2.json +0 -205
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +0 -206
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +0 -143
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +0 -26
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.test.js +0 -56
|
@@ -4,8 +4,8 @@ var _meetsCondition = _interopRequireDefault(require("./meetsCondition"));
|
|
|
4
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
5
|
// Local imports
|
|
6
6
|
|
|
7
|
-
describe('utils.Condition.meetsCondition',
|
|
8
|
-
|
|
7
|
+
describe('utils.Condition.meetsCondition', () => {
|
|
8
|
+
const getCondition = (operator, val) => {
|
|
9
9
|
if (['in', 'nin'].includes(operator)) {
|
|
10
10
|
return {
|
|
11
11
|
op: operator,
|
|
@@ -17,684 +17,684 @@ describe('utils.Condition.meetsCondition', function () {
|
|
|
17
17
|
value: val
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
describe('equality operators',
|
|
22
|
-
['eq', '='].forEach(
|
|
23
|
-
describe("operator ".concat(op),
|
|
20
|
+
const TEST_VALUES = ['a', 'b', 3, 4, null, undefined, true, false, 0];
|
|
21
|
+
describe('equality operators', () => {
|
|
22
|
+
['eq', '='].forEach(op => {
|
|
23
|
+
describe("operator ".concat(op), () => {
|
|
24
24
|
// Should match...
|
|
25
|
-
it('should match two nulls',
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
it('should match two nulls', () => {
|
|
26
|
+
const VALUE = null;
|
|
27
|
+
const CONDITION = getCondition(op, null);
|
|
28
28
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
29
29
|
});
|
|
30
|
-
it('should match two undefineds',
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
it('should match two undefineds', () => {
|
|
31
|
+
const VALUE = undefined;
|
|
32
|
+
const CONDITION = getCondition(op, undefined);
|
|
33
33
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
34
34
|
});
|
|
35
|
-
it('should match two identical strings',
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
it('should match two identical strings', () => {
|
|
36
|
+
const VALUE = 'value';
|
|
37
|
+
const CONDITION = getCondition(op, 'value');
|
|
38
38
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
39
39
|
});
|
|
40
|
-
it('should match two empty strings',
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
it('should match two empty strings', () => {
|
|
41
|
+
const VALUE = '';
|
|
42
|
+
const CONDITION = getCondition(op, '');
|
|
43
43
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
44
44
|
});
|
|
45
|
-
it('should match two identical numbers',
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
it('should match two identical numbers', () => {
|
|
46
|
+
const VALUE = 3;
|
|
47
|
+
const CONDITION = getCondition(op, 3);
|
|
48
48
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
49
49
|
});
|
|
50
|
-
it('should match two zeroes',
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
it('should match two zeroes', () => {
|
|
51
|
+
const VALUE = 0;
|
|
52
|
+
const CONDITION = getCondition(op, 0);
|
|
53
53
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
54
54
|
});
|
|
55
|
-
it('should match two boolean trues',
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
it('should match two boolean trues', () => {
|
|
56
|
+
const VALUE = true;
|
|
57
|
+
const CONDITION = getCondition(op, true);
|
|
58
58
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
59
59
|
});
|
|
60
|
-
it('should match two boolean falses',
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
it('should match two boolean falses', () => {
|
|
61
|
+
const VALUE = false;
|
|
62
|
+
const CONDITION = getCondition(op, false);
|
|
63
63
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
64
64
|
});
|
|
65
|
-
it('should match environmentContext value with data object',
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
it('should match environmentContext value with data object', () => {
|
|
66
|
+
const VALUE = 'Bob';
|
|
67
|
+
const DATA = {
|
|
68
68
|
environmentContext: {
|
|
69
69
|
currentUser: 'Bob'
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
-
|
|
72
|
+
const CONDITION = getCondition(op, 'field::environmentContext.currentUser');
|
|
73
73
|
expect((0, _meetsCondition.default)(CONDITION, VALUE, DATA)).toBeTruthy();
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
// Should reject...
|
|
77
|
-
it('should reject a null and undefined',
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
it('should reject a null and undefined', () => {
|
|
78
|
+
const VALUE = null;
|
|
79
|
+
const CONDITION = getCondition(op, undefined);
|
|
80
80
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
81
81
|
});
|
|
82
|
-
it('should reject a null and empty string',
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
it('should reject a null and empty string', () => {
|
|
83
|
+
const VALUE = null;
|
|
84
|
+
const CONDITION = getCondition(op, '');
|
|
85
85
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
86
86
|
});
|
|
87
|
-
it('should reject an undefined and empty string',
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
it('should reject an undefined and empty string', () => {
|
|
88
|
+
const VALUE = undefined;
|
|
89
|
+
const CONDITION = getCondition(op, '');
|
|
90
90
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
91
91
|
});
|
|
92
|
-
it('should reject a string of just whitespace and empty string',
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
it('should reject a string of just whitespace and empty string', () => {
|
|
93
|
+
const VALUE = ' ';
|
|
94
|
+
const CONDITION = getCondition(op, '');
|
|
95
95
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
96
96
|
});
|
|
97
|
-
it("should reject the string number '3' and the number 3",
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
it("should reject the string number '3' and the number 3", () => {
|
|
98
|
+
const VALUE = '3';
|
|
99
|
+
const CONDITION = getCondition(op, 3);
|
|
100
100
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
101
101
|
});
|
|
102
|
-
it('should reject a boolean true and the number 1',
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
it('should reject a boolean true and the number 1', () => {
|
|
103
|
+
const VALUE = true;
|
|
104
|
+
const CONDITION = getCondition(op, 1);
|
|
105
105
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
106
106
|
});
|
|
107
|
-
it('should reject a boolean false and a zero',
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
it('should reject a boolean false and a zero', () => {
|
|
108
|
+
const VALUE = false;
|
|
109
|
+
const CONDITION = getCondition(op, 0);
|
|
110
110
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
|
-
describe('inequality operators',
|
|
116
|
-
['ne', 'neq', '!=', '<>'].forEach(
|
|
117
|
-
describe("operator ".concat(op),
|
|
115
|
+
describe('inequality operators', () => {
|
|
116
|
+
['ne', 'neq', '!=', '<>'].forEach(op => {
|
|
117
|
+
describe("operator ".concat(op), () => {
|
|
118
118
|
// Should reject...
|
|
119
|
-
it('should reject two nulls',
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
it('should reject two nulls', () => {
|
|
120
|
+
const VALUE = null;
|
|
121
|
+
const CONDITION = getCondition(op, null);
|
|
122
122
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
123
123
|
});
|
|
124
|
-
it('should reject two undefineds',
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
it('should reject two undefineds', () => {
|
|
125
|
+
const VALUE = undefined;
|
|
126
|
+
const CONDITION = getCondition(op, undefined);
|
|
127
127
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
128
128
|
});
|
|
129
|
-
it('should reject two identical strings',
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
it('should reject two identical strings', () => {
|
|
130
|
+
const VALUE = 'value';
|
|
131
|
+
const CONDITION = getCondition(op, 'value');
|
|
132
132
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
133
133
|
});
|
|
134
|
-
it('should reject two empty strings',
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
it('should reject two empty strings', () => {
|
|
135
|
+
const VALUE = '';
|
|
136
|
+
const CONDITION = getCondition(op, '');
|
|
137
137
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
138
138
|
});
|
|
139
|
-
it('should reject two identical numbers',
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
it('should reject two identical numbers', () => {
|
|
140
|
+
const VALUE = 3;
|
|
141
|
+
const CONDITION = getCondition(op, 3);
|
|
142
142
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
143
143
|
});
|
|
144
|
-
it('should reject two zeroes',
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
it('should reject two zeroes', () => {
|
|
145
|
+
const VALUE = 0;
|
|
146
|
+
const CONDITION = getCondition(op, 0);
|
|
147
147
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
148
148
|
});
|
|
149
|
-
it('should reject two boolean trues',
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
it('should reject two boolean trues', () => {
|
|
150
|
+
const VALUE = true;
|
|
151
|
+
const CONDITION = getCondition(op, true);
|
|
152
152
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
153
153
|
});
|
|
154
|
-
it('should reject two boolean falses',
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
it('should reject two boolean falses', () => {
|
|
155
|
+
const VALUE = false;
|
|
156
|
+
const CONDITION = getCondition(op, false);
|
|
157
157
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
158
158
|
});
|
|
159
|
-
it('should reject environmentContext value with data object',
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
it('should reject environmentContext value with data object', () => {
|
|
160
|
+
const VALUE = 'Bob';
|
|
161
|
+
const DATA = {
|
|
162
162
|
environmentContext: {
|
|
163
163
|
currentUser: 'Bob'
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
|
|
166
|
+
const CONDITION = getCondition(op, 'field::environmentContext.currentUser');
|
|
167
167
|
expect((0, _meetsCondition.default)(CONDITION, VALUE, DATA)).toBeFalsy();
|
|
168
168
|
});
|
|
169
169
|
|
|
170
170
|
// Should match...
|
|
171
|
-
it('should match a null and undefined',
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
it('should match a null and undefined', () => {
|
|
172
|
+
const VALUE = null;
|
|
173
|
+
const CONDITION = getCondition(op, undefined);
|
|
174
174
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
175
175
|
});
|
|
176
|
-
it('should match a null and empty string',
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
it('should match a null and empty string', () => {
|
|
177
|
+
const VALUE = null;
|
|
178
|
+
const CONDITION = getCondition(op, '');
|
|
179
179
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
180
180
|
});
|
|
181
|
-
it('should match an undefined and empty string',
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
it('should match an undefined and empty string', () => {
|
|
182
|
+
const VALUE = undefined;
|
|
183
|
+
const CONDITION = getCondition(op, '');
|
|
184
184
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
185
185
|
});
|
|
186
|
-
it('should match a string of just whitespace and empty string',
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
it('should match a string of just whitespace and empty string', () => {
|
|
187
|
+
const VALUE = ' ';
|
|
188
|
+
const CONDITION = getCondition(op, '');
|
|
189
189
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
190
190
|
});
|
|
191
|
-
it("should match the string number '3' and the number 3",
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
it("should match the string number '3' and the number 3", () => {
|
|
192
|
+
const VALUE = '3';
|
|
193
|
+
const CONDITION = getCondition(op, 3);
|
|
194
194
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
195
195
|
});
|
|
196
|
-
it('should match a boolean true and the number 1',
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
it('should match a boolean true and the number 1', () => {
|
|
197
|
+
const VALUE = true;
|
|
198
|
+
const CONDITION = getCondition(op, 1);
|
|
199
199
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
200
200
|
});
|
|
201
|
-
it('should match a boolean false and a zero',
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
it('should match a boolean false and a zero', () => {
|
|
202
|
+
const VALUE = false;
|
|
203
|
+
const CONDITION = getCondition(op, 0);
|
|
204
204
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
207
|
});
|
|
208
208
|
});
|
|
209
|
-
describe('operator in',
|
|
210
|
-
|
|
209
|
+
describe('operator in', () => {
|
|
210
|
+
const op = 'in';
|
|
211
211
|
|
|
212
212
|
// Should match...
|
|
213
|
-
it('should match a string that is in the values array',
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
it('should match a string that is in the values array', () => {
|
|
214
|
+
const VALUE = 'alpha';
|
|
215
|
+
const CONDITION = getCondition(op, ['alpha', 'bravo', 'charlie']);
|
|
216
216
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
217
217
|
});
|
|
218
|
-
it('should match a number that is in the values array',
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
it('should match a number that is in the values array', () => {
|
|
219
|
+
const VALUE = 4;
|
|
220
|
+
const CONDITION = getCondition(op, ['alpha', 'bravo', 'charlie', 4]);
|
|
221
221
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
222
222
|
});
|
|
223
223
|
|
|
224
224
|
// Should reject...
|
|
225
|
-
it('should reject a string that is missing from the values array',
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
it('should reject a string that is missing from the values array', () => {
|
|
226
|
+
const VALUE = 'delta';
|
|
227
|
+
const CONDITION = getCondition(op, ['alpha', 'bravo', 'charlie']);
|
|
228
228
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
229
229
|
});
|
|
230
|
-
it('should reject a number that is missing from the values array',
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
it('should reject a number that is missing from the values array', () => {
|
|
231
|
+
const VALUE = 4;
|
|
232
|
+
const CONDITION = getCondition(op, ['alpha', 'bravo', 'charlie']);
|
|
233
233
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
234
234
|
});
|
|
235
|
-
it('should reject everything when the values array is empty',
|
|
236
|
-
|
|
237
|
-
['a', 'b', 'c', 'd', 'e', 6, 7, 8, 9, 'ten'].forEach(
|
|
235
|
+
it('should reject everything when the values array is empty', () => {
|
|
236
|
+
const CONDITION = getCondition(op, []);
|
|
237
|
+
['a', 'b', 'c', 'd', 'e', 6, 7, 8, 9, 'ten'].forEach(value => {
|
|
238
238
|
expect((0, _meetsCondition.default)(CONDITION, value)).toBeFalsy();
|
|
239
239
|
});
|
|
240
240
|
});
|
|
241
|
-
it('should reject everything when the values array is null',
|
|
242
|
-
|
|
243
|
-
['a', 'b', 'c', 'd', 'e', 6, 7, 8, 9, 'ten'].forEach(
|
|
241
|
+
it('should reject everything when the values array is null', () => {
|
|
242
|
+
const CONDITION = getCondition(op, null);
|
|
243
|
+
['a', 'b', 'c', 'd', 'e', 6, 7, 8, 9, 'ten'].forEach(value => {
|
|
244
244
|
expect((0, _meetsCondition.default)(CONDITION, value)).toBeFalsy();
|
|
245
245
|
});
|
|
246
246
|
});
|
|
247
247
|
});
|
|
248
|
-
describe('operator nin',
|
|
249
|
-
|
|
248
|
+
describe('operator nin', () => {
|
|
249
|
+
const op = 'nin';
|
|
250
250
|
|
|
251
251
|
// Should reject...
|
|
252
|
-
it('should reject a string that is in the values array',
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
it('should reject a string that is in the values array', () => {
|
|
253
|
+
const VALUE = 'alpha';
|
|
254
|
+
const CONDITION = getCondition(op, ['alpha', 'bravo', 'charlie']);
|
|
255
255
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
256
256
|
});
|
|
257
|
-
it('should reject a number that is in the values array',
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
it('should reject a number that is in the values array', () => {
|
|
258
|
+
const VALUE = 4;
|
|
259
|
+
const CONDITION = getCondition(op, ['alpha', 'bravo', 'charlie', 4]);
|
|
260
260
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
261
261
|
});
|
|
262
262
|
|
|
263
263
|
// Should match...
|
|
264
|
-
it('should match a string that is missing from the values array',
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
it('should match a string that is missing from the values array', () => {
|
|
265
|
+
const VALUE = 'delta';
|
|
266
|
+
const CONDITION = getCondition(op, ['alpha', 'bravo', 'charlie']);
|
|
267
267
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
268
268
|
});
|
|
269
|
-
it('should match a number that is missing from the values array',
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
it('should match a number that is missing from the values array', () => {
|
|
270
|
+
const VALUE = 4;
|
|
271
|
+
const CONDITION = getCondition(op, ['alpha', 'bravo', 'charlie']);
|
|
272
272
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
273
273
|
});
|
|
274
|
-
it('should match anything when the values array is empty',
|
|
275
|
-
|
|
276
|
-
TEST_VALUES.forEach(
|
|
274
|
+
it('should match anything when the values array is empty', () => {
|
|
275
|
+
const CONDITION = getCondition(op, []);
|
|
276
|
+
TEST_VALUES.forEach(value => {
|
|
277
277
|
expect((0, _meetsCondition.default)(CONDITION, value)).toBeTruthy();
|
|
278
278
|
});
|
|
279
279
|
});
|
|
280
|
-
it('should match anything when the values array is null',
|
|
281
|
-
|
|
282
|
-
TEST_VALUES.forEach(
|
|
280
|
+
it('should match anything when the values array is null', () => {
|
|
281
|
+
const CONDITION = getCondition(op, null);
|
|
282
|
+
TEST_VALUES.forEach(value => {
|
|
283
283
|
expect((0, _meetsCondition.default)(CONDITION, value)).toBeTruthy();
|
|
284
284
|
});
|
|
285
285
|
});
|
|
286
286
|
});
|
|
287
|
-
describe('operator contains',
|
|
288
|
-
|
|
287
|
+
describe('operator contains', () => {
|
|
288
|
+
const op = 'contains';
|
|
289
289
|
|
|
290
290
|
// Should match...
|
|
291
|
-
it('should match a string that is in the field array',
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
291
|
+
it('should match a string that is in the field array', () => {
|
|
292
|
+
const FIELD = ['alpha', 'bravo', 'charlie'];
|
|
293
|
+
const VALUE = 'alpha';
|
|
294
|
+
const CONDITION = getCondition(op, VALUE);
|
|
295
295
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
296
296
|
});
|
|
297
|
-
it('should match a sub-string that is in the field array',
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
297
|
+
it('should match a sub-string that is in the field array', () => {
|
|
298
|
+
const FIELD = ['alpha', 'bravo', 'charlie'];
|
|
299
|
+
const VALUE = 'alp';
|
|
300
|
+
const CONDITION = getCondition(op, VALUE);
|
|
301
301
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
302
302
|
});
|
|
303
|
-
it('should match a number that is in the field array',
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
303
|
+
it('should match a number that is in the field array', () => {
|
|
304
|
+
const FIELD = [1, 2, 3];
|
|
305
|
+
const VALUE = 1;
|
|
306
|
+
const CONDITION = getCondition(op, VALUE);
|
|
307
307
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
308
308
|
});
|
|
309
|
-
it('should match a sub-string that is in the field string',
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
309
|
+
it('should match a sub-string that is in the field string', () => {
|
|
310
|
+
const FIELD = 'alphabravocharlie';
|
|
311
|
+
const VALUE = 'alpha';
|
|
312
|
+
const CONDITION = getCondition(op, VALUE);
|
|
313
313
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
314
314
|
});
|
|
315
|
-
it('should match a string that is in the field array regardless of case',
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
315
|
+
it('should match a string that is in the field array regardless of case', () => {
|
|
316
|
+
const FIELD = ['Alpha', 'bravo', 'charlie'];
|
|
317
|
+
const VALUE = 'alpha';
|
|
318
|
+
const CONDITION = getCondition(op, VALUE);
|
|
319
319
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
320
320
|
});
|
|
321
321
|
|
|
322
322
|
// Should reject...
|
|
323
|
-
it('should reject a string that is missing from the field array',
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
323
|
+
it('should reject a string that is missing from the field array', () => {
|
|
324
|
+
const FIELD = ['alpha', 'bravo', 'charlie'];
|
|
325
|
+
const VALUE = 'delta';
|
|
326
|
+
const CONDITION = getCondition(op, VALUE);
|
|
327
327
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
328
328
|
});
|
|
329
|
-
it('should reject a number that is missing from the field array',
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
329
|
+
it('should reject a number that is missing from the field array', () => {
|
|
330
|
+
const FIELD = [1, 2, 3];
|
|
331
|
+
const VALUE = 4;
|
|
332
|
+
const CONDITION = getCondition(op, VALUE);
|
|
333
333
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
334
334
|
});
|
|
335
|
-
it('should reject a substring that is missing from the field string',
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
335
|
+
it('should reject a substring that is missing from the field string', () => {
|
|
336
|
+
const FIELD = 'alphabravocharlie';
|
|
337
|
+
const VALUE = 'delta';
|
|
338
|
+
const CONDITION = getCondition(op, VALUE);
|
|
339
339
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
340
340
|
});
|
|
341
|
-
it('should reject any value when the field is an empty Array',
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
341
|
+
it('should reject any value when the field is an empty Array', () => {
|
|
342
|
+
const FIELD = [];
|
|
343
|
+
const VALUE = 'alpha';
|
|
344
|
+
const CONDITION = getCondition(op, VALUE);
|
|
345
345
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
346
346
|
});
|
|
347
|
-
it('should reject any value when the field is an empty string',
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
347
|
+
it('should reject any value when the field is an empty string', () => {
|
|
348
|
+
const FIELD = '';
|
|
349
|
+
const VALUE = 'alpha';
|
|
350
|
+
const CONDITION = getCondition(op, VALUE);
|
|
351
351
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
352
352
|
});
|
|
353
|
-
it('should reject any field when the value is null',
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
353
|
+
it('should reject any field when the value is null', () => {
|
|
354
|
+
const FIELD = ['alpha', 'bravo', 'charlie'];
|
|
355
|
+
const VALUE = null;
|
|
356
|
+
const CONDITION = getCondition(op, VALUE);
|
|
357
357
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
358
358
|
});
|
|
359
|
-
it('should reject any field when the value is undefined',
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
359
|
+
it('should reject any field when the value is undefined', () => {
|
|
360
|
+
const FIELD = ['alpha', 'bravo', 'charlie'];
|
|
361
|
+
const VALUE = undefined;
|
|
362
|
+
const CONDITION = getCondition(op, VALUE);
|
|
363
363
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
364
364
|
});
|
|
365
|
-
it('should reject any value when the field is null',
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
365
|
+
it('should reject any value when the field is null', () => {
|
|
366
|
+
const FIELD = null;
|
|
367
|
+
const VALUE = 'alpha';
|
|
368
|
+
const CONDITION = getCondition(op, VALUE);
|
|
369
369
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
370
370
|
});
|
|
371
|
-
it('should reject any value when the field is undefined',
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
371
|
+
it('should reject any value when the field is undefined', () => {
|
|
372
|
+
const FIELD = undefined;
|
|
373
|
+
const VALUE = 'alpha';
|
|
374
|
+
const CONDITION = getCondition(op, VALUE);
|
|
375
375
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
376
376
|
});
|
|
377
377
|
});
|
|
378
|
-
describe('operator !contains',
|
|
379
|
-
|
|
378
|
+
describe('operator !contains', () => {
|
|
379
|
+
const op = '!contains';
|
|
380
380
|
|
|
381
381
|
// Should match...
|
|
382
|
-
it('should match a string that is not in the field array',
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
382
|
+
it('should match a string that is not in the field array', () => {
|
|
383
|
+
const FIELD = ['alpha', 'bravo', 'charlie'];
|
|
384
|
+
const VALUE = 'delta';
|
|
385
|
+
const CONDITION = getCondition(op, VALUE);
|
|
386
386
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
387
387
|
});
|
|
388
|
-
it('should match any value if the field array is empty',
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
388
|
+
it('should match any value if the field array is empty', () => {
|
|
389
|
+
const FIELD = [];
|
|
390
|
+
const VALUE = 'alpha';
|
|
391
|
+
const CONDITION = getCondition(op, VALUE);
|
|
392
392
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
393
393
|
});
|
|
394
|
-
it('should match any field when the value is null',
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
394
|
+
it('should match any field when the value is null', () => {
|
|
395
|
+
const FIELD = ['alpha', 'bravo', 'charlie'];
|
|
396
|
+
const VALUE = null;
|
|
397
|
+
const CONDITION = getCondition(op, VALUE);
|
|
398
398
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
399
399
|
});
|
|
400
|
-
it('should match any field when the value is undefined',
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
400
|
+
it('should match any field when the value is undefined', () => {
|
|
401
|
+
const FIELD = ['alpha', 'bravo', 'charlie'];
|
|
402
|
+
const VALUE = undefined;
|
|
403
|
+
const CONDITION = getCondition(op, VALUE);
|
|
404
404
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
405
405
|
});
|
|
406
|
-
it('should match any value when the field is an empty string',
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
406
|
+
it('should match any value when the field is an empty string', () => {
|
|
407
|
+
const FIELD = '';
|
|
408
|
+
const VALUE = 'alpha';
|
|
409
|
+
const CONDITION = getCondition(op, VALUE);
|
|
410
410
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
411
411
|
});
|
|
412
|
-
it('should match a number that is missing from the field array',
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
412
|
+
it('should match a number that is missing from the field array', () => {
|
|
413
|
+
const FIELD = [1, 2, 3];
|
|
414
|
+
const VALUE = 4;
|
|
415
|
+
const CONDITION = getCondition(op, VALUE);
|
|
416
416
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
417
417
|
});
|
|
418
|
-
it('should match a substring that is missing from the field string',
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
418
|
+
it('should match a substring that is missing from the field string', () => {
|
|
419
|
+
const FIELD = 'alphabravocharlie';
|
|
420
|
+
const VALUE = 'delta';
|
|
421
|
+
const CONDITION = getCondition(op, VALUE);
|
|
422
422
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
423
423
|
});
|
|
424
|
-
it('should match any value when the field is null',
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
424
|
+
it('should match any value when the field is null', () => {
|
|
425
|
+
const FIELD = null;
|
|
426
|
+
const VALUE = 'alpha';
|
|
427
|
+
const CONDITION = getCondition(op, VALUE);
|
|
428
428
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
429
429
|
});
|
|
430
|
-
it('should match any value when the field is undefined',
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
430
|
+
it('should match any value when the field is undefined', () => {
|
|
431
|
+
const FIELD = undefined;
|
|
432
|
+
const VALUE = 'alpha';
|
|
433
|
+
const CONDITION = getCondition(op, VALUE);
|
|
434
434
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeTruthy();
|
|
435
435
|
});
|
|
436
436
|
|
|
437
437
|
// Should reject...
|
|
438
|
-
it('should reject a string that is in the field array',
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
438
|
+
it('should reject a string that is in the field array', () => {
|
|
439
|
+
const FIELD = ['alpha', 'bravo', 'charlie'];
|
|
440
|
+
const VALUE = 'alpha';
|
|
441
|
+
const CONDITION = getCondition(op, VALUE);
|
|
442
442
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
443
443
|
});
|
|
444
|
-
it('should reject a sub-string that is in the field array',
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
444
|
+
it('should reject a sub-string that is in the field array', () => {
|
|
445
|
+
const FIELD = ['alpha', 'bravo', 'charlie'];
|
|
446
|
+
const VALUE = 'alp';
|
|
447
|
+
const CONDITION = getCondition(op, VALUE);
|
|
448
448
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
449
449
|
});
|
|
450
|
-
it('should reject a number that is in the field array',
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
450
|
+
it('should reject a number that is in the field array', () => {
|
|
451
|
+
const FIELD = [1, 2, 3];
|
|
452
|
+
const VALUE = 1;
|
|
453
|
+
const CONDITION = getCondition(op, VALUE);
|
|
454
454
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
455
455
|
});
|
|
456
|
-
it('should reject a sub-string that is in the field string',
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
456
|
+
it('should reject a sub-string that is in the field string', () => {
|
|
457
|
+
const FIELD = 'alphabravocharlie';
|
|
458
|
+
const VALUE = 'alpha';
|
|
459
|
+
const CONDITION = getCondition(op, VALUE);
|
|
460
460
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
461
461
|
});
|
|
462
|
-
it('should reject a string that is in the field array regardless of case',
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
462
|
+
it('should reject a string that is in the field array regardless of case', () => {
|
|
463
|
+
const FIELD = ['Alpha', 'bravo', 'charlie'];
|
|
464
|
+
const VALUE = 'alpha';
|
|
465
|
+
const CONDITION = getCondition(op, VALUE);
|
|
466
466
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
467
467
|
});
|
|
468
468
|
});
|
|
469
|
-
describe('numerical operators',
|
|
470
|
-
it('less than should reject when value is null',
|
|
471
|
-
|
|
469
|
+
describe('numerical operators', () => {
|
|
470
|
+
it('less than should reject when value is null', () => {
|
|
471
|
+
const CONDITION = {
|
|
472
472
|
op: '<',
|
|
473
473
|
value: '100'
|
|
474
474
|
};
|
|
475
475
|
expect((0, _meetsCondition.default)(CONDITION, null)).toBeFalsy();
|
|
476
476
|
});
|
|
477
|
-
it('less than should reject when condition.value is null',
|
|
478
|
-
|
|
477
|
+
it('less than should reject when condition.value is null', () => {
|
|
478
|
+
const CONDITION = {
|
|
479
479
|
op: '<',
|
|
480
480
|
value: null
|
|
481
481
|
};
|
|
482
482
|
expect((0, _meetsCondition.default)(CONDITION, '100')).toBeFalsy();
|
|
483
483
|
});
|
|
484
|
-
it('less than should reject when condition.value and value are null',
|
|
485
|
-
|
|
484
|
+
it('less than should reject when condition.value and value are null', () => {
|
|
485
|
+
const CONDITION = {
|
|
486
486
|
op: '<',
|
|
487
487
|
value: null
|
|
488
488
|
};
|
|
489
489
|
expect((0, _meetsCondition.default)(CONDITION, null)).toBeFalsy();
|
|
490
490
|
});
|
|
491
|
-
it('less than should reject when value is greater than condition.value',
|
|
492
|
-
|
|
491
|
+
it('less than should reject when value is greater than condition.value', () => {
|
|
492
|
+
const CONDITION = {
|
|
493
493
|
op: '<',
|
|
494
494
|
value: '100'
|
|
495
495
|
};
|
|
496
496
|
expect((0, _meetsCondition.default)(CONDITION, '101')).toBeFalsy();
|
|
497
497
|
});
|
|
498
|
-
it('less than should accept when value is less than condition.value',
|
|
499
|
-
|
|
498
|
+
it('less than should accept when value is less than condition.value', () => {
|
|
499
|
+
const CONDITION = {
|
|
500
500
|
op: '<',
|
|
501
501
|
value: '100'
|
|
502
502
|
};
|
|
503
503
|
expect((0, _meetsCondition.default)(CONDITION, '99')).toBeTruthy();
|
|
504
504
|
});
|
|
505
|
-
it('less than should handle values with commas in',
|
|
506
|
-
|
|
505
|
+
it('less than should handle values with commas in', () => {
|
|
506
|
+
const CONDITION = {
|
|
507
507
|
op: '<',
|
|
508
508
|
value: '10,000'
|
|
509
509
|
};
|
|
510
510
|
expect((0, _meetsCondition.default)(CONDITION, '9,999')).toBeTruthy();
|
|
511
511
|
});
|
|
512
|
-
it('greater than should reject when value is null',
|
|
513
|
-
|
|
512
|
+
it('greater than should reject when value is null', () => {
|
|
513
|
+
const CONDITION = {
|
|
514
514
|
op: '>',
|
|
515
515
|
value: '100'
|
|
516
516
|
};
|
|
517
517
|
expect((0, _meetsCondition.default)(CONDITION, null)).toBeFalsy();
|
|
518
518
|
});
|
|
519
|
-
it('greater than should reject when condition.value is null',
|
|
520
|
-
|
|
519
|
+
it('greater than should reject when condition.value is null', () => {
|
|
520
|
+
const CONDITION = {
|
|
521
521
|
op: '>',
|
|
522
522
|
value: null
|
|
523
523
|
};
|
|
524
524
|
expect((0, _meetsCondition.default)(CONDITION, '100')).toBeFalsy();
|
|
525
525
|
});
|
|
526
|
-
it('greater than should reject when condition.value and value are null',
|
|
527
|
-
|
|
526
|
+
it('greater than should reject when condition.value and value are null', () => {
|
|
527
|
+
const CONDITION = {
|
|
528
528
|
op: '>',
|
|
529
529
|
value: null
|
|
530
530
|
};
|
|
531
531
|
expect((0, _meetsCondition.default)(CONDITION, null)).toBeFalsy();
|
|
532
532
|
});
|
|
533
|
-
it('greater than should reject when value is less than condition.value',
|
|
534
|
-
|
|
533
|
+
it('greater than should reject when value is less than condition.value', () => {
|
|
534
|
+
const CONDITION = {
|
|
535
535
|
op: '>',
|
|
536
536
|
value: '100'
|
|
537
537
|
};
|
|
538
538
|
expect((0, _meetsCondition.default)(CONDITION, '99')).toBeFalsy();
|
|
539
539
|
});
|
|
540
|
-
it('greater than should accept when value is greater than condition.value',
|
|
541
|
-
|
|
540
|
+
it('greater than should accept when value is greater than condition.value', () => {
|
|
541
|
+
const CONDITION = {
|
|
542
542
|
op: '>',
|
|
543
543
|
value: '100'
|
|
544
544
|
};
|
|
545
545
|
expect((0, _meetsCondition.default)(CONDITION, '101')).toBeTruthy();
|
|
546
546
|
});
|
|
547
|
-
it('greater than should handle values with commas in',
|
|
548
|
-
|
|
547
|
+
it('greater than should handle values with commas in', () => {
|
|
548
|
+
const CONDITION = {
|
|
549
549
|
op: '>',
|
|
550
550
|
value: '10,000'
|
|
551
551
|
};
|
|
552
552
|
expect((0, _meetsCondition.default)(CONDITION, '10,000,000')).toBeTruthy();
|
|
553
553
|
});
|
|
554
554
|
});
|
|
555
|
-
describe('operator includes',
|
|
556
|
-
it('should accept a string that exists within the value',
|
|
557
|
-
|
|
558
|
-
|
|
555
|
+
describe('operator includes', () => {
|
|
556
|
+
it('should accept a string that exists within the value', () => {
|
|
557
|
+
const VALUE = ['red', 'green', 'blue'];
|
|
558
|
+
const CONDITION = {
|
|
559
559
|
op: 'includes',
|
|
560
560
|
value: 'blue'
|
|
561
561
|
};
|
|
562
562
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
563
563
|
});
|
|
564
|
-
it('should accept a number that exists within the value',
|
|
565
|
-
|
|
566
|
-
|
|
564
|
+
it('should accept a number that exists within the value', () => {
|
|
565
|
+
const VALUE = [4, 5, 6];
|
|
566
|
+
const CONDITION = {
|
|
567
567
|
op: 'includes',
|
|
568
568
|
value: 6
|
|
569
569
|
};
|
|
570
570
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
571
571
|
});
|
|
572
|
-
it('should reject a string that doesnt exist within the value',
|
|
573
|
-
|
|
574
|
-
|
|
572
|
+
it('should reject a string that doesnt exist within the value', () => {
|
|
573
|
+
const VALUE = ['red', 'green', 'blue'];
|
|
574
|
+
const CONDITION = {
|
|
575
575
|
op: 'includes',
|
|
576
576
|
value: 'purple'
|
|
577
577
|
};
|
|
578
578
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
579
579
|
});
|
|
580
|
-
it('should reject a number that doesnt exist within the value',
|
|
581
|
-
|
|
582
|
-
|
|
580
|
+
it('should reject a number that doesnt exist within the value', () => {
|
|
581
|
+
const VALUE = [4, 5, 6];
|
|
582
|
+
const CONDITION = {
|
|
583
583
|
op: 'includes',
|
|
584
584
|
value: 7
|
|
585
585
|
};
|
|
586
586
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
587
587
|
});
|
|
588
|
-
it('should reject a value that is not an array',
|
|
589
|
-
|
|
590
|
-
|
|
588
|
+
it('should reject a value that is not an array', () => {
|
|
589
|
+
const VALUE = 'badValue';
|
|
590
|
+
const CONDITION = {
|
|
591
591
|
op: 'includes',
|
|
592
592
|
value: 7
|
|
593
593
|
};
|
|
594
594
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
595
595
|
});
|
|
596
|
-
it('should reject an empty array',
|
|
597
|
-
|
|
598
|
-
|
|
596
|
+
it('should reject an empty array', () => {
|
|
597
|
+
const VALUE = [];
|
|
598
|
+
const CONDITION = {
|
|
599
599
|
op: 'includes',
|
|
600
600
|
value: 7
|
|
601
601
|
};
|
|
602
602
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
603
603
|
});
|
|
604
604
|
});
|
|
605
|
-
describe('operator !includes',
|
|
606
|
-
it('should reject a string that exists within the value',
|
|
607
|
-
|
|
608
|
-
|
|
605
|
+
describe('operator !includes', () => {
|
|
606
|
+
it('should reject a string that exists within the value', () => {
|
|
607
|
+
const VALUE = ['red', 'green', 'blue'];
|
|
608
|
+
const CONDITION = {
|
|
609
609
|
op: '!includes',
|
|
610
610
|
value: 'blue'
|
|
611
611
|
};
|
|
612
612
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
613
613
|
});
|
|
614
|
-
it('should reject a number that exists within the value',
|
|
615
|
-
|
|
616
|
-
|
|
614
|
+
it('should reject a number that exists within the value', () => {
|
|
615
|
+
const VALUE = [4, 5, 6];
|
|
616
|
+
const CONDITION = {
|
|
617
617
|
op: '!includes',
|
|
618
618
|
value: 6
|
|
619
619
|
};
|
|
620
620
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
621
621
|
});
|
|
622
|
-
it('should accept a string that doesnt exist within the value',
|
|
623
|
-
|
|
624
|
-
|
|
622
|
+
it('should accept a string that doesnt exist within the value', () => {
|
|
623
|
+
const VALUE = ['red', 'green', 'blue'];
|
|
624
|
+
const CONDITION = {
|
|
625
625
|
op: '!includes',
|
|
626
626
|
value: 'purple'
|
|
627
627
|
};
|
|
628
628
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
629
629
|
});
|
|
630
|
-
it('should accept a number that doesnt exist within the value',
|
|
631
|
-
|
|
632
|
-
|
|
630
|
+
it('should accept a number that doesnt exist within the value', () => {
|
|
631
|
+
const VALUE = [4, 5, 6];
|
|
632
|
+
const CONDITION = {
|
|
633
633
|
op: '!includes',
|
|
634
634
|
value: 7
|
|
635
635
|
};
|
|
636
636
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
637
637
|
});
|
|
638
|
-
it('should accept a value that is not an array',
|
|
639
|
-
|
|
640
|
-
|
|
638
|
+
it('should accept a value that is not an array', () => {
|
|
639
|
+
const VALUE = 'badValue';
|
|
640
|
+
const CONDITION = {
|
|
641
641
|
op: '!includes',
|
|
642
642
|
value: 7
|
|
643
643
|
};
|
|
644
644
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
645
645
|
});
|
|
646
|
-
it('should accept an empty array',
|
|
647
|
-
|
|
648
|
-
|
|
646
|
+
it('should accept an empty array', () => {
|
|
647
|
+
const VALUE = [];
|
|
648
|
+
const CONDITION = {
|
|
649
649
|
op: '!includes',
|
|
650
650
|
value: 7
|
|
651
651
|
};
|
|
652
652
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
653
653
|
});
|
|
654
654
|
});
|
|
655
|
-
describe('operator includesObjectProp',
|
|
656
|
-
it('should accept a property that exists within one of the objects in the value',
|
|
657
|
-
|
|
655
|
+
describe('operator includesObjectProp', () => {
|
|
656
|
+
it('should accept a property that exists within one of the objects in the value', () => {
|
|
657
|
+
const VALUE = [{
|
|
658
658
|
id: 1
|
|
659
659
|
}, {
|
|
660
660
|
id: 2
|
|
661
661
|
}, {
|
|
662
662
|
id: 3
|
|
663
663
|
}];
|
|
664
|
-
|
|
664
|
+
const CONDITION = {
|
|
665
665
|
op: 'includesObjectProp',
|
|
666
666
|
key: 'id',
|
|
667
667
|
value: 2
|
|
668
668
|
};
|
|
669
669
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
670
670
|
});
|
|
671
|
-
it('should reject a property that doesnt exist within one of the objects in the value',
|
|
672
|
-
|
|
671
|
+
it('should reject a property that doesnt exist within one of the objects in the value', () => {
|
|
672
|
+
const VALUE = [{
|
|
673
673
|
id: 1
|
|
674
674
|
}, {
|
|
675
675
|
id: 2
|
|
676
676
|
}, {
|
|
677
677
|
id: 3
|
|
678
678
|
}];
|
|
679
|
-
|
|
679
|
+
const CONDITION = {
|
|
680
680
|
op: 'includesObjectProp',
|
|
681
681
|
key: 'id',
|
|
682
682
|
value: 4
|
|
683
683
|
};
|
|
684
684
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
685
685
|
});
|
|
686
|
-
it('should reject a value that is not an array',
|
|
687
|
-
|
|
688
|
-
|
|
686
|
+
it('should reject a value that is not an array', () => {
|
|
687
|
+
const VALUE = 'badValue';
|
|
688
|
+
const CONDITION = {
|
|
689
689
|
op: 'includesObjectProp',
|
|
690
690
|
key: 'id',
|
|
691
691
|
value: 7
|
|
692
692
|
};
|
|
693
693
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
694
694
|
});
|
|
695
|
-
it('should reject an empty array',
|
|
696
|
-
|
|
697
|
-
|
|
695
|
+
it('should reject an empty array', () => {
|
|
696
|
+
const VALUE = [];
|
|
697
|
+
const CONDITION = {
|
|
698
698
|
op: 'includesObjectProp',
|
|
699
699
|
key: 'id',
|
|
700
700
|
value: 7
|
|
@@ -702,49 +702,49 @@ describe('utils.Condition.meetsCondition', function () {
|
|
|
702
702
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
703
703
|
});
|
|
704
704
|
});
|
|
705
|
-
describe('operator !includesObjectProp',
|
|
706
|
-
it('should reject a property that exists within one of the objects in the value',
|
|
707
|
-
|
|
705
|
+
describe('operator !includesObjectProp', () => {
|
|
706
|
+
it('should reject a property that exists within one of the objects in the value', () => {
|
|
707
|
+
const VALUE = [{
|
|
708
708
|
id: 1
|
|
709
709
|
}, {
|
|
710
710
|
id: 2
|
|
711
711
|
}, {
|
|
712
712
|
id: 3
|
|
713
713
|
}];
|
|
714
|
-
|
|
714
|
+
const CONDITION = {
|
|
715
715
|
op: '!includesObjectProp',
|
|
716
716
|
key: 'id',
|
|
717
717
|
value: 2
|
|
718
718
|
};
|
|
719
719
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
720
720
|
});
|
|
721
|
-
it('should accept a property that doesnt exist within one of the objects in the value',
|
|
722
|
-
|
|
721
|
+
it('should accept a property that doesnt exist within one of the objects in the value', () => {
|
|
722
|
+
const VALUE = [{
|
|
723
723
|
id: 1
|
|
724
724
|
}, {
|
|
725
725
|
id: 2
|
|
726
726
|
}, {
|
|
727
727
|
id: 3
|
|
728
728
|
}];
|
|
729
|
-
|
|
729
|
+
const CONDITION = {
|
|
730
730
|
op: '!includesObjectProp',
|
|
731
731
|
key: 'id',
|
|
732
732
|
value: 4
|
|
733
733
|
};
|
|
734
734
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
735
735
|
});
|
|
736
|
-
it('should accept a value that is not an array',
|
|
737
|
-
|
|
738
|
-
|
|
736
|
+
it('should accept a value that is not an array', () => {
|
|
737
|
+
const VALUE = 'badValue';
|
|
738
|
+
const CONDITION = {
|
|
739
739
|
op: '!includesObjectProp',
|
|
740
740
|
key: 'id',
|
|
741
741
|
value: 7
|
|
742
742
|
};
|
|
743
743
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
744
744
|
});
|
|
745
|
-
it('should accept an empty array',
|
|
746
|
-
|
|
747
|
-
|
|
745
|
+
it('should accept an empty array', () => {
|
|
746
|
+
const VALUE = [];
|
|
747
|
+
const CONDITION = {
|
|
748
748
|
op: '!includesObjectProp',
|
|
749
749
|
key: 'id',
|
|
750
750
|
value: 7
|
|
@@ -752,124 +752,124 @@ describe('utils.Condition.meetsCondition', function () {
|
|
|
752
752
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
753
753
|
});
|
|
754
754
|
});
|
|
755
|
-
describe('operator includesAllOf',
|
|
756
|
-
it('should reject when value is not an array',
|
|
757
|
-
|
|
758
|
-
|
|
755
|
+
describe('operator includesAllOf', () => {
|
|
756
|
+
it('should reject when value is not an array', () => {
|
|
757
|
+
const VALUE = 'Not an array';
|
|
758
|
+
const CONDITION = {
|
|
759
759
|
op: 'includesAllOf',
|
|
760
760
|
values: ['a', 'c']
|
|
761
761
|
};
|
|
762
762
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
763
763
|
});
|
|
764
|
-
it('should reject when value is an empty array',
|
|
765
|
-
|
|
766
|
-
|
|
764
|
+
it('should reject when value is an empty array', () => {
|
|
765
|
+
const VALUE = [];
|
|
766
|
+
const CONDITION = {
|
|
767
767
|
op: 'includesAllOf',
|
|
768
768
|
values: ['a', 'c']
|
|
769
769
|
};
|
|
770
770
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
771
771
|
});
|
|
772
|
-
it('should accept when the list of values is an empty array',
|
|
773
|
-
|
|
774
|
-
|
|
772
|
+
it('should accept when the list of values is an empty array', () => {
|
|
773
|
+
const VALUE = ['a', 'b', 'c'];
|
|
774
|
+
const CONDITION = {
|
|
775
775
|
op: 'includesAllOf',
|
|
776
776
|
values: []
|
|
777
777
|
};
|
|
778
778
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
779
779
|
});
|
|
780
|
-
it('should accept a list of values that are all in field',
|
|
781
|
-
|
|
782
|
-
|
|
780
|
+
it('should accept a list of values that are all in field', () => {
|
|
781
|
+
const VALUE = ['a', 'b', 'c'];
|
|
782
|
+
const CONDITION = {
|
|
783
783
|
op: 'includesAllOf',
|
|
784
784
|
values: ['a', 'c']
|
|
785
785
|
};
|
|
786
786
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
787
787
|
});
|
|
788
|
-
it('should reject a list of values if any are missing from field',
|
|
789
|
-
|
|
790
|
-
|
|
788
|
+
it('should reject a list of values if any are missing from field', () => {
|
|
789
|
+
const VALUE = ['a', 'b', 'c'];
|
|
790
|
+
const CONDITION = {
|
|
791
791
|
op: 'includesAllOf',
|
|
792
792
|
values: ['a', 'd']
|
|
793
793
|
};
|
|
794
794
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
795
795
|
});
|
|
796
796
|
});
|
|
797
|
-
describe('operator !includesAllOf',
|
|
798
|
-
it('should accept when value is not an array',
|
|
799
|
-
|
|
800
|
-
|
|
797
|
+
describe('operator !includesAllOf', () => {
|
|
798
|
+
it('should accept when value is not an array', () => {
|
|
799
|
+
const VALUE = 'Not an array';
|
|
800
|
+
const CONDITION = {
|
|
801
801
|
op: '!includesAllOf',
|
|
802
802
|
values: ['a', 'c']
|
|
803
803
|
};
|
|
804
804
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
805
805
|
});
|
|
806
|
-
it('should accept when value is an empty array',
|
|
807
|
-
|
|
808
|
-
|
|
806
|
+
it('should accept when value is an empty array', () => {
|
|
807
|
+
const VALUE = [];
|
|
808
|
+
const CONDITION = {
|
|
809
809
|
op: '!includesAllOf',
|
|
810
810
|
values: ['a', 'c']
|
|
811
811
|
};
|
|
812
812
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
813
813
|
});
|
|
814
|
-
it('should reject when the list of values is an empty array',
|
|
815
|
-
|
|
816
|
-
|
|
814
|
+
it('should reject when the list of values is an empty array', () => {
|
|
815
|
+
const VALUE = ['a', 'b', 'c'];
|
|
816
|
+
const CONDITION = {
|
|
817
817
|
op: '!includesAllOf',
|
|
818
818
|
values: []
|
|
819
819
|
};
|
|
820
820
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
821
821
|
});
|
|
822
|
-
it('should reject a list of values that are all in value',
|
|
823
|
-
|
|
824
|
-
|
|
822
|
+
it('should reject a list of values that are all in value', () => {
|
|
823
|
+
const VALUE = ['a', 'b', 'c'];
|
|
824
|
+
const CONDITION = {
|
|
825
825
|
op: '!includesAllOf',
|
|
826
826
|
values: ['a', 'c']
|
|
827
827
|
};
|
|
828
828
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeFalsy();
|
|
829
829
|
});
|
|
830
|
-
it('should accept a list of values if any are missing from value',
|
|
831
|
-
|
|
832
|
-
|
|
830
|
+
it('should accept a list of values if any are missing from value', () => {
|
|
831
|
+
const VALUE = ['a', 'b', 'c'];
|
|
832
|
+
const CONDITION = {
|
|
833
833
|
op: '!includesAllOf',
|
|
834
834
|
values: ['a', 'd']
|
|
835
835
|
};
|
|
836
836
|
expect((0, _meetsCondition.default)(CONDITION, VALUE)).toBeTruthy();
|
|
837
837
|
});
|
|
838
838
|
});
|
|
839
|
-
describe('unknown operator',
|
|
840
|
-
|
|
841
|
-
it('should reject anything regardless of the value',
|
|
842
|
-
|
|
843
|
-
TEST_VALUES.forEach(
|
|
839
|
+
describe('unknown operator', () => {
|
|
840
|
+
const op = 'definitely_not_a_real_operator';
|
|
841
|
+
it('should reject anything regardless of the value', () => {
|
|
842
|
+
const CONDITION = getCondition(op, 'a');
|
|
843
|
+
TEST_VALUES.forEach(value => {
|
|
844
844
|
expect((0, _meetsCondition.default)(CONDITION, value)).toBeFalsy();
|
|
845
845
|
});
|
|
846
846
|
});
|
|
847
|
-
it('should accept anything even with a null value',
|
|
848
|
-
|
|
849
|
-
TEST_VALUES.forEach(
|
|
847
|
+
it('should accept anything even with a null value', () => {
|
|
848
|
+
const CONDITION = getCondition(op, null);
|
|
849
|
+
TEST_VALUES.forEach(value => {
|
|
850
850
|
expect((0, _meetsCondition.default)(CONDITION, value)).toBeFalsy();
|
|
851
851
|
});
|
|
852
852
|
});
|
|
853
|
-
it('should accept anything even with a undefined value',
|
|
854
|
-
|
|
855
|
-
TEST_VALUES.forEach(
|
|
853
|
+
it('should accept anything even with a undefined value', () => {
|
|
854
|
+
const CONDITION = getCondition(op, null);
|
|
855
|
+
TEST_VALUES.forEach(value => {
|
|
856
856
|
expect((0, _meetsCondition.default)(CONDITION, value)).toBeFalsy();
|
|
857
857
|
});
|
|
858
858
|
});
|
|
859
859
|
});
|
|
860
|
-
describe('invalid condition',
|
|
861
|
-
it('should accept anything when the condition is null',
|
|
862
|
-
TEST_VALUES.forEach(
|
|
860
|
+
describe('invalid condition', () => {
|
|
861
|
+
it('should accept anything when the condition is null', () => {
|
|
862
|
+
TEST_VALUES.forEach(value => {
|
|
863
863
|
expect((0, _meetsCondition.default)(null, value)).toBeTruthy();
|
|
864
864
|
});
|
|
865
865
|
});
|
|
866
|
-
it('should accept anything when the condition is undefined',
|
|
867
|
-
TEST_VALUES.forEach(
|
|
866
|
+
it('should accept anything when the condition is undefined', () => {
|
|
867
|
+
TEST_VALUES.forEach(value => {
|
|
868
868
|
expect((0, _meetsCondition.default)(undefined, value)).toBeTruthy();
|
|
869
869
|
});
|
|
870
870
|
});
|
|
871
|
-
it('should accept anything when the condition is not an object',
|
|
872
|
-
TEST_VALUES.forEach(
|
|
871
|
+
it('should accept anything when the condition is not an object', () => {
|
|
872
|
+
TEST_VALUES.forEach(value => {
|
|
873
873
|
expect((0, _meetsCondition.default)('condition', value)).toBeTruthy();
|
|
874
874
|
});
|
|
875
875
|
});
|