Skip to content

Commit c05cb8a

Browse files
committed
test: add no-op processing tests
1 parent 145b6d8 commit c05cb8a

4 files changed

Lines changed: 61 additions & 3 deletions

File tree

package-lock.json

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/processor/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@types/rdfjs__term-set": "^2.0.0",
2525
"@zazuko/env": "^2",
2626
"chai": "^5.2.0",
27+
"glob": "^11.0.2",
2728
"sparqljs": "^3.7.3"
2829
},
2930
"mocha": {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import * as url from 'node:url'
2+
import path from 'node:path'
3+
import rdf from '@zazuko/env/web.js'
4+
import { glob } from 'glob'
5+
import { expect } from 'chai'
6+
import QueryProcessor from '../index.js'
7+
import { loadQuery, stringifyQuery } from './lib/query.js'
8+
9+
const cwd = url.fileURLToPath(new URL('.', import.meta.url))
10+
11+
describe('@hydrofoil/sparql-processor', () => {
12+
describe('QueryProcessor', () => {
13+
context('no-op processing', () => {
14+
glob.sync('queries/*.{rq,ru}', { cwd }).forEach((file) => {
15+
const name = path.basename(file)
16+
17+
it(`does not modify the query (${name})`, () => {
18+
const processor = new (class extends QueryProcessor {})(rdf)
19+
20+
const processed = processor.process(loadQuery(name))
21+
22+
expect(stringifyQuery(processed))
23+
.to.deep.equal(stringifyQuery(loadQuery(name)))
24+
})
25+
})
26+
})
27+
})
28+
})
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
base <http://example.org/>
2+
3+
INSERT DATA {
4+
GRAPH <urn:example:graph> {
5+
<airport> a <urn:example:Airport> ;
6+
}
7+
};
8+
9+
INSERT {
10+
?airport a <urn:example:Airport> ;
11+
}
12+
WHERE {
13+
GRAPH <urn:example:graph> {
14+
?airport a <urn:example:Airport> ;
15+
}
16+
};
17+
18+
DELETE {
19+
GRAPH <urn:example:graph> {
20+
?airport a <urn:example:Airport> ;
21+
}
22+
}
23+
WHERE {
24+
GRAPH <urn:example:graph> {
25+
?airport a <urn:example:Airport> ;
26+
}
27+
}

0 commit comments

Comments
 (0)