@webiny/db-utils 6.6.0-alpha.0 → 6.6.0-alpha.10
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/package.json +13 -8
- package/{dist/valueFilter → valueFilter}/filters/ContainsFilter.js +5 -2
- package/valueFilter/filters/ContainsFilter.js.map +1 -0
- package/{dist/valueFilter → valueFilter}/filters/EqFilter.js +1 -1
- package/{dist/valueFilter → valueFilter}/filters/EqFilter.js.map +1 -1
- package/__tests__/valueFilter/__mocks/registry.ts +0 -8
- package/__tests__/valueFilter/andIn.test.ts +0 -56
- package/__tests__/valueFilter/between.test.ts +0 -62
- package/__tests__/valueFilter/contains.test.ts +0 -74
- package/__tests__/valueFilter/eq.test.ts +0 -42
- package/__tests__/valueFilter/fuzzy.test.ts +0 -30
- package/__tests__/valueFilter/gt.test.ts +0 -47
- package/__tests__/valueFilter/gte.test.ts +0 -50
- package/__tests__/valueFilter/in.test.ts +0 -54
- package/__tests__/valueFilter/lt.test.ts +0 -47
- package/__tests__/valueFilter/lte.test.ts +0 -49
- package/__tests__/valueFilter/startsWith.test.ts +0 -58
- package/dist/package.json +0 -24
- package/dist/valueFilter/filters/ContainsFilter.js.map +0 -1
- package/src/index.ts +0 -4
- package/src/valueFilter/ValueFilterRegistry.ts +0 -21
- package/src/valueFilter/abstractions/ValueFilter.ts +0 -29
- package/src/valueFilter/abstractions/ValueFilterRegistry.ts +0 -15
- package/src/valueFilter/abstractions/index.ts +0 -2
- package/src/valueFilter/feature.ts +0 -31
- package/src/valueFilter/filters/AndInFilter.ts +0 -36
- package/src/valueFilter/filters/BetweenFilter.ts +0 -37
- package/src/valueFilter/filters/ContainsFilter.ts +0 -87
- package/src/valueFilter/filters/EqFilter.ts +0 -32
- package/src/valueFilter/filters/FuzzyFilter.ts +0 -42
- package/src/valueFilter/filters/GtFilter.ts +0 -22
- package/src/valueFilter/filters/GteFilter.ts +0 -22
- package/src/valueFilter/filters/InFilter.ts +0 -36
- package/src/valueFilter/filters/LtFilter.ts +0 -22
- package/src/valueFilter/filters/LteFilter.ts +0 -22
- package/src/valueFilter/filters/StartsWithFilter.ts +0 -44
- package/src/valueFilter/index.ts +0 -3
- package/tsconfig.build.json +0 -21
- package/tsconfig.json +0 -18
- package/vitest.config.ts +0 -5
- package/webiny.config.js +0 -8
- /package/{dist/LICENSE → LICENSE} +0 -0
- /package/{dist/README.md → README.md} +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/valueFilter → valueFilter}/ValueFilterRegistry.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/ValueFilterRegistry.js +0 -0
- /package/{dist/valueFilter → valueFilter}/ValueFilterRegistry.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/abstractions/ValueFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/abstractions/ValueFilter.js +0 -0
- /package/{dist/valueFilter → valueFilter}/abstractions/ValueFilter.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/abstractions/ValueFilterRegistry.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/abstractions/ValueFilterRegistry.js +0 -0
- /package/{dist/valueFilter → valueFilter}/abstractions/ValueFilterRegistry.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/abstractions/index.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/abstractions/index.js +0 -0
- /package/{dist/valueFilter → valueFilter}/feature.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/feature.js +0 -0
- /package/{dist/valueFilter → valueFilter}/feature.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/AndInFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/AndInFilter.js +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/AndInFilter.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/BetweenFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/BetweenFilter.js +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/BetweenFilter.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/ContainsFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/EqFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/FuzzyFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/FuzzyFilter.js +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/FuzzyFilter.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/GtFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/GtFilter.js +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/GtFilter.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/GteFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/GteFilter.js +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/GteFilter.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/InFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/InFilter.js +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/InFilter.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/LtFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/LtFilter.js +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/LtFilter.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/LteFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/LteFilter.js +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/LteFilter.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/StartsWithFilter.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/StartsWithFilter.js +0 -0
- /package/{dist/valueFilter → valueFilter}/filters/StartsWithFilter.js.map +0 -0
- /package/{dist/valueFilter → valueFilter}/index.d.ts +0 -0
- /package/{dist/valueFilter → valueFilter}/index.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/db-utils",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.10",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -10,15 +10,20 @@
|
|
|
10
10
|
"directory": "packages/db-utils"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webiny/error": "6.6.0-alpha.
|
|
14
|
-
"@webiny/feature": "6.6.0-alpha.
|
|
13
|
+
"@webiny/error": "6.6.0-alpha.10",
|
|
14
|
+
"@webiny/feature": "6.6.0-alpha.10",
|
|
15
15
|
"fuse.js": "7.5.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
19
|
-
"@webiny/di": "
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
18
|
+
"@webiny/build-tools": "6.6.0-alpha.10",
|
|
19
|
+
"@webiny/di": "2.0.0",
|
|
20
|
+
"typescript": "7.0.2",
|
|
21
|
+
"vitest": "5.0.5"
|
|
22
|
+
},
|
|
23
|
+
"webiny": {
|
|
24
|
+
"publishFrom": "dist"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
23
28
|
}
|
|
24
29
|
}
|
|
@@ -3,7 +3,10 @@ const createValues = (initialValue)=>{
|
|
|
3
3
|
if ("string" == typeof initialValue) return [
|
|
4
4
|
initialValue
|
|
5
5
|
];
|
|
6
|
-
if (Array.isArray(initialValue)) return initialValue.
|
|
6
|
+
if (Array.isArray(initialValue)) return initialValue.flatMap((v)=>{
|
|
7
|
+
if (null !== v && "object" == typeof v) return createValues(v);
|
|
8
|
+
return v.toString();
|
|
9
|
+
}).filter(Boolean);
|
|
7
10
|
const result = [];
|
|
8
11
|
const traverse = (node)=>{
|
|
9
12
|
if (null == node) return;
|
|
@@ -25,7 +28,7 @@ class ContainsFilterImpl {
|
|
|
25
28
|
}
|
|
26
29
|
matches({ value: initialValue, compareValue: initialCompareValue }) {
|
|
27
30
|
if (!initialValue || Array.isArray(initialValue) && 0 === initialValue.length) return false;
|
|
28
|
-
if (null == initialCompareValue) return true;
|
|
31
|
+
else if (null == initialCompareValue) return true;
|
|
29
32
|
const values = createValues(initialValue);
|
|
30
33
|
const compareValues = createCompareValues(initialCompareValue);
|
|
31
34
|
if (0 === compareValues.length) return false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valueFilter/filters/ContainsFilter.js","sources":["../../../src/valueFilter/filters/ContainsFilter.ts"],"sourcesContent":["import { ValueFilter } from \"../abstractions/ValueFilter.js\";\n\nconst createValues = (initialValue: string | string[] | object): string[] => {\n if (typeof initialValue === \"string\") {\n return [initialValue];\n }\n\n if (Array.isArray(initialValue)) {\n return initialValue\n .flatMap(v => {\n /**\n * Arrays can contain objects (e.g. searchable-json values in a multiple values object field)\n * and other arrays, at any depth, so we go through their values instead of converting them\n * to a string.\n */\n if (v !== null && typeof v === \"object\") {\n return createValues(v);\n }\n return v.toString();\n })\n .filter(Boolean);\n }\n\n const result: string[] = [];\n\n const traverse = (node: any): void => {\n if (node == null) {\n return;\n }\n if (typeof node === \"string\" || typeof node === \"number\") {\n result.push(node.toString());\n } else if (Array.isArray(node)) {\n node.forEach(traverse);\n } else if (typeof node === \"object\") {\n Object.values(node).forEach(traverse);\n }\n };\n\n traverse(initialValue);\n\n return result.filter(Boolean);\n};\n\nconst escapeRegex = (value: string): string => {\n return value.replace(/[\\\\^$.*+?()[\\]{}|/]/g, \"\\\\$&\");\n};\n\nconst createCompareValues = (value: string) => {\n return value\n .replace(/\\s+/g, \" \")\n .trim()\n .replace(/:/g, \"\")\n .split(\" \")\n .filter(val => {\n return val.length > 0;\n })\n .map(escapeRegex);\n};\n\nclass ContainsFilterImpl implements ValueFilter.Interface {\n public readonly operation = \"contains\";\n\n public is(operation: string): boolean {\n return this.operation === operation;\n }\n\n public canUse(): boolean {\n return true;\n }\n\n public matches({\n value: initialValue,\n compareValue: initialCompareValue\n }: ValueFilter.MatchesParams): ValueFilter.Result {\n if (!initialValue || (Array.isArray(initialValue) && initialValue.length === 0)) {\n return false;\n } else if (initialCompareValue === undefined || initialCompareValue === null) {\n return true;\n }\n const values = createValues(initialValue);\n const compareValues = createCompareValues(initialCompareValue);\n if (compareValues.length === 0) {\n return false;\n }\n return values.some(target => {\n return compareValues.every(compareValue => {\n return target.match(new RegExp(compareValue, \"gi\")) !== null;\n });\n });\n }\n}\n\nexport const ContainsFilter = ValueFilter.createImplementation({\n implementation: ContainsFilterImpl,\n dependencies: []\n});\n"],"names":["createValues","initialValue","Array","v","Boolean","result","traverse","node","Object","escapeRegex","value","createCompareValues","val","ContainsFilterImpl","operation","initialCompareValue","values","compareValues","target","compareValue","RegExp","ContainsFilter","ValueFilter"],"mappings":";AAEA,MAAMA,eAAe,CAACC;IAClB,IAAI,AAAwB,YAAxB,OAAOA,cACP,OAAO;QAACA;KAAa;IAGzB,IAAIC,MAAM,OAAO,CAACD,eACd,OAAOA,aACF,OAAO,CAACE,CAAAA;QAML,IAAIA,AAAM,SAANA,KAAc,AAAa,YAAb,OAAOA,GACrB,OAAOH,aAAaG;QAExB,OAAOA,EAAE,QAAQ;IACrB,GACC,MAAM,CAACC;IAGhB,MAAMC,SAAmB,EAAE;IAE3B,MAAMC,WAAW,CAACC;QACd,IAAIA,AAAQ,QAARA,MACA;QAEJ,IAAI,AAAgB,YAAhB,OAAOA,QAAqB,AAAgB,YAAhB,OAAOA,MACnCF,OAAO,IAAI,CAACE,KAAK,QAAQ;aACtB,IAAIL,MAAM,OAAO,CAACK,OACrBA,KAAK,OAAO,CAACD;aACV,IAAI,AAAgB,YAAhB,OAAOC,MACdC,OAAO,MAAM,CAACD,MAAM,OAAO,CAACD;IAEpC;IAEAA,SAASL;IAET,OAAOI,OAAO,MAAM,CAACD;AACzB;AAEA,MAAMK,cAAc,CAACC,QACVA,MAAM,OAAO,CAAC,wBAAwB;AAGjD,MAAMC,sBAAsB,CAACD,QAClBA,MACF,OAAO,CAAC,QAAQ,KAChB,IAAI,GACJ,OAAO,CAAC,MAAM,IACd,KAAK,CAAC,KACN,MAAM,CAACE,CAAAA,MACGA,IAAI,MAAM,GAAG,GAEvB,GAAG,CAACH;AAGb,MAAMI;IAGK,GAAGC,SAAiB,EAAW;QAClC,OAAO,IAAI,CAAC,SAAS,KAAKA;IAC9B;IAEO,SAAkB;QACrB,OAAO;IACX;IAEO,QAAQ,EACX,OAAOb,YAAY,EACnB,cAAcc,mBAAmB,EACT,EAAsB;QAC9C,IAAI,CAACd,gBAAiBC,MAAM,OAAO,CAACD,iBAAiBA,AAAwB,MAAxBA,aAAa,MAAM,EACpE,OAAO;aACJ,IAAIc,QAAAA,qBACP,OAAO;QAEX,MAAMC,SAAShB,aAAaC;QAC5B,MAAMgB,gBAAgBN,oBAAoBI;QAC1C,IAAIE,AAAyB,MAAzBA,cAAc,MAAM,EACpB,OAAO;QAEX,OAAOD,OAAO,IAAI,CAACE,CAAAA,SACRD,cAAc,KAAK,CAACE,CAAAA,eAChBD,AAAiD,SAAjDA,OAAO,KAAK,CAAC,IAAIE,OAAOD,cAAc;IAGzD;;aA7BgB,SAAS,GAAG;;AA8BhC;AAEO,MAAME,iBAAiBC,YAAY,oBAAoB,CAAC;IAC3D,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -8,7 +8,7 @@ class EqFilterImpl {
|
|
|
8
8
|
}
|
|
9
9
|
matches({ value, compareValue }) {
|
|
10
10
|
if (true === Array.isArray(value)) return value.some((v)=>Array.isArray(compareValue) ? compareValue.includes(v) : compareValue === v);
|
|
11
|
-
if (true === Array.isArray(compareValue)) return compareValue.every((v)=>value == v);
|
|
11
|
+
else if (true === Array.isArray(compareValue)) return compareValue.every((v)=>value == v);
|
|
12
12
|
return value == compareValue;
|
|
13
13
|
}
|
|
14
14
|
constructor(){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueFilter/filters/EqFilter.js","sources":["../../../src/valueFilter/filters/EqFilter.ts"],"sourcesContent":["import { ValueFilter } from \"../abstractions/ValueFilter.js\";\n\nclass EqFilterImpl implements ValueFilter.Interface {\n public readonly operation = \"eq\";\n\n public is(operation: string): boolean {\n return this.operation === operation;\n }\n\n public canUse(): boolean {\n return true;\n }\n\n public matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result {\n /* Possibility that either input value or one from the system is array. */\n if (Array.isArray(value) === true) {\n return value.some((v: string) => {\n return Array.isArray(compareValue) ? compareValue.includes(v) : compareValue === v;\n });\n } else if (Array.isArray(compareValue) === true) {\n return compareValue.every((v: string) => {\n return value == v;\n });\n }\n return value == compareValue;\n }\n}\n\nexport const EqFilter = ValueFilter.createImplementation({\n implementation: EqFilterImpl,\n dependencies: []\n});\n"],"names":["EqFilterImpl","operation","value","compareValue","Array","v","EqFilter","ValueFilter"],"mappings":";AAEA,MAAMA;IAGK,GAAGC,SAAiB,EAAW;QAClC,OAAO,IAAI,CAAC,SAAS,KAAKA;IAC9B;IAEO,SAAkB;QACrB,OAAO;IACX;IAEO,QAAQ,EAAEC,KAAK,EAAEC,YAAY,EAA6B,EAAsB;QAEnF,IAAIC,AAAyB,SAAzBA,MAAM,OAAO,CAACF,QACd,OAAOA,MAAM,IAAI,CAAC,CAACG,IACRD,MAAM,OAAO,CAACD,gBAAgBA,aAAa,QAAQ,CAACE,KAAKF,iBAAiBE;
|
|
1
|
+
{"version":3,"file":"valueFilter/filters/EqFilter.js","sources":["../../../src/valueFilter/filters/EqFilter.ts"],"sourcesContent":["import { ValueFilter } from \"../abstractions/ValueFilter.js\";\n\nclass EqFilterImpl implements ValueFilter.Interface {\n public readonly operation = \"eq\";\n\n public is(operation: string): boolean {\n return this.operation === operation;\n }\n\n public canUse(): boolean {\n return true;\n }\n\n public matches({ value, compareValue }: ValueFilter.MatchesParams): ValueFilter.Result {\n /* Possibility that either input value or one from the system is array. */\n if (Array.isArray(value) === true) {\n return value.some((v: string) => {\n return Array.isArray(compareValue) ? compareValue.includes(v) : compareValue === v;\n });\n } else if (Array.isArray(compareValue) === true) {\n return compareValue.every((v: string) => {\n return value == v;\n });\n }\n return value == compareValue;\n }\n}\n\nexport const EqFilter = ValueFilter.createImplementation({\n implementation: EqFilterImpl,\n dependencies: []\n});\n"],"names":["EqFilterImpl","operation","value","compareValue","Array","v","EqFilter","ValueFilter"],"mappings":";AAEA,MAAMA;IAGK,GAAGC,SAAiB,EAAW;QAClC,OAAO,IAAI,CAAC,SAAS,KAAKA;IAC9B;IAEO,SAAkB;QACrB,OAAO;IACX;IAEO,QAAQ,EAAEC,KAAK,EAAEC,YAAY,EAA6B,EAAsB;QAEnF,IAAIC,AAAyB,SAAzBA,MAAM,OAAO,CAACF,QACd,OAAOA,MAAM,IAAI,CAAC,CAACG,IACRD,MAAM,OAAO,CAACD,gBAAgBA,aAAa,QAAQ,CAACE,KAAKF,iBAAiBE;aAElF,IAAID,AAAgC,SAAhCA,MAAM,OAAO,CAACD,eACrB,OAAOA,aAAa,KAAK,CAAC,CAACE,IAChBH,SAASG;QAGxB,OAAOH,SAASC;IACpB;;aAtBgB,SAAS,GAAG;;AAuBhC;AAEO,MAAMG,WAAWC,YAAY,oBAAoB,CAAC;IACrD,gBAAgBP;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Container } from "@webiny/feature/api";
|
|
2
|
-
import { ValueFilterFeature, ValueFilterRegistry } from "~/valueFilter/index.js";
|
|
3
|
-
|
|
4
|
-
export const createValueFilterRegistry = (): ValueFilterRegistry.Interface => {
|
|
5
|
-
const container = new Container();
|
|
6
|
-
ValueFilterFeature.register(container);
|
|
7
|
-
return container.resolve(ValueFilterRegistry);
|
|
8
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { createValueFilterRegistry } from "./__mocks/registry";
|
|
3
|
-
|
|
4
|
-
describe("and_in filter", () => {
|
|
5
|
-
const registry = createValueFilterRegistry();
|
|
6
|
-
|
|
7
|
-
const getFilter = () => {
|
|
8
|
-
const filter = registry.get("and_in");
|
|
9
|
-
expect(filter).toBeDefined();
|
|
10
|
-
return filter!;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
test("target value should contain all required values", () => {
|
|
14
|
-
const filter = getFilter();
|
|
15
|
-
|
|
16
|
-
const result = filter.matches({
|
|
17
|
-
value: ["news", "webiny", "local", "global"],
|
|
18
|
-
compareValue: ["local", "webiny"]
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
expect(result).toBe(true);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("target value does not contain all required values and match fails", () => {
|
|
25
|
-
const filter = getFilter();
|
|
26
|
-
|
|
27
|
-
const result = filter.matches({
|
|
28
|
-
value: ["news", "local", "global"],
|
|
29
|
-
compareValue: ["local", "webiny"]
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
expect(result).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("must match all the given tags", () => {
|
|
36
|
-
const filter = getFilter();
|
|
37
|
-
|
|
38
|
-
const result = filter.matches({
|
|
39
|
-
value: ["tag1", "tag2"],
|
|
40
|
-
compareValue: ["tag1", "tag2"]
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
expect(result).toBe(true);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("not match because not all tags are present", () => {
|
|
47
|
-
const filter = getFilter();
|
|
48
|
-
|
|
49
|
-
const result = filter.matches({
|
|
50
|
-
value: ["tag1", "tag2"],
|
|
51
|
-
compareValue: ["tag1", "tag2", "tag3"]
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
expect(result).toBe(false);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { createValueFilterRegistry } from "./__mocks/registry";
|
|
3
|
-
|
|
4
|
-
describe("between filter", () => {
|
|
5
|
-
const registry = createValueFilterRegistry();
|
|
6
|
-
|
|
7
|
-
const getFilter = () => {
|
|
8
|
-
const filter = registry.get("between");
|
|
9
|
-
expect(filter).toBeDefined();
|
|
10
|
-
return filter!;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const betweenList: [
|
|
14
|
-
[number, [number, number]],
|
|
15
|
-
[number, [number, number]],
|
|
16
|
-
[Date, [Date, Date]],
|
|
17
|
-
[Date, [Date, Date]]
|
|
18
|
-
] = [
|
|
19
|
-
[5, [4, 6]],
|
|
20
|
-
[5, [4, 5]],
|
|
21
|
-
[
|
|
22
|
-
new Date("2021-01-02T23:23:23.000Z"),
|
|
23
|
-
[new Date("2021-01-02T23:23:22.000Z"), new Date("2021-01-02T23:23:24.000Z")]
|
|
24
|
-
],
|
|
25
|
-
[
|
|
26
|
-
new Date("2021-01-02T23:23:23.000Z"),
|
|
27
|
-
[new Date("2021-01-02T23:23:22.999Z"), new Date("2021-01-02T23:23:23.001Z")]
|
|
28
|
-
]
|
|
29
|
-
];
|
|
30
|
-
test.each(betweenList)("values should be in between", (value, compareValue) => {
|
|
31
|
-
const filter = getFilter();
|
|
32
|
-
|
|
33
|
-
const result = filter.matches({ value, compareValue });
|
|
34
|
-
|
|
35
|
-
expect(result).toBe(true);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const notBetweenList: [
|
|
39
|
-
[number, [number, number]],
|
|
40
|
-
[number, [number, number]],
|
|
41
|
-
[Date, [Date, Date]],
|
|
42
|
-
[Date, [Date, Date]]
|
|
43
|
-
] = [
|
|
44
|
-
[3, [4, 6]],
|
|
45
|
-
[8, [4, 7]],
|
|
46
|
-
[
|
|
47
|
-
new Date("2021-01-02T23:23:22.000Z"),
|
|
48
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:24.000Z")]
|
|
49
|
-
],
|
|
50
|
-
[
|
|
51
|
-
new Date("2021-01-02T23:23:22.998Z"),
|
|
52
|
-
[new Date("2021-01-02T23:23:22.999Z"), new Date("2021-01-02T23:23:23.001Z")]
|
|
53
|
-
]
|
|
54
|
-
];
|
|
55
|
-
test.each(notBetweenList)("values should not be in between", (value, compareValue) => {
|
|
56
|
-
const filter = getFilter();
|
|
57
|
-
|
|
58
|
-
const result = filter.matches({ value, compareValue });
|
|
59
|
-
|
|
60
|
-
expect(result).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { createValueFilterRegistry } from "./__mocks/registry";
|
|
3
|
-
|
|
4
|
-
describe("contains filter", () => {
|
|
5
|
-
const registry = createValueFilterRegistry();
|
|
6
|
-
|
|
7
|
-
const getFilter = () => {
|
|
8
|
-
const filter = registry.get("contains");
|
|
9
|
-
expect(filter).toBeDefined();
|
|
10
|
-
return filter!;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const containsList = [
|
|
14
|
-
["some text witH description", "wIth"],
|
|
15
|
-
["some texT witH description", "text wiTh"]
|
|
16
|
-
];
|
|
17
|
-
test.each(containsList)("value should contain - %s contains %s", (value, compareValue) => {
|
|
18
|
-
const filter = getFilter();
|
|
19
|
-
|
|
20
|
-
const result = filter.matches({ value, compareValue });
|
|
21
|
-
|
|
22
|
-
expect(result).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const regexMetacharsList = [
|
|
26
|
-
["some (text) with [brackets]", "(text)"],
|
|
27
|
-
["price is $100.00", "$100.00"],
|
|
28
|
-
["path/to/file.txt", "file.txt"],
|
|
29
|
-
["hello.*world", ".*world"],
|
|
30
|
-
["a+b=c", "a+b"]
|
|
31
|
-
];
|
|
32
|
-
test.each(regexMetacharsList)(
|
|
33
|
-
"should match literal metacharacters - %s contains %s",
|
|
34
|
-
(value, compareValue) => {
|
|
35
|
-
const filter = getFilter();
|
|
36
|
-
|
|
37
|
-
const result = filter.matches({ value, compareValue });
|
|
38
|
-
|
|
39
|
-
expect(result).toBe(true);
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const emptyCompareList = [
|
|
44
|
-
["some text", ""],
|
|
45
|
-
["some text", " "],
|
|
46
|
-
["some text", ":::"],
|
|
47
|
-
["some text", ": : :"]
|
|
48
|
-
];
|
|
49
|
-
test.each(emptyCompareList)(
|
|
50
|
-
"should not match when compareValue is empty after normalization - %s vs %s",
|
|
51
|
-
(value, compareValue) => {
|
|
52
|
-
const filter = getFilter();
|
|
53
|
-
|
|
54
|
-
const result = filter.matches({ value, compareValue });
|
|
55
|
-
|
|
56
|
-
expect(result).toBe(false);
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const notContainsList = [
|
|
61
|
-
["Some text wiTh description", "with tExta"],
|
|
62
|
-
["sOme text with description", "with soMeE"]
|
|
63
|
-
];
|
|
64
|
-
test.each(notContainsList)(
|
|
65
|
-
"value should not contain - %s not contains %s",
|
|
66
|
-
(value, compareValue) => {
|
|
67
|
-
const filter = getFilter();
|
|
68
|
-
|
|
69
|
-
const result = filter.matches({ value, compareValue });
|
|
70
|
-
|
|
71
|
-
expect(result).toBe(false);
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { createValueFilterRegistry } from "./__mocks/registry";
|
|
3
|
-
|
|
4
|
-
describe("eq filter", () => {
|
|
5
|
-
const registry = createValueFilterRegistry();
|
|
6
|
-
|
|
7
|
-
const getFilter = () => {
|
|
8
|
-
const filter = registry.get("eq");
|
|
9
|
-
expect(filter).toBeDefined();
|
|
10
|
-
return filter!;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const equalList: ([number, number] | [string, string] | [boolean, boolean])[] = [
|
|
14
|
-
[1, 1],
|
|
15
|
-
[932, 932],
|
|
16
|
-
["some text", "some text"],
|
|
17
|
-
[true, true],
|
|
18
|
-
[false, false]
|
|
19
|
-
];
|
|
20
|
-
test.each(equalList)("values should be equal - %s == %s", (value, compareValue) => {
|
|
21
|
-
const filter = getFilter();
|
|
22
|
-
|
|
23
|
-
const result = filter.matches({ value, compareValue });
|
|
24
|
-
|
|
25
|
-
expect(result).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const notEqualList: ([number, number] | [string, string] | [boolean, boolean])[] = [
|
|
29
|
-
[1, 2],
|
|
30
|
-
[932, 132],
|
|
31
|
-
["some text", "some text 2"],
|
|
32
|
-
[true, false],
|
|
33
|
-
[false, true]
|
|
34
|
-
];
|
|
35
|
-
test.each(notEqualList)("values should not be equal - %s != %s", (value, compareValue) => {
|
|
36
|
-
const filter = getFilter();
|
|
37
|
-
|
|
38
|
-
const result = filter.matches({ value, compareValue });
|
|
39
|
-
|
|
40
|
-
expect(result).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { createValueFilterRegistry } from "./__mocks/registry";
|
|
3
|
-
|
|
4
|
-
describe("fuzzy filter", () => {
|
|
5
|
-
const registry = createValueFilterRegistry();
|
|
6
|
-
|
|
7
|
-
const getFilter = () => {
|
|
8
|
-
const filter = registry.get("fuzzy");
|
|
9
|
-
expect(filter).toBeDefined();
|
|
10
|
-
return filter!;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const fuzzySearchList: [string, string, boolean][] = [
|
|
14
|
-
["Crafting a good page title for SEO", "why go serverless", false],
|
|
15
|
-
["What is Serverless and is it worth it?", "why go serverless", true],
|
|
16
|
-
["Why should you go Serverless today?", "why go serverless", true],
|
|
17
|
-
["Serverless Side Rendering — The Ultimate Guide", "why go serverless", true]
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
test.each(fuzzySearchList)(
|
|
21
|
-
`should perform fuzzy search on "%s"`,
|
|
22
|
-
(value, compareValue, expected) => {
|
|
23
|
-
const filter = getFilter();
|
|
24
|
-
|
|
25
|
-
const result = filter.matches({ value, compareValue });
|
|
26
|
-
|
|
27
|
-
expect(result).toBe(expected);
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { createValueFilterRegistry } from "./__mocks/registry";
|
|
3
|
-
|
|
4
|
-
describe("gt filter", () => {
|
|
5
|
-
const registry = createValueFilterRegistry();
|
|
6
|
-
|
|
7
|
-
const getFilter = () => {
|
|
8
|
-
const filter = registry.get("gt");
|
|
9
|
-
expect(filter).toBeDefined();
|
|
10
|
-
return filter!;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const gtList: ([number, number] | [Date, Date])[] = [
|
|
14
|
-
[2, 1],
|
|
15
|
-
[933, 932],
|
|
16
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:22.999Z")],
|
|
17
|
-
[new Date("2021-01-02T23:23:24.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
18
|
-
[new Date("2021-01-02T23:24:23.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
19
|
-
[new Date("2021-01-03T00:23:23.000Z"), new Date("2021-01-02T23:23:23.000Z")]
|
|
20
|
-
];
|
|
21
|
-
test.each(gtList)("value should be greater", (value, compareValue) => {
|
|
22
|
-
const filter = getFilter();
|
|
23
|
-
|
|
24
|
-
const result = filter.matches({ value, compareValue });
|
|
25
|
-
|
|
26
|
-
expect(result).toBe(true);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const notGtList: ([number, number] | [Date, Date])[] = [
|
|
30
|
-
[2, 3],
|
|
31
|
-
[2, 2],
|
|
32
|
-
[933, 934],
|
|
33
|
-
[933, 933],
|
|
34
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:23.001Z")],
|
|
35
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
36
|
-
[new Date("2021-01-02T23:23:24.000Z"), new Date("2021-01-02T23:24:24.000Z")],
|
|
37
|
-
[new Date("2021-01-02T23:24:23.000Z"), new Date("2021-01-03T00:24:23.000Z")],
|
|
38
|
-
[new Date("2021-01-03T00:23:23.000Z"), new Date("2021-01-04T00:23:23.000Z")]
|
|
39
|
-
];
|
|
40
|
-
test.each(notGtList)("value should not be greater", (value, compareValue) => {
|
|
41
|
-
const filter = getFilter();
|
|
42
|
-
|
|
43
|
-
const result = filter.matches({ value, compareValue });
|
|
44
|
-
|
|
45
|
-
expect(result).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { createValueFilterRegistry } from "./__mocks/registry";
|
|
3
|
-
|
|
4
|
-
describe("gte filter", () => {
|
|
5
|
-
const registry = createValueFilterRegistry();
|
|
6
|
-
|
|
7
|
-
const getFilter = () => {
|
|
8
|
-
const filter = registry.get("gte");
|
|
9
|
-
expect(filter).toBeDefined();
|
|
10
|
-
return filter!;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const gteList: ([number, number] | [Date, Date])[] = [
|
|
14
|
-
[2, 1],
|
|
15
|
-
[2, 2],
|
|
16
|
-
[933, 932],
|
|
17
|
-
[933, 933],
|
|
18
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:22.999Z")],
|
|
19
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
20
|
-
[new Date("2021-01-02T23:23:24.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
21
|
-
[new Date("2021-01-02T23:23:24.000Z"), new Date("2021-01-02T23:23:24.000Z")],
|
|
22
|
-
[new Date("2021-01-02T23:24:23.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
23
|
-
[new Date("2021-01-02T23:24:23.000Z"), new Date("2021-01-02T23:24:23.000Z")],
|
|
24
|
-
[new Date("2021-01-03T00:23:23.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
25
|
-
[new Date("2021-01-03T23:23:23.000Z"), new Date("2021-01-03T23:23:23.000Z")]
|
|
26
|
-
];
|
|
27
|
-
test.each(gteList)("value should be greater or equal", (value, compareValue) => {
|
|
28
|
-
const filter = getFilter();
|
|
29
|
-
|
|
30
|
-
const result = filter.matches({ value, compareValue });
|
|
31
|
-
|
|
32
|
-
expect(result).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const notGteList: ([number, number] | [Date, Date])[] = [
|
|
36
|
-
[2, 3],
|
|
37
|
-
[933, 934],
|
|
38
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:23.001Z")],
|
|
39
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:24.000Z")],
|
|
40
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:24:23.000Z")],
|
|
41
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-03T00:23:23.000Z")]
|
|
42
|
-
];
|
|
43
|
-
test.each(notGteList)("value should not be greater or equal", (value, compareValue) => {
|
|
44
|
-
const filter = getFilter();
|
|
45
|
-
|
|
46
|
-
const result = filter.matches({ value, compareValue });
|
|
47
|
-
|
|
48
|
-
expect(result).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { createValueFilterRegistry } from "./__mocks/registry";
|
|
3
|
-
|
|
4
|
-
describe("in filter", () => {
|
|
5
|
-
const registry = createValueFilterRegistry();
|
|
6
|
-
|
|
7
|
-
const getFilter = () => {
|
|
8
|
-
const filter = registry.get("in");
|
|
9
|
-
expect(filter).toBeDefined();
|
|
10
|
-
return filter!;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const inList: [
|
|
14
|
-
[number, [number, number, number]],
|
|
15
|
-
[number, [number, string, Date]],
|
|
16
|
-
[string, [string, number, boolean]],
|
|
17
|
-
[boolean, [boolean, boolean, string, number]],
|
|
18
|
-
[boolean, [boolean, string, Date]]
|
|
19
|
-
] = [
|
|
20
|
-
[1, [1, 2, 3]],
|
|
21
|
-
[932, [932, "text", new Date()]],
|
|
22
|
-
["some text", ["some text", 2, true]],
|
|
23
|
-
[true, [true, false, "2", 1]],
|
|
24
|
-
[false, [false, "4", new Date()]]
|
|
25
|
-
];
|
|
26
|
-
test.each(inList)("values should be in", (value, compareValue) => {
|
|
27
|
-
const filter = getFilter();
|
|
28
|
-
|
|
29
|
-
const result = filter.matches({ value, compareValue });
|
|
30
|
-
|
|
31
|
-
expect(result).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const notInList: [
|
|
35
|
-
[number, [number, number, number]],
|
|
36
|
-
[number, [string, string, Date]],
|
|
37
|
-
[string, [string, number, boolean]],
|
|
38
|
-
[boolean, [string, boolean, string, number]],
|
|
39
|
-
[boolean, [string, string, Date]]
|
|
40
|
-
] = [
|
|
41
|
-
[1, [5, 2, 3]],
|
|
42
|
-
[932, ["932", "text", new Date()]],
|
|
43
|
-
["some text", ["some text 2", 2, true]],
|
|
44
|
-
[true, ["true", false, "2", 1]],
|
|
45
|
-
[false, ["false", "4", new Date()]]
|
|
46
|
-
];
|
|
47
|
-
test.each(notInList)("values should not be in", (value, compareValue) => {
|
|
48
|
-
const filter = getFilter();
|
|
49
|
-
|
|
50
|
-
const result = filter.matches({ value, compareValue });
|
|
51
|
-
|
|
52
|
-
expect(result).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { createValueFilterRegistry } from "./__mocks/registry";
|
|
3
|
-
|
|
4
|
-
describe("lt filter", () => {
|
|
5
|
-
const registry = createValueFilterRegistry();
|
|
6
|
-
|
|
7
|
-
const getFilter = () => {
|
|
8
|
-
const filter = registry.get("lt");
|
|
9
|
-
expect(filter).toBeDefined();
|
|
10
|
-
return filter!;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const ltList: ([number, number] | [Date, Date])[] = [
|
|
14
|
-
[2, 3],
|
|
15
|
-
[933, 934],
|
|
16
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:23.001Z")],
|
|
17
|
-
[new Date("2021-01-02T23:23:24.000Z"), new Date("2021-01-02T23:23:25.000Z")],
|
|
18
|
-
[new Date("2021-01-02T23:24:23.000Z"), new Date("2021-01-03T00:25:23.000Z")],
|
|
19
|
-
[new Date("2021-01-03T00:23:23.000Z"), new Date("2021-01-04T00:23:24.000Z")]
|
|
20
|
-
];
|
|
21
|
-
test.each(ltList)("value should be lesser", (value, compareValue) => {
|
|
22
|
-
const filter = getFilter();
|
|
23
|
-
|
|
24
|
-
const result = filter.matches({ value, compareValue });
|
|
25
|
-
|
|
26
|
-
expect(result).toBe(true);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const notLtList: ([number, number] | [Date, Date])[] = [
|
|
30
|
-
[4, 3],
|
|
31
|
-
[3, 2],
|
|
32
|
-
[935, 934],
|
|
33
|
-
[933, 933],
|
|
34
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
35
|
-
[new Date("2021-01-02T23:23:23.001Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
36
|
-
[new Date("2021-01-02T23:23:24.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
37
|
-
[new Date("2021-01-02T23:24:23.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
38
|
-
[new Date("2021-01-03T00:23:23.000Z"), new Date("2021-01-02T23:23:23.000Z")]
|
|
39
|
-
];
|
|
40
|
-
test.each(notLtList)("value should not be lesser", (value, compareValue) => {
|
|
41
|
-
const filter = getFilter();
|
|
42
|
-
|
|
43
|
-
const result = filter.matches({ value, compareValue });
|
|
44
|
-
|
|
45
|
-
expect(result).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { createValueFilterRegistry } from "./__mocks/registry";
|
|
3
|
-
|
|
4
|
-
describe("lte filter", () => {
|
|
5
|
-
const registry = createValueFilterRegistry();
|
|
6
|
-
|
|
7
|
-
const getFilter = () => {
|
|
8
|
-
const filter = registry.get("lte");
|
|
9
|
-
expect(filter).toBeDefined();
|
|
10
|
-
return filter!;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const lteList: ([number, number] | [Date, Date])[] = [
|
|
14
|
-
[2, 3],
|
|
15
|
-
[2, 2],
|
|
16
|
-
[933, 934],
|
|
17
|
-
[933, 933],
|
|
18
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:23.001Z")],
|
|
19
|
-
[new Date("2021-01-02T23:23:23.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
20
|
-
[new Date("2021-01-02T23:23:24.000Z"), new Date("2021-01-02T23:23:25.000Z")],
|
|
21
|
-
[new Date("2021-01-02T23:23:24.000Z"), new Date("2021-01-02T23:23:24.000Z")],
|
|
22
|
-
[new Date("2021-01-02T23:24:23.000Z"), new Date("2021-01-03T00:25:23.000Z")],
|
|
23
|
-
[new Date("2021-01-02T23:24:23.000Z"), new Date("2021-01-02T23:24:23.000Z")],
|
|
24
|
-
[new Date("2021-01-03T00:23:23.000Z"), new Date("2021-01-04T00:23:24.000Z")],
|
|
25
|
-
[new Date("2021-01-03T00:23:23.000Z"), new Date("2021-01-03T00:23:23.000Z")]
|
|
26
|
-
];
|
|
27
|
-
test.each(lteList)("value should be lesser or equal", (value, compareValue) => {
|
|
28
|
-
const filter = getFilter();
|
|
29
|
-
|
|
30
|
-
const result = filter.matches({ value, compareValue });
|
|
31
|
-
|
|
32
|
-
expect(result).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const notLteList: ([number, number] | [Date, Date])[] = [
|
|
36
|
-
[4, 3],
|
|
37
|
-
[935, 934],
|
|
38
|
-
[new Date("2021-01-02T23:23:23.001Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
39
|
-
[new Date("2021-01-02T23:23:24.000Z"), new Date("2021-01-02T23:23:23.000Z")],
|
|
40
|
-
[new Date("2021-01-02T23:24:23.000Z"), new Date("2021-01-02T23:23:23.000Z")]
|
|
41
|
-
];
|
|
42
|
-
test.each(notLteList)("value should not be lesser or equal", (value, compareValue) => {
|
|
43
|
-
const filter = getFilter();
|
|
44
|
-
|
|
45
|
-
const result = filter.matches({ value, compareValue });
|
|
46
|
-
|
|
47
|
-
expect(result).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
});
|