Mercurial > code > home > repos > streamed-graph
diff src/Layout.test.ts @ 104:1aea03d306af
WIP Layout. tests are passing but they're a little wrong
author | drewp@bigasterisk.com |
---|---|
date | Sat, 12 Mar 2022 22:41:43 -0800 |
parents | f12feced00ce |
children |
line wrap: on
line diff
--- a/src/Layout.test.ts Sat Mar 12 00:42:00 2022 -0800 +++ b/src/Layout.test.ts Sat Mar 12 22:41:43 2022 -0800 @@ -1,25 +1,15 @@ -import { Layout, LayoutResult } from "./Layout"; +import { Quad, Store, Term } from "n3"; +import { n3Graph } from "./fetchAndParse"; +import { AlignedTable, Layout, LayoutResult } from "./Layout"; +import { EX, rdf } from "./namespaces"; import { ViewConfig } from "./ViewConfig"; -import { - DataFactory, - Store, - Prefixes, - Parser, - Quad, - NamedNode, - Term, -} from "n3"; -import { EX, rdf } from "./namespaces"; -import Immutable from "immutable"; -import { n3Graph } from "./fetchAndParse"; -const { namedNode } = DataFactory; const twoStatements = async (): Promise<Store> => { return n3Graph(` @prefix : <http://example.com/> . :g1 { - :a :b :c . - :d :e :f . + :a0 :b0 :c0 . + :d0 :e0 :f0 . } `); }; @@ -58,8 +48,8 @@ sections: [ { statements: [ - G1(EX("a"), EX("b"), EX("c")), - G1(EX("d"), EX("e"), EX("f")), + G1(EX("a0"), EX("b0"), EX("c0")), + G1(EX("d0"), EX("e0"), EX("f0")), ], }, ], @@ -76,24 +66,28 @@ <> a :View; :table [ :primaryType :T1 ] .`); const layout = new Layout(vc); - const lr = layout.plan(await typedStatements()); + lr = layout.plan(await typedStatements()); + }); + it("returns 2 sections", ()=>{ expect(lr.sections).toHaveLength(2); - }); + }) it("puts the right type in the table", async () => { - expect(lr.sections[0]).toEqual({ - columnHeaders: [{ rdfType: EX("T1"), pred: EX("color") }], - rows: [ - [EX("a"), EX("red")], - [EX("b"), EX("blue")], - [EX("c"), null], - [EX("e"), null], - ], - }); + const sec0 = lr.sections[0] as AlignedTable; + expect(sec0.columnHeaders).toEqual([ + { rdfType: EX("T1"), pred: EX("color") }, + { rdfType: EX("T1"), pred: EX("size") } + ]) + expect(sec0.rows).toEqual([ + [EX("a"), EX("red"), null], + [EX("b"), EX("blue"),null], + [EX("c"), null, null], + [EX("e"), null, EX('small')], + ]); }); it("leaves the rest ungrouped", async () => { expect(lr.sections[1]).toEqual({ statements: [ - G1(EX("d"), rdf.type, EX("T1")), + G1(EX("d"), rdf.type, EX("T2")), G1(EX("d"), EX("size"), EX("big")), ], });