Mercurial > code > home > repos > streamed-graph
diff src/json_ld_quads.test.ts @ 29:45ed53428e74
fix configs to run tests (all in one bundle though)
author | drewp@bigasterisk.com |
---|---|
date | Sun, 15 Dec 2019 21:18:42 -0800 |
parents | 9ec3cbc8791a |
children | 8b4dc9e87b56 |
line wrap: on
line diff
--- a/src/json_ld_quads.test.ts Sun Dec 15 12:38:11 2019 -0800 +++ b/src/json_ld_quads.test.ts Sun Dec 15 21:18:42 2019 -0800 @@ -1,19 +1,26 @@ -//import { eachJsonLdQuad } from './json_ld_quads'; +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 = []; -// // await eachJsonLdQuad([ -// // { -// // "@id": "http://example.com/g1", -// // "@graph": [{ -// // "@id": "http://example.com/s1", -// // "http://example.com/p1": [{ "@value": "lit1" }] -// // }], -// // } -// // ], results.push); -// // expect(results).toEqual('f') -// // }); -// }); \ No newline at end of file +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"); + + }); +}); \ No newline at end of file