Mercurial > code > home > repos > streamed-graph
diff src/layout/Layout.test.ts @ 119:8715633f5213
fancier column sorting to bring preds from the same type together
author | drewp@bigasterisk.com |
---|---|
date | Sun, 20 Mar 2022 01:17:35 -0700 |
parents | c2923b20bf5c |
children | 3584f24becf4 |
line wrap: on
line diff
--- a/src/layout/Layout.test.ts Sun Mar 20 00:54:19 2022 -0700 +++ b/src/layout/Layout.test.ts Sun Mar 20 01:17:35 2022 -0700 @@ -155,7 +155,6 @@ <> a :View; :table [ :primaryType :T1; :joinType :T2 ] . `); - vc.graph.forEach((q) => console.log("vc", q), null, null, null, null); const layout = new Layout(vc); const lr = layout.plan( await n3Graph(` @@ -178,6 +177,32 @@ [[], [EX("big")]], ]); }); + it("groups columns by type", async()=>{ + const vc = new ViewConfig(); + await vc.readFromGraph(` + @prefix ex: <http://example.com/> . + @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . + @prefix : <http://example.com/> . + + <> a :View; :table [ :primaryType :T1; :joinType :T2, :T3 ] . + `); + const layout = new Layout(vc); + const lr = layout.plan( + await n3Graph(` + @prefix : <http://example.com/> . + :g1 { + :a a :T1; :p1 :red; :p3 :green . + :b a :T2; :p2 :blue . + } + `) + ); + const section0 = lr.sections[0] as AlignedTable; + expect(section0.columnHeaders).toEqual([ + { rdfTypes: [EX("T1")], pred: EX("p1") }, + { rdfTypes: [EX("T1")], pred: EX("p3") }, + { rdfTypes: [EX("T2")], pred: EX("p2") }, + ]); + }) }); it.skip("makes a table out of ungrouped triples with the same type", async () => {}); });