@traqula/test-utils 0.0.22 → 0.0.24

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.
@@ -1,91 +1,106 @@
1
1
  "use strict";
2
- var import_vitest = require("vitest");
3
- import_vitest.expect.extend({
4
- toEqualParsedQuery(received, expected) {
5
- const pass = objectsEqual(received, expected, () => false, []);
6
- const message = pass ? () => `${this.utils.matcherHint("toEqualParsedQuery")}
7
-
8
- Expected: ${this.utils.printExpected(expected)}
9
- Received: ${this.utils.printReceived(received)}` : () => {
10
- const diffString = this.utils.diff(expected, received, {
11
- expand: this.expand
12
- });
13
- return `${this.utils.matcherHint("toEqualParsedQuery")}
14
-
15
- ${diffString && diffString.includes("- Expect") ? `Difference:
16
-
17
- ${diffString}` : `Expected: ${this.utils.printExpected(expected)}
18
- Received: ${this.utils.printReceived(received)}`}`;
19
- };
20
- return { pass, message };
21
- },
22
- toEqualParsedQueryIgnoring(received, selector, ignoreKeys, expected) {
23
- const pass = objectsEqual(received, expected, selector, ignoreKeys);
24
- const message = pass ? () => `${this.utils.matcherHint("toEqualParsedQuery")}
25
-
26
- Expected: ${this.utils.printExpected(expected)}
27
- Received: ${this.utils.printReceived(received)}` : () => {
28
- const diffString = this.utils.diff(expected, received, {
29
- expand: this.expand
30
- });
31
- return `${this.utils.matcherHint("toEqualParsedQuery")}
32
-
33
- ${diffString && diffString.includes("- Expect") ? `Difference:
34
-
35
- ${diffString}` : `Expected: ${this.utils.printExpected(expected)}
36
- Received: ${this.utils.printReceived(received)}`}`;
37
- };
38
- return { pass, message };
39
- }
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ vitest_1.expect.extend({
5
+ toEqualParsedQuery(received, expected) {
6
+ const pass = objectsEqual(received, expected, () => false, []);
7
+ const message = pass ?
8
+ () => `${this.utils.matcherHint('toEqualParsedQuery')}\n\n` +
9
+ `Expected: ${this.utils.printExpected(expected)}\n` +
10
+ `Received: ${this.utils.printReceived(received)}` :
11
+ () => {
12
+ const diffString = this.utils.diff(expected, received, {
13
+ expand: this.expand,
14
+ });
15
+ return (`${this.utils.matcherHint('toEqualParsedQuery')}\n\n${diffString && diffString.includes('- Expect') ?
16
+ `Difference:\n\n${diffString}` :
17
+ `Expected: ${this.utils.printExpected(expected)}\n` +
18
+ `Received: ${this.utils.printReceived(received)}`}`);
19
+ };
20
+ return { pass, message };
21
+ },
22
+ toEqualParsedQueryIgnoring(received, selector, ignoreKeys, expected) {
23
+ const pass = objectsEqual(received, expected, selector, ignoreKeys);
24
+ const message = pass ?
25
+ () => `${this.utils.matcherHint('toEqualParsedQuery')}\n\n` +
26
+ `Expected: ${this.utils.printExpected(expected)}\n` +
27
+ `Received: ${this.utils.printReceived(received)}` :
28
+ () => {
29
+ const diffString = this.utils.diff(expected, received, {
30
+ expand: this.expand,
31
+ });
32
+ return (`${this.utils.matcherHint('toEqualParsedQuery')}\n\n${diffString && diffString.includes('- Expect') ?
33
+ `Difference:\n\n${diffString}` :
34
+ `Expected: ${this.utils.printExpected(expected)}\n` +
35
+ `Received: ${this.utils.printReceived(received)}`}`);
36
+ };
37
+ return { pass, message };
38
+ },
40
39
  });
40
+ // We cannot use native instanceOf to test whether expected is a Term!
41
41
  function objectsEqual(received, expected, selector, ignoreKeys) {
42
- if (received === void 0 || received === null || isPrimitive(received)) {
43
- return received === expected;
44
- }
45
- if (isTerm(received)) {
46
- return received.equals(expected);
47
- }
48
- if (isTerm(expected)) {
49
- return expected.equals(received);
50
- }
51
- if (Array.isArray(received)) {
52
- if (!Array.isArray(expected)) {
53
- return false;
42
+ if (received === undefined || received === null || isPrimitive(received)) {
43
+ return received === expected;
54
44
  }
55
- if (received.length !== expected.length) {
56
- return false;
45
+ if (isTerm(received)) {
46
+ // eslint-disable-next-line ts/ban-ts-comment
47
+ // @ts-expect-error TS2345
48
+ return received.equals(expected);
57
49
  }
58
- for (const [i, element] of received.entries()) {
59
- if (!objectsEqual(element, expected[i], selector, ignoreKeys)) {
60
- return false;
61
- }
50
+ if (isTerm(expected)) {
51
+ // eslint-disable-next-line ts/ban-ts-comment
52
+ // @ts-expect-error TS2345
53
+ return expected.equals(received);
62
54
  }
63
- } else {
64
- if (expected === void 0 || expected === null || isPrimitive(expected) || Array.isArray(expected)) {
65
- return false;
55
+ // York
56
+ // test
57
+ if (Array.isArray(received)) {
58
+ if (!Array.isArray(expected)) {
59
+ return false;
60
+ }
61
+ if (received.length !== expected.length) {
62
+ return false;
63
+ }
64
+ for (const [i, element] of received.entries()) {
65
+ if (!objectsEqual(element, expected[i], selector, ignoreKeys)) {
66
+ return false;
67
+ }
68
+ }
66
69
  }
67
- const keys_first = Object.keys(received);
68
- const receivedMatches = selector(received);
69
- for (const key of keys_first) {
70
- if (receivedMatches && ignoreKeys.includes(key)) {
71
- continue;
72
- }
73
- if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {
74
- return false;
75
- }
70
+ else {
71
+ // Received == object
72
+ if (expected === undefined || expected === null || isPrimitive(expected) || Array.isArray(expected)) {
73
+ return false;
74
+ }
75
+ const keys_first = Object.keys(received);
76
+ const receivedMatches = selector(received);
77
+ for (const key of keys_first) {
78
+ if (receivedMatches && ignoreKeys.includes(key)) {
79
+ continue;
80
+ }
81
+ // eslint-disable-next-line ts/ban-ts-comment
82
+ // @ts-expect-error TS7053
83
+ if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {
84
+ return false;
85
+ }
86
+ }
87
+ // We do this to make sure that we are not missing keys in the received object
88
+ const keys_second = Object.keys(expected);
89
+ for (const key of keys_second) {
90
+ // eslint-disable-next-line ts/ban-ts-comment
91
+ // @ts-expect-error TS7053
92
+ if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {
93
+ return false;
94
+ }
95
+ }
76
96
  }
77
- const keys_second = Object.keys(expected);
78
- for (const key of keys_second) {
79
- if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {
80
- return false;
81
- }
82
- }
83
- }
84
- return true;
97
+ return true;
85
98
  }
99
+ // If true, the value is a term. With ts annotation
86
100
  function isTerm(value) {
87
- return false;
101
+ return false;
88
102
  }
89
103
  function isPrimitive(value) {
90
- return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
104
+ return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
91
105
  }
106
+ //# sourceMappingURL=toEqualParsedQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toEqualParsedQuery.js","sourceRoot":"","sources":["../../../../lib/matchers/toEqualParsedQuery.ts"],"names":[],"mappings":";;AAAA,mCAAgC;AAEhC,eAAM,CAAC,MAAM,CAAC;IACZ,kBAAkB,CAAC,QAAiB,EAAE,QAAiB;QACrD,MAAM,IAAI,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC;YAClB,GAAG,EAAE,CACH,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,CAChD,MAAM;gBACN,aAAa,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI;gBACnD,aAAa,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACnD,GAAG,EAAE;gBACH,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE;oBACrD,MAAM,EAAE,IAAI,CAAC,MAAM;iBACpB,CAAC,CAAC;gBACH,OAAO,CACL,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,CAChD,OACA,UAAU,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;oBAC7C,kBAAkB,UAAU,EAAE,CAAC,CAAC;oBAChC,aAAa,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,IAA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,KAAK,CAAC;QACf,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,eAAe,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE3C,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAC7B,IAAI,eAAe,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChD,SAAS;YACX,CAAC;YACD,6CAA6C;YAC7C,0BAA0B;YAC1B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;gBACtE,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,8EAA8E;QAC9E,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,6CAA6C;YAC7C,0BAA0B;YAC1B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC;gBACtE,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,mDAAmD;AACnD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,CAAC;AAC9F,CAAC","sourcesContent":["import { expect } from 'vitest';\n\nexpect.extend({\n toEqualParsedQuery(received: unknown, expected: unknown) {\n const pass = objectsEqual(received, expected, () => false, []);\n const message = pass ?\n () =>\n `${this.utils.matcherHint('toEqualParsedQuery')\n }\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(received)}` :\n () => {\n const diffString = this.utils.diff(expected, received, {\n expand: this.expand,\n });\n return (\n `${this.utils.matcherHint('toEqualParsedQuery')\n }\\n\\n${\n diffString && diffString.includes('- Expect') ?\n `Difference:\\n\\n${diffString}` :\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(received)}`}`\n );\n };\n\n return { pass, message };\n },\n toEqualParsedQueryIgnoring(\n received: unknown,\n selector: (obj: object) => boolean,\n ignoreKeys: string[],\n expected: unknown,\n ) {\n const pass = objectsEqual(received, expected, selector, ignoreKeys);\n const message = pass ?\n () =>\n `${this.utils.matcherHint('toEqualParsedQuery')\n }\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(received)}` :\n () => {\n const diffString = this.utils.diff(expected, received, {\n expand: this.expand,\n });\n return (\n `${this.utils.matcherHint('toEqualParsedQuery')\n }\\n\\n${\n diffString && diffString.includes('- Expect') ?\n `Difference:\\n\\n${diffString}` :\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(received)}`}`\n );\n };\n\n return { pass, message };\n },\n});\n\n// We cannot use native instanceOf to test whether expected is a Term!\nfunction objectsEqual(\n received: unknown,\n expected: unknown,\n selector: (obj: object) => boolean,\n ignoreKeys: string[],\n): boolean {\n if (received === undefined || received === null || isPrimitive(received)) {\n return received === expected;\n }\n\n if (isTerm(received)) {\n // eslint-disable-next-line ts/ban-ts-comment\n // @ts-expect-error TS2345\n return received.equals(expected);\n }\n if (isTerm(expected)) {\n // eslint-disable-next-line ts/ban-ts-comment\n // @ts-expect-error TS2345\n return expected.equals(received);\n }\n // York\n // test\n if (Array.isArray(received)) {\n if (!Array.isArray(expected)) {\n return false;\n }\n if (received.length !== expected.length) {\n return false;\n }\n for (const [ i, element ] of received.entries()) {\n if (!objectsEqual(element, expected[i], selector, ignoreKeys)) {\n return false;\n }\n }\n } else {\n // Received == object\n if (expected === undefined || expected === null || isPrimitive(expected) || Array.isArray(expected)) {\n return false;\n }\n const keys_first = Object.keys(received);\n const receivedMatches = selector(received);\n\n for (const key of keys_first) {\n if (receivedMatches && ignoreKeys.includes(key)) {\n continue;\n }\n // eslint-disable-next-line ts/ban-ts-comment\n // @ts-expect-error TS7053\n if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {\n return false;\n }\n }\n\n // We do this to make sure that we are not missing keys in the received object\n const keys_second = Object.keys(expected);\n for (const key of keys_second) {\n // eslint-disable-next-line ts/ban-ts-comment\n // @ts-expect-error TS7053\n if (!objectsEqual(received[key], expected[key], selector, ignoreKeys)) {\n return false;\n }\n }\n }\n return true;\n}\n\n// If true, the value is a term. With ts annotation\nfunction isTerm(value: unknown): value is { equals: (other: { termType: unknown } | undefined | null) => boolean } {\n return false;\n}\n\nfunction isPrimitive(value: unknown): value is string | number | boolean {\n return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';\n}\n"]}
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
- var import_vitest = require("vitest");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("vitest");
4
+ //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.js","sourceRoot":"","sources":["../../../../lib/matchers/vitest.ts"],"names":[],"mappings":";;AAAA,kBAAgB","sourcesContent":["import 'vitest';\n\ninterface CustomMatchers<R = unknown> {\n toEqualParsedQuery: (expected: unknown) => R;\n toEqualParsedQueryIgnoring: (selector: (obj: object) => boolean, keys: string[], expected: unknown) => R;\n}\n\ndeclare module 'vitest' {\n interface Assertion<T = any> extends CustomMatchers<T> {}\n interface AsymmetricMatchersContaining extends CustomMatchers {}\n}\n"]}
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@traqula/test-utils",
3
3
  "type": "module",
4
- "version": "0.0.22",
4
+ "version": "0.0.24",
5
5
  "description": "Test utils used by the Traqula monorepo",
6
6
  "lsd:module": true,
7
7
  "license": "MIT",
@@ -26,9 +26,10 @@
26
26
  },
27
27
  "main": "dist/esm/lib/index.js",
28
28
  "files": [
29
- "dist/**/*.d.ts",
30
- "dist/**/*.js",
31
- "dist/**/*.js.map",
29
+ "dist/*/lib/**/*.d.ts",
30
+ "dist/*/lib/**/*.js",
31
+ "dist/*/lib/**/*.js.map",
32
+ "dist/cjs/package.json",
32
33
  "lib/generators/**/*.json",
33
34
  "lib/generators/**/*.sparql"
34
35
  ],
@@ -36,9 +37,9 @@
36
37
  "node": "^20.19.0 || >=22.12.0"
37
38
  },
38
39
  "scripts": {
39
- "build": "yarn build:ts && yarn build:transpile",
40
+ "build": "yarn build:ts && yarn build:cjs",
40
41
  "build:ts": "node \"../../node_modules/typescript/bin/tsc\" -b",
41
- "build:transpile": "esbuild \"dist/esm/**/*.js\" --outdir=dist/cjs/lib --platform=node --format=cjs"
42
+ "build:cjs": "node \"../../node_modules/typescript/bin/tsc\" -b tsconfig.cjs.json"
42
43
  },
43
44
  "dependencies": {
44
45
  "rdf-data-factory": "^2.0.1",
@@ -47,5 +48,5 @@
47
48
  "devDependencies": {
48
49
  "@rdfjs/types": "^2.0.0"
49
50
  },
50
- "gitHead": "e0cf04a50b3558229ebcc5992cf9562b14f9a077"
51
+ "gitHead": "9865fe1fe302819d46e19c6f3250ceef778f434f"
51
52
  }