Skip to content

Commit 2fe5b33

Browse files
jacoscazrubensworks
authored andcommitted
adds tests for Algebra interfaces
1 parent ca4ac66 commit 2fe5b33

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

rdf-js-query-tests.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function test_bindings() {
4747
}
4848
}
4949

50-
async function test_queryable() {
50+
async function test_stringqueryable() {
5151
const engine: StringQueryable<AllMetadataSupport, QueryAlgebraContext> = <any> {};
5252

5353
const query: Query<SparqlResultSupport> = await engine.query('SELECT * WHERE { ... }');
@@ -70,7 +70,7 @@ async function test_queryable() {
7070
}
7171
}
7272

73-
async function test_sparqlqueryable() {
73+
async function test_stringsparqlqueryable() {
7474
const engine: StringSparqlQueryable<SparqlResultSupport> = <any> {};
7575

7676
const bindings: ResultStream<Bindings> = await engine.queryBindings('SELECT * WHERE { ... }');
@@ -79,7 +79,20 @@ async function test_sparqlqueryable() {
7979
const done: void = await engine.queryVoid('INSERT WHERE { ... }');
8080
}
8181

82-
async function test_sparqlqueryable_partial() {
82+
async function test_algebrasparqlqueryable() {
83+
interface AlgebraType { mock: 'algebra' };
84+
const engine: AlgebraSparqlQueryable<AlgebraType, SparqlResultSupport> = <any> {};
85+
86+
const bindings: ResultStream<Bindings> = await engine.queryBindings({ mock: 'algebra' });
87+
const quads: ResultStream<Quad> = await engine.queryQuads({ mock: 'algebra' });
88+
const bool: boolean = await engine.queryBoolean({ mock: 'algebra' });
89+
const done: void = await engine.queryVoid({ mock: 'algebra' });
90+
91+
// @ts-ignore
92+
await engine.queryBoolean('ASK WHERE { ... }'); // Query type doesn't match AlgebraType
93+
}
94+
95+
async function test_stringsparqlqueryable_partial() {
8396
const engine: StringSparqlQueryable<BindingsResultSupport & QuadsResultSupport> = <any> {};
8497

8598
const bindings: ResultStream<Bindings> = await engine.queryBindings('SELECT * WHERE { ... }');
@@ -89,3 +102,15 @@ async function test_sparqlqueryable_partial() {
89102
// @ts-ignore
90103
const done: void = await engine.queryVoid('INSERT WHERE { ... }'); // Unsupported
91104
}
105+
106+
async function test_algebrasparqlqueryable_partial() {
107+
interface AlgebraType { mock: 'algebra' };
108+
const engine: AlgebraSparqlQueryable<AlgebraType, BindingsResultSupport & QuadsResultSupport> = <any> {};
109+
110+
const bindings: ResultStream<Bindings> = await engine.queryBindings({ mock: 'algebra' });
111+
const quads: ResultStream<Quad> = await engine.queryQuads({ mock: 'algebra' });
112+
// @ts-ignore
113+
const bool: boolean = await engine.queryBoolean({ mock: 'algebra' }); // Unsupported
114+
// @ts-ignore
115+
const done: void = await engine.queryVoid({ mock: 'algebra' }); // Unsupported
116+
}

0 commit comments

Comments
 (0)