From 37f879fa7ad7f71c25259f9437ba6ffd1a47c79e Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Wed, 8 Jan 2025 18:15:36 +0100 Subject: [PATCH] test: normalise blank nodes --- package-lock.json | 6 +- .../__snapshots__/queryShapes.test.ts.snap | 102 +++++++++--------- packages/hydra/test/lib/queryShapes.test.ts | 4 +- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/package-lock.json b/package-lock.json index 97e5237..319d4b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8898,9 +8898,9 @@ "license": "BSD-3-Clause" }, "node_modules/@zazuko/env": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/@zazuko/env/-/env-2.4.2.tgz", - "integrity": "sha512-mq3YTIs9dmXh2nyS2Hm94bNRHuItlgrp+5QS1zG6ClSpmgztKhMYNRhssmZvd0kBcpYZSV4+EogI/QxrkCg6ww==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@zazuko/env/-/env-2.5.1.tgz", + "integrity": "sha512-FfvogDssZEmWYeVlh/d6q63rEubgtOSvkuDV/2VIB6rz4a3c93OsMQlwasQkMko0+gEJQZoh7VVR8+gaCaCNpw==", "license": "MIT", "dependencies": { "@rdfjs/data-model": "^2.0.1", diff --git a/packages/hydra/test/lib/__snapshots__/queryShapes.test.ts.snap b/packages/hydra/test/lib/__snapshots__/queryShapes.test.ts.snap index d47b40f..72a725f 100644 --- a/packages/hydra/test/lib/__snapshots__/queryShapes.test.ts.snap +++ b/packages/hydra/test/lib/__snapshots__/queryShapes.test.ts.snap @@ -7,25 +7,25 @@ exports[`@kopflos-cms/hydra/lib/queryShapes.js memberQueryShape multiple member @prefix rdf: . @prefix kl: . -_:g7 hydra:subject ; +_:t0 hydra:subject ; hydra:property schema:containsPlace . -_:g6 hydra:property rdf:type ; +_:t1 hydra:property rdf:type ; hydra:object schema:PopulatedPlace . -_:g5 hydra:property rdf:type ; +_:t2 hydra:property rdf:type ; hydra:object . a hydra:Collection ; - hydra:memberAssertion _:g7, _:g6, _:g5 . + hydra:memberAssertion _:t0, _:t1, _:t2 . -_:b284 a sh:NodeShape ; +_:t3 a sh:NodeShape ; sh:target [ rdf:type ; sh:expression [ sh:distinct [ sh:filterShape [ - hydra:memberAssertion _:g7, _:g6, _:g5 ; + hydra:memberAssertion _:t0, _:t1, _:t2 ; ] ; ] ; ] ; @@ -66,26 +66,26 @@ exports[`@kopflos-cms/hydra/lib/queryShapes.js memberQueryShape ordered collecti @prefix rdf: . @prefix kl: . -_:g4 sh:path schema:name . +_:t0 sh:path schema:name . -_:g3 hydra:object ; +_:t1 hydra:object ; hydra:property rdf:type . a hydra:Collection ; - sh:orderBy _:g4 ; - hydra:memberAssertion _:g3 . + sh:orderBy _:t0 ; + hydra:memberAssertion _:t1 . -_:b261 a sh:NodeShape ; +_:t2 a sh:NodeShape ; sh:target [ rdf:type ; sh:expression [ sh:distinct [ sh:limit 10 ; sh:nodes [ - sh:orderBy _:g4 ; + sh:orderBy _:t0 ; sh:nodes [ sh:filterShape [ - hydra:memberAssertion _:g3 ; + hydra:memberAssertion _:t1 ; ] ; ] ; ] ; @@ -118,16 +118,16 @@ exports[`@kopflos-cms/hydra/lib/queryShapes.js memberQueryShape ordered collecti @prefix rdf: . @prefix kl: . -_:g4 sh:path schema:name . +_:t0 sh:path schema:name . -_:g3 hydra:object ; +_:t1 hydra:object ; hydra:property rdf:type . a hydra:Collection ; - sh:orderBy _:g4 ; - hydra:memberAssertion _:g3 . + sh:orderBy _:t0 ; + hydra:memberAssertion _:t1 . -_:b272 a sh:NodeShape ; +_:t2 a sh:NodeShape ; sh:target [ rdf:type ; sh:expression [ @@ -135,10 +135,10 @@ _:b272 a sh:NodeShape ; sh:limit 10 ; sh:nodes [ sh:nodes [ - sh:orderBy _:g4 ; + sh:orderBy _:t0 ; sh:nodes [ sh:filterShape [ - hydra:memberAssertion _:g3 ; + hydra:memberAssertion _:t1 ; ] ; ] ; ] ; @@ -173,26 +173,26 @@ exports[`@kopflos-cms/hydra/lib/queryShapes.js memberQueryShape ordered collecti @prefix rdf: . @prefix kl: . -_:g4 sh:path schema:name . +_:t0 sh:path schema:name . -_:g3 hydra:object ; +_:t1 hydra:object ; hydra:property rdf:type . a hydra:Collection ; - sh:orderBy _:g4 ; - hydra:memberAssertion _:g3 . + sh:orderBy _:t0 ; + hydra:memberAssertion _:t1 . -_:b250 a sh:NodeShape ; +_:t2 a sh:NodeShape ; sh:target [ rdf:type ; sh:expression [ sh:distinct [ sh:offset 5 ; sh:nodes [ - sh:orderBy _:g4 ; + sh:orderBy _:t0 ; sh:nodes [ sh:filterShape [ - hydra:memberAssertion _:g3 ; + hydra:memberAssertion _:t1 ; ] ; ] ; ] ; @@ -225,7 +225,7 @@ exports[`@kopflos-cms/hydra/lib/queryShapes.js memberQueryShape unordered collec @prefix rdf: . @prefix kl: . -_:g1 sh:property [ +_:t1 sh:property [ sh:path schema:name ; ] ; sh:rule [ @@ -240,26 +240,26 @@ _:g1 sh:property [ sh:object ; ] . -_:g0 hydra:object ; +_:t4 hydra:object ; hydra:property rdf:type . a hydra:Collection ; - kl:memberShape _:g1 ; - hydra:memberAssertion _:g0 . + kl:memberShape _:t1 ; + hydra:memberAssertion _:t4 . -_:b242 a sh:NodeShape ; +_:t5 a sh:NodeShape ; sh:target [ rdf:type ; sh:expression [ sh:distinct [ sh:filterShape [ - hydra:memberAssertion _:g0 ; + hydra:memberAssertion _:t4 ; ] ; ] ; ] ; ] ; sh:and ( - _:g1 + _:t1 ) . " @@ -272,28 +272,28 @@ exports[`@kopflos-cms/hydra/lib/queryShapes.js totalsQueryShape multiple member @prefix rdf: . @prefix kl: . -_:g7 hydra:subject ; +_:t0 hydra:subject ; hydra:property schema:containsPlace . -_:g6 hydra:property rdf:type ; +_:t1 hydra:property rdf:type ; hydra:object schema:PopulatedPlace . -_:g5 hydra:property rdf:type ; +_:t2 hydra:property rdf:type ; hydra:object . a hydra:Collection ; - hydra:memberAssertion _:g7, _:g6, _:g5 . + hydra:memberAssertion _:t0, _:t1, _:t2 . -_:b351 a sh:NodeShape ; +_:t4 a sh:NodeShape ; sh:rule [ rdf:type sh:TripleRule ; - sh:subject sh:this ; + sh:subject ; sh:predicate hydra:totalItems ; sh:object [ sh:count [ sh:distinct [ sh:filterShape [ - hydra:memberAssertion _:g7, _:g6, _:g5 ; + hydra:memberAssertion _:t0, _:t1, _:t2 ; ] ; ] ; ] ; @@ -310,25 +310,25 @@ exports[`@kopflos-cms/hydra/lib/queryShapes.js totalsQueryShape ordered collecti @prefix rdf: . @prefix kl: . -_:g3 hydra:object ; +_:t1 hydra:object ; hydra:property rdf:type . a hydra:Collection ; sh:orderBy [ sh:path schema:name ; ] ; - hydra:memberAssertion _:g3 . + hydra:memberAssertion _:t1 . -_:b345 a sh:NodeShape ; +_:t3 a sh:NodeShape ; sh:rule [ rdf:type sh:TripleRule ; - sh:subject sh:this ; + sh:subject ; sh:predicate hydra:totalItems ; sh:object [ sh:count [ sh:distinct [ sh:filterShape [ - hydra:memberAssertion _:g3 ; + hydra:memberAssertion _:t1 ; ] ; ] ; ] ; @@ -345,7 +345,7 @@ exports[`@kopflos-cms/hydra/lib/queryShapes.js totalsQueryShape unordered collec @prefix rdf: . @prefix kl: . -_:g0 hydra:object ; +_:t2 hydra:object ; hydra:property rdf:type . a hydra:Collection ; @@ -354,18 +354,18 @@ _:g0 hydra:object ; sh:path schema:name ; ] ; ] ; - hydra:memberAssertion _:g0 . + hydra:memberAssertion _:t2 . -_:b296 a sh:NodeShape ; +_:t4 a sh:NodeShape ; sh:rule [ rdf:type sh:TripleRule ; - sh:subject sh:this ; + sh:subject ; sh:predicate hydra:totalItems ; sh:object [ sh:count [ sh:distinct [ sh:filterShape [ - hydra:memberAssertion _:g0 ; + hydra:memberAssertion _:t2 ; ] ; ] ; ] ; diff --git a/packages/hydra/test/lib/queryShapes.test.ts b/packages/hydra/test/lib/queryShapes.test.ts index 1fbe29d..87f39ed 100644 --- a/packages/hydra/test/lib/queryShapes.test.ts +++ b/packages/hydra/test/lib/queryShapes.test.ts @@ -1,5 +1,4 @@ import env from '@zazuko/env-node' -import type { Dataset } from '@zazuko/env/lib/DatasetExt.js' import { expect, use } from 'chai' import snapshots from 'mocha-chai-rdf/snapshots.js' import { createStore } from 'mocha-chai-rdf/store.js' @@ -126,8 +125,9 @@ describe('@kopflos-cms/hydra/lib/queryShapes.js', () => { }) function serialize(dataset: DatasetCore) { - return (dataset as Dataset).serialize({ + return env.dataset.serialize(dataset, { format: 'text/turtle', prefixes: ['sh', 'hydra', 'schema', 'rdf', ['kl', kl().value]], + renameBlankNodes: true, }) }