@noeldemartin/solid-utils 0.6.0-next.956cbec11a55691bab3170059fa908865d683e20 → 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 +2 -0
- package/dist/noeldemartin-solid-utils.js +21 -20
- package/dist/testing.d.ts +0 -35
- 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 +11 -3
- package/src/helpers/io.ts +6 -0
- package/src/index.ts +1 -1
- package/src/testing/index.ts +0 -2
- package/src/{testing/types → types}/index.ts +2 -2
- /package/src/{testing/chai → chai}/assertions.ts +0 -0
- /package/src/{testing/chai → chai}/index.ts +0 -0
- /package/src/{testing/vitest → vitest}/index.ts +0 -0
- /package/src/{testing/vitest → vitest}/matchers.ts +0 -0
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",
|
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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { ChaiSolidAssertions } from '@noeldemartin/solid-utils/
|
|
2
|
-
export type { VitestSolidMatchers } from '@noeldemartin/solid-utils/
|
|
1
|
+
export type { ChaiSolidAssertions } from '@noeldemartin/solid-utils/chai';
|
|
2
|
+
export type { VitestSolidMatchers } from '@noeldemartin/solid-utils/vitest';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|