Skip to content

Commit 278a7a9

Browse files
authored
Add test to make sure shaclc prefixes are emitted (#66)
1 parent 0ec62c9 commit 278a7a9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/RdfParser-test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,28 @@ describe('parser', () => {
267267
]);
268268
});
269269

270-
it('should parse text/shaclc with baseIRI', () => {
270+
it('should parse text/shaclc with baseIRI', async () => {
271271
const stream = stringToStream(`
272272
BASE <http://localhost:3002/ContactsShape>
273273
PREFIX cont: <http://localhost:3002/ContactsShape#>
274274
275275
shape cont:ContactsShape {}
276276
`);
277-
return expect(arrayifyStream(rdfParser.parse(stream, {contentType: 'text/shaclc'})))
277+
278+
const prefixes: Record<string, string> = {};
279+
const result = arrayifyStream(rdfParser.parse(stream, {contentType: 'text/shaclc'})
280+
.on('prefix', (prefix: string, iri: string) => prefixes[prefix] = iri));
281+
282+
await expect(result)
278283
.resolves.toBeRdfIsomorphic([
279284
quad("http://localhost:3002/ContactsShape#ContactsShape", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www.w3.org/ns/shacl#NodeShape"),
280285
quad("http://localhost:3002/ContactsShape", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www.w3.org/2002/07/owl#Ontology"),
281286
]);
287+
288+
expect(prefixes).toMatchObject({
289+
cont: 'http://localhost:3002/ContactsShape#',
290+
rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
291+
sh: 'http://www.w3.org/ns/shacl#',
292+
});
282293
});
283294
});

0 commit comments

Comments
 (0)