Skip to content

Commit

Permalink
Add test for optional inverse path
Browse files Browse the repository at this point in the history
  • Loading branch information
pheyvaer committed May 2, 2024
1 parent 6f2c3de commit 6da531c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/07 - mermaid/mermaid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ describe("Test whether the correct Mermaid text is generated for a ShapesGraph",
assert.equal(actualMermaid, expectedMermaid);
});

it("Optional inverse path", async () => {
const actualMermaid = shapesGraph.toMermaid(df.namedNode("http://example.org/OptionalInversePathShape"));
const expectedMermaid = await fs.readFile('./tests/07 - mermaid/optional-inverse-path.txt', 'utf-8');
assert.equal(actualMermaid, expectedMermaid);
});

it("Sequence and inverse path", async () => {
const actualMermaid = shapesGraph.toMermaid(df.namedNode("http://example.org/SequenceAndInversePathShape"));
const expectedMermaid = await fs.readFile('./tests/07 - mermaid/sequence-and-inverse-path.txt', 'utf-8');
Expand Down
3 changes: 3 additions & 0 deletions tests/07 - mermaid/optional-inverse-path.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flowchart TD
S1((Shape))
S1_0[ ]-.->|"http://example.org/p2"|S1
9 changes: 8 additions & 1 deletion tests/07 - mermaid/shape.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@ ex:OptionalSequencePathShape a sh:NodeShape ;
sh:minCount 0
] .

# Path
# Inverse path
ex:InversePathShape a sh:NodeShape ;
sh:property [
sh:path [sh:inversePath ex:p2 ] ;
sh:minCount 1
] .

# Optional inverse path
ex:OptionalInversePathShape a sh:NodeShape ;
sh:property [
sh:path [sh:inversePath ex:p2 ] ;
sh:minCount 0
] .

# Sequence and inverse path
ex:SequenceAndInversePathShape a sh:NodeShape ;
sh:property [
Expand Down

0 comments on commit 6da531c

Please sign in to comment.