Mercurial > code > home > repos > streamed-graph
annotate src/layout/ViewConfig.test.ts @ 122:2e8fa3fec0c8
support joining subjects into wider rows
author | drewp@bigasterisk.com |
---|---|
date | Sun, 20 Mar 2022 14:12:03 -0700 |
parents | 2468f2227d22 |
children |
rev | line source |
---|---|
102 | 1 import { Util } from "n3"; |
122
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
2 import { EX } from "./namespaces"; |
102 | 3 import { ViewConfig } from "./ViewConfig"; |
4 | |
5 describe("ViewModel", () => { | |
6 it("gets a table description", async () => { | |
7 const vc = new ViewConfig(); | |
8 | |
9 await vc.readFromGraph(` | |
10 @prefix ex: <http://example.com/> . | |
11 @prefix demo: <http://example.com/demo/> . | |
12 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | |
13 @prefix : <http://bigasterisk.com/netRoutes/ns#> . | |
14 | |
15 <> a ex:View ; rdfs:label "repos" . | |
16 <> ex:table demo:table1 . | |
122
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
17 demo:table1 |
102 | 18 ex:primaryType :FilteredNic; |
19 ex:joinType :Traffic . | |
20 `); | |
21 const NET = Util.prefix("http://bigasterisk.com/netRoutes/ns#"); | |
22 | |
23 expect(vc.tables[0].primary).toEqual(NET("FilteredNic")); | |
24 expect(vc.tables[0].joins).toEqual([NET("Traffic")]); | |
25 }); | |
122
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
26 it("gets pred joins", async () => { |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
27 const vc = new ViewConfig(); |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
28 await vc.readFromGraph(` |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
29 @prefix ex: <http://example.com/> . |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
30 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
31 @prefix : <http://example.com/> . |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
32 |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
33 <> a :View; :table [ |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
34 :primaryType :T1; |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
35 :link [:predicate :predLink; :rtype :T2 ] ] . |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
36 `); |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
37 expect(vc.tables[0].primary).toEqual(EX("T1")); |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
38 expect(vc.tables[0].links).toEqual([{ pred: EX("predLink") }]); |
2e8fa3fec0c8
support joining subjects into wider rows
drewp@bigasterisk.com
parents:
106
diff
changeset
|
39 }); |
102 | 40 }); |