@rdfx/testing 0.0.59 → 0.0.60

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/index.d.ts CHANGED
@@ -12,6 +12,7 @@ declare module "vitest" {
12
12
  toEqualRdfQuadArray: (actual: RDF.BaseQuad[]) => T;
13
13
  toEqualRdfTerm: (actual: RDF.Term) => T;
14
14
  toEqualRdfTermArray: (actual: RDF.Term[]) => T;
15
+ toEqualRdfTermSet: (actual: RDF.Term[]) => T;
15
16
  }
16
17
  }
17
18
  export { matchers } from "./matchers.js";
@@ -8,6 +8,7 @@ export interface IQuadTerms<TQuad extends RDF.BaseQuad = RDF.Quad> {
8
8
  predicate?: TQuad["predicate"];
9
9
  subject?: TQuad["subject"];
10
10
  }
11
+ export declare function termArrayToString(termArray: RDF.Term[]): string;
11
12
  export declare function toBeRdfDatasetContaining<TQuad extends RDF.BaseQuad = RDF.Quad>(dataset: RDF.DatasetCore<TQuad>, ...quads: TQuad[]): {
12
13
  message: () => string;
13
14
  pass: boolean;
@@ -23,7 +23,7 @@ function succeed(received, actual) {
23
23
  pass: true,
24
24
  };
25
25
  }
26
- function termArrayToString(termArray) {
26
+ export function termArrayToString(termArray) {
27
27
  return `[ ${termArray.map((term) => JSON.stringify(termToString(term))).join(", ")} ]`;
28
28
  }
29
29
  function getBnodeDiff(receivedQuads, expectedQuads) {
@@ -1,4 +1,5 @@
1
1
  import { toBeRdfDatasetContaining, toBeRdfDatasetMatching, toBeRdfDatasetOfSize, toBeRdfIsomorphic, toEqualRdfQuad, toEqualRdfQuadArray, toEqualRdfTerm, toEqualRdfTermArray } from "./jestRdfMatchers.js";
2
+ import { toEqualRdfTermSet } from "./rdfxRdfMatchers.js";
2
3
  export declare const matchers: {
3
4
  toBeRdfDatasetContaining: typeof toBeRdfDatasetContaining;
4
5
  toBeRdfDatasetMatching: typeof toBeRdfDatasetMatching;
@@ -8,6 +9,7 @@ export declare const matchers: {
8
9
  toEqualRdfQuadArray: typeof toEqualRdfQuadArray;
9
10
  toEqualRdfTerm: typeof toEqualRdfTerm;
10
11
  toEqualRdfTermArray: typeof toEqualRdfTermArray;
12
+ toEqualRdfTermSet: typeof toEqualRdfTermSet;
11
13
  toBeLeft: import("vitest").Matcher<import("vitest").MatcherState, any[]>;
12
14
  };
13
15
  //# sourceMappingURL=matchers.d.ts.map
package/dist/matchers.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { toBeRdfDatasetContaining, toBeRdfDatasetMatching, toBeRdfDatasetOfSize, toBeRdfIsomorphic, toEqualRdfQuad, toEqualRdfQuadArray, toEqualRdfTerm, toEqualRdfTermArray, } from "./jestRdfMatchers.js";
2
2
  import { toBeLeft } from "./purifyMatchers.js";
3
+ import { toEqualRdfTermSet } from "./rdfxRdfMatchers.js";
3
4
  export const matchers = {
4
5
  toBeRdfDatasetContaining,
5
6
  toBeRdfDatasetMatching,
@@ -9,6 +10,7 @@ export const matchers = {
9
10
  toEqualRdfQuadArray,
10
11
  toEqualRdfTerm,
11
12
  toEqualRdfTermArray,
13
+ toEqualRdfTermSet,
12
14
  toBeLeft,
13
15
  };
14
16
  //# sourceMappingURL=matchers.js.map
@@ -0,0 +1,6 @@
1
+ import type * as RDF from "@rdfjs/types";
2
+ export declare function toEqualRdfTermSet(received: RDF.Term[], actual: RDF.Term[]): {
3
+ message: () => string;
4
+ pass: boolean;
5
+ };
6
+ //# sourceMappingURL=rdfxRdfMatchers.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { termToString } from "rdf-string";
2
+ import { termArrayToString } from "./jestRdfMatchers.js";
3
+ export function toEqualRdfTermSet(received, actual) {
4
+ if (received.length !== actual.length) {
5
+ return {
6
+ message: () => `expected ${termArrayToString(received)} to equal ${termArrayToString(actual)}`,
7
+ pass: false,
8
+ };
9
+ }
10
+ for (const receivedElement of received) {
11
+ if (!actual.some((actualElement) => actualElement.equals(receivedElement))) {
12
+ return {
13
+ message: () => `expected ${termToString(receivedElement)} to be present in set`,
14
+ pass: false,
15
+ };
16
+ }
17
+ }
18
+ return {
19
+ message: () => `expected ${termArrayToString(received)} not to equal ${termArrayToString(actual)}`,
20
+ pass: true,
21
+ };
22
+ }
23
+ //# sourceMappingURL=rdfxRdfMatchers.js.map
package/package.json CHANGED
@@ -29,5 +29,5 @@
29
29
  },
30
30
  "type": "module",
31
31
  "types": "./dist/index.d.ts",
32
- "version": "0.0.59"
32
+ "version": "0.0.60"
33
33
  }