Fork of https://github.com/oxigraph/oxigraph.git for the purpose of NextGraph project
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
2.1 KiB
52 lines
2.1 KiB
/* global describe, it */
|
|
|
|
import assert from "node:assert";
|
|
import runTests from "../node_modules/@rdfjs/data-model/test/index.js";
|
|
import oxigraph from "../pkg/oxigraph.js";
|
|
|
|
runTests({ factory: oxigraph });
|
|
|
|
describe("DataModel", () => {
|
|
describe("#toString()", () => {
|
|
it("namedNode().toString() should return SPARQL compatible syntax", () => {
|
|
assert.strictEqual(
|
|
"<http://example.com>",
|
|
oxigraph.namedNode("http://example.com").toString(),
|
|
);
|
|
});
|
|
|
|
it("blankNode().toString() should return SPARQL compatible syntax", () => {
|
|
assert.strictEqual("_:a", oxigraph.blankNode("a").toString());
|
|
});
|
|
|
|
it("literal().toString() should return SPARQL compatible syntax", () => {
|
|
assert.strictEqual('"a\\"b"@en', oxigraph.literal('a"b', "en").toString());
|
|
});
|
|
|
|
it("defaultGraph().toString() should return SPARQL compatible syntax", () => {
|
|
assert.strictEqual("DEFAULT", oxigraph.defaultGraph().toString());
|
|
});
|
|
|
|
it("variable().toString() should return SPARQL compatible syntax", () => {
|
|
assert.strictEqual("?a", oxigraph.variable("a").toString());
|
|
});
|
|
|
|
it("quad().toString() should return SPARQL compatible syntax", () => {
|
|
assert.strictEqual(
|
|
"<http://example.com/s> <http://example.com/p> <<<http://example.com/s1> <http://example.com/p1> <http://example.com/o1>>> <http://example.com/g>",
|
|
oxigraph
|
|
.quad(
|
|
oxigraph.namedNode("http://example.com/s"),
|
|
oxigraph.namedNode("http://example.com/p"),
|
|
oxigraph.quad(
|
|
oxigraph.namedNode("http://example.com/s1"),
|
|
oxigraph.namedNode("http://example.com/p1"),
|
|
oxigraph.namedNode("http://example.com/o1"),
|
|
),
|
|
oxigraph.namedNode("http://example.com/g"),
|
|
)
|
|
.toString(),
|
|
);
|
|
});
|
|
});
|
|
});
|
|
|