diff src/layout/Layout.test.ts @ 108:5e6840229a05

rewrite freeStatements rendering to put more planning in layout
author drewp@bigasterisk.com
date Fri, 18 Mar 2022 11:57:38 -0700
parents 2468f2227d22
children cbcd82d21356
line wrap: on
line diff
--- a/src/layout/Layout.test.ts	Sun Mar 13 22:02:30 2022 -0700
+++ b/src/layout/Layout.test.ts	Fri Mar 18 11:57:38 2022 -0700
@@ -47,9 +47,9 @@
     expect(lr).toEqual({
       sections: [
         {
-          statements: [
-            G1(EX("a0"), EX("b0"), EX("c0")),
-            G1(EX("d0"), EX("e0"), EX("f0")),
+          subjRows: [
+            { subj: EX("a0"), predRows: [{ pred: EX("b0"), objs: [EX("c0")] }] },
+            { subj: EX("d0"), predRows: [{ pred: EX("e0"), objs: [EX("f0")] }] },
           ],
         },
       ],
@@ -68,27 +68,32 @@
       const layout = new Layout(vc);
       lr = layout.plan(await typedStatements());
     });
-    it("returns 2 sections", ()=>{
+    it("returns 2 sections", () => {
       expect(lr.sections).toHaveLength(2);
-    })
+    });
     it("puts the right type in the table", async () => {
       const sec0 = lr.sections[0] as AlignedTable;
       expect(sec0.columnHeaders).toEqual([
         { rdfType: EX("T1"), pred: EX("color") },
-        { rdfType: EX("T1"), pred: EX("size") }
-    ])
+        { 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')],
-        ]);
+        [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("T2")),
-          G1(EX("d"), EX("size"), EX("big")),
+        subjRows: [
+          {
+            subj: EX("d"),
+            predRows: [
+              { pred: EX("size"), objs: [EX("big")] },
+              { pred: rdf.type, objs: [EX("T2")] },
+            ],
+          },
         ],
       });
     });