@noeldemartin/solid-utils 0.6.0-next.95fe731be0689c25d9040cc1411e27c49f69901d → 0.6.0-next.9e5255c1e3f28414be67ade1f4aadbbbd1211cb2
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/chai.d.ts +31 -0
- package/dist/chai.js +23 -0
- package/dist/chai.js.map +1 -0
- package/dist/helpers-Bxz7F0sw.js +107 -0
- package/dist/helpers-Bxz7F0sw.js.map +1 -0
- package/dist/{io-CMHtz5bu.js → io-vm3EKQZf.js} +85 -80
- package/dist/{io-CMHtz5bu.js.map → io-vm3EKQZf.js.map} +1 -1
- package/dist/noeldemartin-solid-utils.d.ts +50 -0
- package/dist/noeldemartin-solid-utils.js +21 -20
- package/dist/testing.d.ts +18 -25
- package/dist/testing.js +4 -173
- package/dist/testing.js.map +1 -1
- package/dist/vitest.d.ts +50 -0
- package/dist/vitest.js +55 -0
- package/dist/vitest.js.map +1 -0
- package/package.json +12 -4
- package/src/{testing/chai → chai}/assertions.ts +5 -14
- package/src/chai/index.ts +19 -0
- package/src/helpers/io.ts +6 -0
- package/src/index.ts +1 -0
- package/src/testing/index.ts +0 -2
- package/src/types/index.ts +2 -0
- package/src/{testing/vitest → vitest}/index.ts +5 -0
- package/src/testing/chai/index.ts +0 -7
- /package/src/{testing/vitest → vitest}/matchers.ts +0 -0
package/dist/vitest.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MatcherState } from '@vitest/expect';
|
|
2
|
+
|
|
3
|
+
declare const _default: {
|
|
4
|
+
toEqualJsonLD(this: MatcherState, received: any, expected: JsonLD): Promise<{
|
|
5
|
+
pass: boolean;
|
|
6
|
+
message: () => string;
|
|
7
|
+
}>;
|
|
8
|
+
toEqualSparql(this: MatcherState, received: any, expected: string): {
|
|
9
|
+
pass: boolean;
|
|
10
|
+
message: () => string;
|
|
11
|
+
};
|
|
12
|
+
toEqualTurtle(this: MatcherState, received: any, expected: string): {
|
|
13
|
+
pass: boolean;
|
|
14
|
+
message: () => string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export declare function installVitestSolidMatchers(): void;
|
|
19
|
+
|
|
20
|
+
declare type JsonLD = Partial<{
|
|
21
|
+
'@context': Record<string, unknown>;
|
|
22
|
+
'@id': string;
|
|
23
|
+
'@type': null | string | string[];
|
|
24
|
+
}> & {
|
|
25
|
+
[k: string]: unknown;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export declare type VitestSolidMatchers<R = unknown> = {
|
|
29
|
+
[K in keyof typeof _default]: (...args: Parameters<(typeof _default)[K]> extends [any, ...infer Rest] ? Rest : never) => ReturnType<(typeof _default)[K]> extends Promise<any> ? Promise<R> : R;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { }
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
declare module '@vitest/expect' {
|
|
36
|
+
interface Assertion<T> extends VitestSolidMatchers<T> {
|
|
37
|
+
}
|
|
38
|
+
interface AsymmetricMatchersContaining extends VitestSolidMatchers {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
declare global {
|
|
44
|
+
namespace Chai {
|
|
45
|
+
interface Assertion extends ChaiSolidAssertions {
|
|
46
|
+
}
|
|
47
|
+
interface Include extends ChaiSolidAssertions {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
package/dist/vitest.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { expect as l } from "vitest";
|
|
2
|
+
import { n as r, b as i } from "./io-vm3EKQZf.js";
|
|
3
|
+
import { t as o, s as u, j as c } from "./helpers-Bxz7F0sw.js";
|
|
4
|
+
function a(e, t) {
|
|
5
|
+
const s = e.success, n = t.state.utils;
|
|
6
|
+
return { pass: s, message: s ? () => [e.message, n.matcherHint(t.hint)].join(`
|
|
7
|
+
|
|
8
|
+
`) : () => [
|
|
9
|
+
e.message,
|
|
10
|
+
n.matcherHint(t.hint),
|
|
11
|
+
[
|
|
12
|
+
`Expected: not ${n.printExpected(t.expected)}`,
|
|
13
|
+
`Received: ${n.printReceived(t.received)}`
|
|
14
|
+
].join(`
|
|
15
|
+
`)
|
|
16
|
+
].join(`
|
|
17
|
+
|
|
18
|
+
`) };
|
|
19
|
+
}
|
|
20
|
+
const m = {
|
|
21
|
+
async toEqualJsonLD(e, t) {
|
|
22
|
+
const s = await c(t, e);
|
|
23
|
+
return a(s, {
|
|
24
|
+
state: this,
|
|
25
|
+
hint: "toEqualJsonLD",
|
|
26
|
+
expected: t,
|
|
27
|
+
received: e
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
toEqualSparql(e, t) {
|
|
31
|
+
const s = u(t, e);
|
|
32
|
+
return a(s, {
|
|
33
|
+
state: this,
|
|
34
|
+
hint: "toEqualSparql",
|
|
35
|
+
expected: i(t),
|
|
36
|
+
received: i(e)
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
toEqualTurtle(e, t) {
|
|
40
|
+
const s = o(t, e);
|
|
41
|
+
return a(s, {
|
|
42
|
+
state: this,
|
|
43
|
+
hint: "toEqualTurtle",
|
|
44
|
+
expected: r(t),
|
|
45
|
+
received: r(e)
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function d() {
|
|
50
|
+
l.extend(m);
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
d as installVitestSolidMatchers
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=vitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.js","sources":["../src/vitest/matchers.ts","../src/vitest/index.ts"],"sourcesContent":["import type { MatcherState, MatchersObject } from '@vitest/expect';\n\nimport { normalizeSparql, normalizeTurtle } from '@noeldemartin/solid-utils/helpers/io';\nimport { jsonldEquals, sparqlEquals, turtleEquals } from '@noeldemartin/solid-utils/testing/helpers';\nimport type { EqualityResult } from '@noeldemartin/solid-utils/testing/helpers';\nimport type { JsonLD } from '@noeldemartin/solid-utils/helpers';\n\ninterface FormatResultOptions {\n state: MatcherState;\n hint: string;\n expected: unknown;\n received: unknown;\n}\n\nfunction formatResult(result: EqualityResult, options: FormatResultOptions) {\n const pass = result.success;\n const utils = options.state.utils;\n const message = pass\n ? () => [result.message, utils.matcherHint(options.hint)].join('\\n\\n')\n : () =>\n [\n result.message,\n utils.matcherHint(options.hint),\n [\n `Expected: not ${utils.printExpected(options.expected)}`,\n `Received: ${utils.printReceived(options.received)}`,\n ].join('\\n'),\n ].join('\\n\\n');\n\n return { pass, message };\n}\n\nexport function defineMatchers<T extends MatchersObject>(matchers: T): T {\n return matchers;\n}\n\nexport default defineMatchers({\n async toEqualJsonLD(received, expected: JsonLD) {\n const result = await jsonldEquals(expected, received);\n\n return formatResult(result, {\n state: this,\n hint: 'toEqualJsonLD',\n expected,\n received,\n });\n },\n toEqualSparql(received, expected: string) {\n const result = sparqlEquals(expected, received);\n\n return formatResult(result, {\n state: this,\n hint: 'toEqualSparql',\n expected: normalizeSparql(expected),\n received: normalizeSparql(received),\n });\n },\n toEqualTurtle(received, expected: string) {\n const result = turtleEquals(expected, received);\n\n return formatResult(result, {\n state: this,\n hint: 'toEqualTurtle',\n expected: normalizeTurtle(expected),\n received: normalizeTurtle(received),\n });\n },\n});\n","import { expect } from 'vitest';\n\nimport matchers from './matchers';\n\nexport type VitestSolidMatchers<R = unknown> = {\n [K in keyof typeof matchers]: (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...args: Parameters<(typeof matchers)[K]> extends [any, ...infer Rest] ? Rest : never\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) => ReturnType<(typeof matchers)[K]> extends Promise<any> ? Promise<R> : R;\n};\n\nexport function installVitestSolidMatchers(): void {\n expect.extend(matchers);\n}\n\ndeclare module '@vitest/expect' {\n interface Assertion<T> extends VitestSolidMatchers<T> {}\n interface AsymmetricMatchersContaining extends VitestSolidMatchers {}\n}\n"],"names":["formatResult","result","options","pass","utils","matchers","received","expected","jsonldEquals","sparqlEquals","normalizeSparql","turtleEquals","normalizeTurtle","installVitestSolidMatchers","expect"],"mappings":";;;AAcA,SAASA,EAAaC,GAAwBC,GAA8B;AACxE,QAAMC,IAAOF,EAAO,SACdG,IAAQF,EAAQ,MAAM;AAarB,SAAA,EAAE,MAAAC,GAAM,SAZCA,IACV,MAAM,CAACF,EAAO,SAASG,EAAM,YAAYF,EAAQ,IAAI,CAAC,EAAE,KAAK;AAAA;AAAA,CAAM,IACnE,MACE;AAAA,IACID,EAAO;AAAA,IACPG,EAAM,YAAYF,EAAQ,IAAI;AAAA,IAC9B;AAAA,MACI,iBAAiBE,EAAM,cAAcF,EAAQ,QAAQ,CAAC;AAAA,MACtD,aAAaE,EAAM,cAAcF,EAAQ,QAAQ,CAAC;AAAA,IACtD,EAAE,KAAK;AAAA,CAAI;AAAA,EAAA,EACb,KAAK;AAAA;AAAA,CAAM,EAEE;AAC3B;AAMA,MAAAG,IAA8B;AAAA,EAC1B,MAAM,cAAcC,GAAUC,GAAkB;AAC5C,UAAMN,IAAS,MAAMO,EAAaD,GAAUD,CAAQ;AAEpD,WAAON,EAAaC,GAAQ;AAAA,MACxB,OAAO;AAAA,MACP,MAAM;AAAA,MACN,UAAAM;AAAA,MACA,UAAAD;AAAA,IAAA,CACH;AAAA,EACL;AAAA,EACA,cAAcA,GAAUC,GAAkB;AAChC,UAAAN,IAASQ,EAAaF,GAAUD,CAAQ;AAE9C,WAAON,EAAaC,GAAQ;AAAA,MACxB,OAAO;AAAA,MACP,MAAM;AAAA,MACN,UAAUS,EAAgBH,CAAQ;AAAA,MAClC,UAAUG,EAAgBJ,CAAQ;AAAA,IAAA,CACrC;AAAA,EACL;AAAA,EACA,cAAcA,GAAUC,GAAkB;AAChC,UAAAN,IAASU,EAAaJ,GAAUD,CAAQ;AAE9C,WAAON,EAAaC,GAAQ;AAAA,MACxB,OAAO;AAAA,MACP,MAAM;AAAA,MACN,UAAUW,EAAgBL,CAAQ;AAAA,MAClC,UAAUK,EAAgBN,CAAQ;AAAA,IAAA,CACrC;AAAA,EAAA;AAET;ACvDO,SAASO,IAAmC;AAC/C,EAAAC,EAAO,OAAOT,CAAQ;AAC1B;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noeldemartin/solid-utils",
|
|
3
|
-
"version": "0.6.0-next.
|
|
3
|
+
"version": "0.6.0-next.9e5255c1e3f28414be67ade1f4aadbbbd1211cb2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -11,6 +11,14 @@
|
|
|
11
11
|
"./testing": {
|
|
12
12
|
"types": "./dist/testing.d.ts",
|
|
13
13
|
"default": "./dist/testing.js"
|
|
14
|
+
},
|
|
15
|
+
"./vitest": {
|
|
16
|
+
"types": "./dist/vitest.d.ts",
|
|
17
|
+
"default": "./dist/vitest.js"
|
|
18
|
+
},
|
|
19
|
+
"./chai": {
|
|
20
|
+
"types": "./dist/chai.d.ts",
|
|
21
|
+
"default": "./dist/chai.js"
|
|
14
22
|
}
|
|
15
23
|
},
|
|
16
24
|
"files": [
|
|
@@ -28,7 +36,7 @@
|
|
|
28
36
|
"verify": "noeldemartin-verify"
|
|
29
37
|
},
|
|
30
38
|
"dependencies": {
|
|
31
|
-
"@noeldemartin/utils": "0.7.0
|
|
39
|
+
"@noeldemartin/utils": "^0.7.0",
|
|
32
40
|
"@rdfjs/types": "^2.0.1",
|
|
33
41
|
"jsonld": "^8.3.3",
|
|
34
42
|
"md5": "^2.3.0",
|
|
@@ -36,7 +44,7 @@
|
|
|
36
44
|
},
|
|
37
45
|
"devDependencies": {
|
|
38
46
|
"@noeldemartin/eslint-config-typescript": "^0.1.2",
|
|
39
|
-
"@noeldemartin/scripts": "0.3.0-next.
|
|
47
|
+
"@noeldemartin/scripts": "0.3.0-next.88fb0ff21ba1f9015dab043ded20be9518e51248",
|
|
40
48
|
"@noeldemartin/testing": "0.0.0-next.cd489a93da5eaad3f89a4d9ae3734f7ef911b6f6",
|
|
41
49
|
"@tsconfig/node22": "^22.0.0",
|
|
42
50
|
"@types/chai": "^5.2.0",
|
|
@@ -47,7 +55,7 @@
|
|
|
47
55
|
"@vitest/expect": "^3.0.9",
|
|
48
56
|
"typescript": "^5.8.2",
|
|
49
57
|
"vite": "^6.2.2",
|
|
50
|
-
"vite-plugin-dts": "
|
|
58
|
+
"vite-plugin-dts": "4.5.0",
|
|
51
59
|
"vitest": "^3.0.9"
|
|
52
60
|
},
|
|
53
61
|
"eslintConfig": {
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { sparqlEquals, turtleEquals } from '@noeldemartin/solid-utils/testing/helpers';
|
|
2
2
|
import type { EqualityResult } from '@noeldemartin/solid-utils/testing/helpers';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
declare global {
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
10
|
-
namespace Chai {
|
|
11
|
-
interface Assertion extends CustomAssertions {}
|
|
12
|
-
interface Include extends CustomAssertions {}
|
|
13
|
-
}
|
|
4
|
+
export function defineChaiAssertions<T extends Record<string, (this: Chai.AssertionStatic, ...args: any[]) => void>>(
|
|
5
|
+
assertions: T): T {
|
|
6
|
+
return assertions;
|
|
14
7
|
}
|
|
15
8
|
|
|
16
|
-
|
|
9
|
+
export default defineChaiAssertions({
|
|
17
10
|
turtle(graph: string): void {
|
|
18
11
|
const self = this as unknown as Chai.AssertionStatic;
|
|
19
12
|
const actual = self._obj as string;
|
|
@@ -39,6 +32,4 @@ const assertions: Record<string, (this: Chai.AssertionStatic, ...args: any[]) =>
|
|
|
39
32
|
|
|
40
33
|
assert(result.success, result.message, '', result.expected, result.actual);
|
|
41
34
|
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default assertions;
|
|
35
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import assertions from './assertions';
|
|
2
|
+
|
|
3
|
+
export type ChaiSolidAssertions = {
|
|
4
|
+
[assertion in keyof typeof assertions]: (typeof assertions)[assertion];
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export function installChaiSolidAssertions(): void {
|
|
8
|
+
(globalThis as { chai?: Chai.ChaiStatic }).chai?.use((_chai) => {
|
|
9
|
+
return Object.entries(assertions).forEach(([name, method]) => _chai.Assertion.addMethod(name, method));
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare global {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
15
|
+
namespace Chai {
|
|
16
|
+
interface Assertion extends ChaiSolidAssertions {}
|
|
17
|
+
interface Include extends ChaiSolidAssertions {}
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/helpers/io.ts
CHANGED
|
@@ -202,6 +202,12 @@ export async function jsonldToQuads(json: JsonLD, baseIRI?: string): Promise<Qua
|
|
|
202
202
|
return quads;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
export async function normalizeJsonLD(json: JsonLD, baseIRI?: string): Promise<JsonLD> {
|
|
206
|
+
const quads = await jsonldToQuads(json, baseIRI);
|
|
207
|
+
|
|
208
|
+
return quadsToJsonLD(quads);
|
|
209
|
+
}
|
|
210
|
+
|
|
205
211
|
export function normalizeSparql(sparql: string): string {
|
|
206
212
|
const quads = sparqlToQuadsSync(sparql);
|
|
207
213
|
|
package/src/index.ts
CHANGED
package/src/testing/index.ts
CHANGED
|
@@ -13,3 +13,8 @@ export type VitestSolidMatchers<R = unknown> = {
|
|
|
13
13
|
export function installVitestSolidMatchers(): void {
|
|
14
14
|
expect.extend(matchers);
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
declare module '@vitest/expect' {
|
|
18
|
+
interface Assertion<T> extends VitestSolidMatchers<T> {}
|
|
19
|
+
interface AsymmetricMatchersContaining extends VitestSolidMatchers {}
|
|
20
|
+
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import assertions from './assertions';
|
|
2
|
-
|
|
3
|
-
export function installChaiPlugin(): void {
|
|
4
|
-
(globalThis as { chai?: Chai.ChaiStatic }).chai?.use((_chai) => {
|
|
5
|
-
return Object.entries(assertions).forEach(([name, method]) => _chai.Assertion.addMethod(name, method));
|
|
6
|
-
});
|
|
7
|
-
}
|
|
File without changes
|