Skip to content

Commit

Permalink
Merge 8ac7b8f into 36ecf65
Browse files Browse the repository at this point in the history
  • Loading branch information
vhf committed Sep 9, 2019
2 parents 36ecf65 + 8ac7b8f commit 04a76cb
Show file tree
Hide file tree
Showing 14 changed files with 1,237 additions and 459 deletions.
48 changes: 3 additions & 45 deletions src/__tests__/__snapshots__/component.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,7 @@
exports[`filters bound 1`] = `
Operator {
"args": Array [
Dimension {
"componentType": "dimension",
"descending": false,
"iri": NamedNode {
"value": "http://example.com/d",
},
"isDistinct": false,
"label": Literal {
"datatype": NamedNode {
"value": "http://www.w3.org/2001/XMLSchema#string",
},
"language": "",
"value": "d",
},
},
"{\\"componentType\\":\\"dimension\\",\\"iri\\":\\"http://example.com/d\\",\\"labels\\":[{\\"value\\":\\"d\\",\\"language\\":\\"\\"}]}",
],
"operator": "bound",
}
Expand All @@ -28,21 +14,7 @@ Operator {
"args": Array [
Operator {
"args": Array [
Dimension {
"componentType": "dimension",
"descending": false,
"iri": NamedNode {
"value": "http://example.com/d",
},
"isDistinct": false,
"label": Literal {
"datatype": NamedNode {
"value": "http://www.w3.org/2001/XMLSchema#string",
},
"language": "",
"value": "d",
},
},
"{\\"componentType\\":\\"dimension\\",\\"iri\\":\\"http://example.com/d\\",\\"labels\\":[{\\"value\\":\\"d\\",\\"language\\":\\"\\"}]}",
],
"operator": "bound",
},
Expand All @@ -54,21 +26,7 @@ Operator {
exports[`filters not in 1`] = `
Operator {
"args": Array [
Dimension {
"componentType": "dimension",
"descending": false,
"iri": NamedNode {
"value": "http://example.com/d",
},
"isDistinct": false,
"label": Literal {
"datatype": NamedNode {
"value": "http://www.w3.org/2001/XMLSchema#string",
},
"language": "",
"value": "d",
},
},
"{\\"componentType\\":\\"dimension\\",\\"iri\\":\\"http://example.com/d\\",\\"labels\\":[{\\"value\\":\\"d\\",\\"language\\":\\"\\"}]}",
ArrayExpr {
"xs": Array [
NamedNode {
Expand Down
234 changes: 205 additions & 29 deletions src/__tests__/__snapshots__/datasetquery.test.ts.snap

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/__tests__/__snapshots__/serialization.test.ts.snap

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/__tests__/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let d = null;

describe("filters", () => {
beforeAll(() => {
d = new Dimension({ label: "d", iri: "http://example.com/d" });
d = new Dimension({ labels: [{value: "d", language: ""}], iri: "http://example.com/d" });
});

test("bound", () => {
Expand Down
26 changes: 26 additions & 0 deletions src/__tests__/datacube.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { DataCube } from "../datacube";

describe(".datasetByIri()", () => {
it("takes an IRI", async () => {
const cube = new DataCube("https://ld.stadt-zuerich.ch/query");
const datasets = await cube.datasets();
for (const dataset of datasets) {
const iri = dataset.iri;
expect(await cube.datasetByIri(iri)).toBe(dataset);
}
});
});

describe(".datasetsByGraph()", () => {
it("takes a graph IRI", async () => {
const cube = new DataCube("https://ld.stadt-zuerich.ch/query");
const datasets = await cube.datasets();
const cube2 = new DataCube("https://ld.stadt-zuerich.ch/query");
for (const dataset of datasets.slice(0, 3)) {
const graphIri = dataset.graphIri;
const expecting = (await cube2.datasetsByGraphIri(graphIri)).map((ds) => ds.toJSON());
const expected = datasets.filter((ds) => ds.graphIri === graphIri).map((ds) => ds.toJSON());
expect(expecting).toMatchObject(expected);
}
});
});

0 comments on commit 04a76cb

Please sign in to comment.