diff src/layout/json_ld_quads.test.ts @ 106:2468f2227d22

make src/layout/ and src/render/ separation
author drewp@bigasterisk.com
date Sun, 13 Mar 2022 22:00:30 -0700
parents src/json_ld_quads.test.ts@8b4dc9e87b56
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/layout/json_ld_quads.test.ts	Sun Mar 13 22:00:30 2022 -0700
@@ -0,0 +1,29 @@
+import { eachJsonLdQuad } from "./json_ld_quads";
+import { Literal, DataFactory } from "n3";
+const { literal } = DataFactory;
+
+describe("eachJsonLdQuad", () => {
+  test("finds multiple graphs", () => {});
+  test("returns quads", async () => {
+    let results: Array<any> = [];
+    await eachJsonLdQuad(
+      [
+        {
+          "@id": "http://example.com/g1",
+          "@graph": [
+            {
+              "@id": "http://example.com/s1",
+              "http://example.com/p1": [{ "@value": "lit1" }]
+            }
+          ]
+        }
+      ],
+      (res: any) => results.push(res)
+    );
+    expect(results).toHaveLength(1);
+    expect(results[0].subject.value).toEqual("http://example.com/s1");
+    expect(results[0].predicate.value).toEqual("http://example.com/p1");
+    expect((results[0].object as Literal).equals(literal("lit1"))).toBeTruthy();
+    expect(results[0].graph.value).toEqual("http://example.com/g1");
+  });
+});