From d60c6959162f213c5a10b041d3c9b634319568a6 Mon Sep 17 00:00:00 2001 From: bergi Date: Sun, 2 Jun 2024 21:55:38 +0200 Subject: [PATCH] chore: adapted code for dependency updates --- index.js | 4 ++-- package.json | 2 +- test/test.js | 33 +++++++++++++++++++++++---------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index fe2b514..1c34e23 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -import URDNA2015Sync from 'rdf-canonize/lib/URDNA2015Sync.js' +import RDFC10Sync from 'rdf-canonize/lib/RDFC10Sync.js' function toJsonldQuad (quad) { return { @@ -25,7 +25,7 @@ function toJsonldDataset (dataset) { } function normalize (dataset) { - const canonize = new URDNA2015Sync() + const canonize = new RDFC10Sync() return canonize.main(toJsonldDataset(dataset)) } diff --git a/package.json b/package.json index 1696464..e02ef8d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "type": "module", "main": "index.js", "scripts": { - "fetch-test-suite": "if [ ! -e test/support/suite ]; then git clone --depth 1 https://github.com/json-ld/normalization.git test/support/suite; fi", + "fetch-test-suite": "if [ ! -e test/support/suite ]; then git clone --depth 1 https://github.com/w3c/rdf-canon.git test/support/suite; fi", "test": "stricter-standard index.js test/test.js test/support/*.js && npm run fetch-test-suite && c8 --reporter=lcov --reporter=text mocha --delay" }, "repository": { diff --git a/test/test.js b/test/test.js index 975b3bf..d9b9b97 100644 --- a/test/test.js +++ b/test/test.js @@ -7,15 +7,12 @@ import { listToArray, readFileContent, readFileDataset } from './support/utils.j const ns = { action: rdf.namedNode('http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action'), entries: rdf.namedNode('http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#entries'), - result: rdf.namedNode('http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result') + result: rdf.namedNode('http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result'), + complexity: rdf.namedNode('https://w3c.github.io/rdf-canon/tests/vocab#computationalComplexity') } const exclude = new Set([ - 'manifest-urdna2015#test023', - 'manifest-urdna2015#test044', - 'manifest-urdna2015#test045', - 'manifest-urdna2015#test046', - 'manifest-urdna2015#test057' + 'manifest#test075c' // ignore SHA384 ]) async function loadTest (dataset, term) { @@ -23,8 +20,24 @@ async function loadTest (dataset, term) { return null } - const action = [...dataset.match(term, ns.action)][0].object.value - const result = [...dataset.match(term, ns.result)][0].object.value + const action = [...dataset.match(term, ns.action)][0]?.object.value + const result = [...dataset.match(term, ns.result)][0]?.object.value + const complexity = [...dataset.match(term, ns.complexity)][0]?.object.value + + if (!action || !result) { + return null + } + + // ignore all map tests + if (term.value.endsWith('m')) { + return null + } + + // ignore all medium or high complexity tests + if (complexity === 'medium' || complexity === 'high') { + return null + } + const input = await readFileDataset(action) const expected = await readFileContent(result) @@ -51,9 +64,9 @@ async function loadTests (filename) { return tests.filter(Boolean) } -loadTests('manifest-urdna2015.ttl').then(tests => { +loadTests('manifest.ttl').then(tests => { describe('@rdfjs/normalize', () => { - describe('RDF Dataset Normalization (URDNA2015)', () => { + describe('RDF Dataset Normalization (RDFC-1.0)', () => { for (const test of tests) { test() }