|
|
@ -11,17 +11,17 @@ const triple = dataModel.quad( |
|
|
|
dataModel.literal("o"), |
|
|
|
dataModel.literal("o"), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
describe("Store", function () { |
|
|
|
describe("Store", () => { |
|
|
|
describe("#add()", function () { |
|
|
|
describe("#add()", () => { |
|
|
|
it("an added quad should be in the store", function () { |
|
|
|
it("an added quad should be in the store", () => { |
|
|
|
const store = new Store(); |
|
|
|
const store = new Store(); |
|
|
|
store.add(dataModel.quad(ex, ex, triple)); |
|
|
|
store.add(dataModel.quad(ex, ex, triple)); |
|
|
|
assert(store.has(dataModel.quad(ex, ex, triple))); |
|
|
|
assert(store.has(dataModel.quad(ex, ex, triple))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe("#delete()", function () { |
|
|
|
describe("#delete()", () => { |
|
|
|
it("an removed quad should not be in the store anymore", function () { |
|
|
|
it("an removed quad should not be in the store anymore", () => { |
|
|
|
const store = new Store([dataModel.quad(triple, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(triple, ex, ex)]); |
|
|
|
assert(store.has(dataModel.quad(triple, ex, ex))); |
|
|
|
assert(store.has(dataModel.quad(triple, ex, ex))); |
|
|
|
store.delete(dataModel.quad(triple, ex, ex)); |
|
|
|
store.delete(dataModel.quad(triple, ex, ex)); |
|
|
@ -29,22 +29,22 @@ describe("Store", function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe("#has()", function () { |
|
|
|
describe("#has()", () => { |
|
|
|
it("an added quad should be in the store", function () { |
|
|
|
it("an added quad should be in the store", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
assert(store.has(dataModel.quad(ex, ex, ex))); |
|
|
|
assert(store.has(dataModel.quad(ex, ex, ex))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe("#size()", function () { |
|
|
|
describe("#size()", () => { |
|
|
|
it("A store with one quad should have 1 for size", function () { |
|
|
|
it("A store with one quad should have 1 for size", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
assert.strictEqual(1, store.size); |
|
|
|
assert.strictEqual(1, store.size); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe("#match_quads()", function () { |
|
|
|
describe("#match_quads()", () => { |
|
|
|
it("blank pattern should return all quads", function () { |
|
|
|
it("blank pattern should return all quads", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const results = store.match(); |
|
|
|
const results = store.match(); |
|
|
|
assert.strictEqual(1, results.length); |
|
|
|
assert.strictEqual(1, results.length); |
|
|
@ -52,32 +52,32 @@ describe("Store", function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe("#query()", function () { |
|
|
|
describe("#query()", () => { |
|
|
|
it("ASK true", function () { |
|
|
|
it("ASK true", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
assert.strictEqual(true, store.query("ASK { ?s ?s ?s }")); |
|
|
|
assert.strictEqual(true, store.query("ASK { ?s ?s ?s }")); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("ASK false", function () { |
|
|
|
it("ASK false", () => { |
|
|
|
const store = new Store(); |
|
|
|
const store = new Store(); |
|
|
|
assert.strictEqual(false, store.query("ASK { FILTER(false)}")); |
|
|
|
assert.strictEqual(false, store.query("ASK { FILTER(false)}")); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("CONSTRUCT", function () { |
|
|
|
it("CONSTRUCT", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const results = store.query("CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }"); |
|
|
|
const results = store.query("CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }"); |
|
|
|
assert.strictEqual(1, results.length); |
|
|
|
assert.strictEqual(1, results.length); |
|
|
|
assert(dataModel.quad(ex, ex, ex).equals(results[0])); |
|
|
|
assert(dataModel.quad(ex, ex, ex).equals(results[0])); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("SELECT", function () { |
|
|
|
it("SELECT", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const results = store.query("SELECT ?s WHERE { ?s ?p ?o }"); |
|
|
|
const results = store.query("SELECT ?s WHERE { ?s ?p ?o }"); |
|
|
|
assert.strictEqual(1, results.length); |
|
|
|
assert.strictEqual(1, results.length); |
|
|
|
assert(ex.equals(results[0].get("s"))); |
|
|
|
assert(ex.equals(results[0].get("s"))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("SELECT with NOW()", function () { |
|
|
|
it("SELECT with NOW()", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const results = store.query( |
|
|
|
const results = store.query( |
|
|
|
"SELECT * WHERE { FILTER(2022 <= YEAR(NOW()) && YEAR(NOW()) <= 2100) }", |
|
|
|
"SELECT * WHERE { FILTER(2022 <= YEAR(NOW()) && YEAR(NOW()) <= 2100) }", |
|
|
@ -85,15 +85,15 @@ describe("Store", function () { |
|
|
|
assert.strictEqual(1, results.length); |
|
|
|
assert.strictEqual(1, results.length); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("SELECT with RAND()", function () { |
|
|
|
it("SELECT with RAND()", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const results = store.query("SELECT (RAND() AS ?y) WHERE {}"); |
|
|
|
const results = store.query("SELECT (RAND() AS ?y) WHERE {}"); |
|
|
|
assert.strictEqual(1, results.length); |
|
|
|
assert.strictEqual(1, results.length); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe("#update()", function () { |
|
|
|
describe("#update()", () => { |
|
|
|
it("INSERT DATA", function () { |
|
|
|
it("INSERT DATA", () => { |
|
|
|
const store = new Store(); |
|
|
|
const store = new Store(); |
|
|
|
store.update( |
|
|
|
store.update( |
|
|
|
"INSERT DATA { <http://example.com> <http://example.com> <http://example.com> }", |
|
|
|
"INSERT DATA { <http://example.com> <http://example.com> <http://example.com> }", |
|
|
@ -101,7 +101,7 @@ describe("Store", function () { |
|
|
|
assert.strictEqual(1, store.size); |
|
|
|
assert.strictEqual(1, store.size); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("DELETE DATA", function () { |
|
|
|
it("DELETE DATA", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
store.update( |
|
|
|
store.update( |
|
|
|
"DELETE DATA { <http://example.com> <http://example.com> <http://example.com> }", |
|
|
|
"DELETE DATA { <http://example.com> <http://example.com> <http://example.com> }", |
|
|
@ -109,15 +109,15 @@ describe("Store", function () { |
|
|
|
assert.strictEqual(0, store.size); |
|
|
|
assert.strictEqual(0, store.size); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("DELETE WHERE", function () { |
|
|
|
it("DELETE WHERE", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex)]); |
|
|
|
store.update("DELETE WHERE { ?v ?v ?v }"); |
|
|
|
store.update("DELETE WHERE { ?v ?v ?v }"); |
|
|
|
assert.strictEqual(0, store.size); |
|
|
|
assert.strictEqual(0, store.size); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe("#load()", function () { |
|
|
|
describe("#load()", () => { |
|
|
|
it("load NTriples in the default graph", function () { |
|
|
|
it("load NTriples in the default graph", () => { |
|
|
|
const store = new Store(); |
|
|
|
const store = new Store(); |
|
|
|
store.load( |
|
|
|
store.load( |
|
|
|
"<http://example.com> <http://example.com> <http://example.com> .", |
|
|
|
"<http://example.com> <http://example.com> <http://example.com> .", |
|
|
@ -126,7 +126,7 @@ describe("Store", function () { |
|
|
|
assert(store.has(dataModel.quad(ex, ex, ex))); |
|
|
|
assert(store.has(dataModel.quad(ex, ex, ex))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("load NTriples in an other graph", function () { |
|
|
|
it("load NTriples in an other graph", () => { |
|
|
|
const store = new Store(); |
|
|
|
const store = new Store(); |
|
|
|
store.load( |
|
|
|
store.load( |
|
|
|
"<http://example.com> <http://example.com> <http://example.com> .", |
|
|
|
"<http://example.com> <http://example.com> <http://example.com> .", |
|
|
@ -137,7 +137,7 @@ describe("Store", function () { |
|
|
|
assert(store.has(dataModel.quad(ex, ex, ex, ex))); |
|
|
|
assert(store.has(dataModel.quad(ex, ex, ex, ex))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("load Turtle with a base IRI", function () { |
|
|
|
it("load Turtle with a base IRI", () => { |
|
|
|
const store = new Store(); |
|
|
|
const store = new Store(); |
|
|
|
store.load( |
|
|
|
store.load( |
|
|
|
"<http://example.com> <http://example.com> <> .", |
|
|
|
"<http://example.com> <http://example.com> <> .", |
|
|
@ -147,7 +147,7 @@ describe("Store", function () { |
|
|
|
assert(store.has(dataModel.quad(ex, ex, ex))); |
|
|
|
assert(store.has(dataModel.quad(ex, ex, ex))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("load NQuads", function () { |
|
|
|
it("load NQuads", () => { |
|
|
|
const store = new Store(); |
|
|
|
const store = new Store(); |
|
|
|
store.load( |
|
|
|
store.load( |
|
|
|
"<http://example.com> <http://example.com> <http://example.com> <http://example.com> .", |
|
|
|
"<http://example.com> <http://example.com> <http://example.com> <http://example.com> .", |
|
|
@ -156,7 +156,7 @@ describe("Store", function () { |
|
|
|
assert(store.has(dataModel.quad(ex, ex, ex, ex))); |
|
|
|
assert(store.has(dataModel.quad(ex, ex, ex, ex))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("load TriG with a base IRI", function () { |
|
|
|
it("load TriG with a base IRI", () => { |
|
|
|
const store = new Store(); |
|
|
|
const store = new Store(); |
|
|
|
store.load( |
|
|
|
store.load( |
|
|
|
"GRAPH <> { <http://example.com> <http://example.com> <> }", |
|
|
|
"GRAPH <> { <http://example.com> <http://example.com> <> }", |
|
|
@ -167,8 +167,8 @@ describe("Store", function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe("#dump()", function () { |
|
|
|
describe("#dump()", () => { |
|
|
|
it("dump dataset content", function () { |
|
|
|
it("dump dataset content", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex, ex)]); |
|
|
|
assert.strictEqual( |
|
|
|
assert.strictEqual( |
|
|
|
"<http://example.com> <http://example.com> <http://example.com> <http://example.com> .\n", |
|
|
|
"<http://example.com> <http://example.com> <http://example.com> <http://example.com> .\n", |
|
|
@ -176,7 +176,7 @@ describe("Store", function () { |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("dump named graph content", function () { |
|
|
|
it("dump named graph content", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex, ex)]); |
|
|
|
assert.strictEqual( |
|
|
|
assert.strictEqual( |
|
|
|
"<http://example.com> <http://example.com> <http://example.com> .\n", |
|
|
|
"<http://example.com> <http://example.com> <http://example.com> .\n", |
|
|
@ -184,7 +184,7 @@ describe("Store", function () { |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("dump default graph content", function () { |
|
|
|
it("dump default graph content", () => { |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex, ex)]); |
|
|
|
const store = new Store([dataModel.quad(ex, ex, ex, ex)]); |
|
|
|
assert.strictEqual("", store.dump("application/n-triples", dataModel.defaultGraph())); |
|
|
|
assert.strictEqual("", store.dump("application/n-triples", dataModel.defaultGraph())); |
|
|
|
}); |
|
|
|
}); |
|
|
|