Skip to content

Commit

Permalink
chore: adapted code for dependency updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bergos committed Jun 2, 2024
1 parent 0b1c94b commit d60c695
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import URDNA2015Sync from 'rdf-canonize/lib/URDNA2015Sync.js'
import RDFC10Sync from 'rdf-canonize/lib/RDFC10Sync.js'

function toJsonldQuad (quad) {
return {
Expand All @@ -25,7 +25,7 @@ function toJsonldDataset (dataset) {
}

function normalize (dataset) {
const canonize = new URDNA2015Sync()
const canonize = new RDFC10Sync()

return canonize.main(toJsonldDataset(dataset))
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
33 changes: 23 additions & 10 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,37 @@ 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) {
if (exclude.has(term.value)) {
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)

Expand All @@ -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()
}
Expand Down

0 comments on commit d60c695

Please sign in to comment.