-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { describe, test, expect } from "vitest"; | ||
import { validate } from "../src"; | ||
import { SimpleStream } from "@ajuvercr/js-runner"; | ||
import { ShaclError } from "../src/error"; | ||
|
||
describe("errors", () => { | ||
test("invalid shacl file path", async () => { | ||
expect.assertions(1); | ||
|
||
const func = validate({ | ||
path: "/tmp/shacl-doesnt-exist.ttl", | ||
incoming: new SimpleStream<string>(), | ||
outgoing: new SimpleStream<string>(), | ||
}); | ||
|
||
expect(func).rejects.toThrow(ShaclError.fileSystemError()); | ||
}); | ||
|
||
test("invalid shacl rdf format", async () => { | ||
expect.assertions(1); | ||
|
||
const func = validate({ | ||
path: "./tests/shacl/invalid.ttl", | ||
incoming: new SimpleStream<string>(), | ||
outgoing: new SimpleStream<string>(), | ||
}); | ||
|
||
expect(func).rejects.toThrow(ShaclError.invalidRdfFormat()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@prefix ex: <http://example.org#> . | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
||
ex:PointShape | ||
a sh:NodeShape; | ||
sh:targetClass ex:Point; | ||
sh:closed true; | ||
sh:ignoredProperties (rdf:type); | ||
sh:property [ | ||
sh:path ex:x; | ||
sh:message "Requires an integer X coordinate"; | ||
sh:name "X-coordinate"; | ||
sh:datatype xsd:integer; | ||
sh:minCount 1; | ||
sh:maxCount 1; | ||
], [ | ||
sh:path ex:y; | ||
sh:message "Requires an integer Y coordinate"; | ||
sh:name "Y-coordinate"; | ||
sh:datatype xsd:integer; | ||
sh:minCount 1; | ||
sh:maxCount 1; | ||
] # NOTE: Intentionally misses a period here! |