annotate src/json_ld_quads.test.ts @ 31:e54941d93356

mostly config fixes to try to make this pkg usable by others (not working yet)
author drewp@bigasterisk.com
date Tue, 17 Dec 2019 23:13:01 -0800
parents 45ed53428e74
children 8b4dc9e87b56
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
1 import { eachJsonLdQuad } from './json_ld_quads';
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
2 import { Literal, DataFactory } from 'n3';
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
3 const { literal } = DataFactory;
17
94629c39681c trying to do ts+jest. WIP
drewp@bigasterisk.com
parents:
diff changeset
4
29
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
5 describe("eachJsonLdQuad", () => {
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
6 test("finds multiple graphs", () => {
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
7 });
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
8 test("returns quads", async () => {
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
9 let results: Array<any> = [];
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
10 await eachJsonLdQuad([
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
11 {
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
12 "@id": "http://example.com/g1",
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
13 "@graph": [{
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
14 "@id": "http://example.com/s1",
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
15 "http://example.com/p1": [{ "@value": "lit1" }]
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
16 }],
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
17 }
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
18 ], (res: any) => results.push(res));
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
19 expect(results).toHaveLength(1);
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
20 expect(results[0].subject.value).toEqual("http://example.com/s1");
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
21 expect(results[0].predicate.value).toEqual("http://example.com/p1");
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
22 expect((results[0].object as Literal).equals(literal("lit1"))).toBeTruthy();
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
23 expect(results[0].graph.value).toEqual("http://example.com/g1");
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
24
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
25 });
45ed53428e74 fix configs to run tests (all in one bundle though)
drewp@bigasterisk.com
parents: 20
diff changeset
26 });