Skip to content

Commit

Permalink
adds tests for Algebra interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoscaz authored and rubensworks committed Feb 17, 2022
1 parent ca4ac66 commit 2fe5b33
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions rdf-js-query-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function test_bindings() {
}
}

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

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

async function test_sparqlqueryable() {
async function test_stringsparqlqueryable() {
const engine: StringSparqlQueryable<SparqlResultSupport> = <any> {};

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

async function test_sparqlqueryable_partial() {
async function test_algebrasparqlqueryable() {
interface AlgebraType { mock: 'algebra' };
const engine: AlgebraSparqlQueryable<AlgebraType, SparqlResultSupport> = <any> {};

const bindings: ResultStream<Bindings> = await engine.queryBindings({ mock: 'algebra' });
const quads: ResultStream<Quad> = await engine.queryQuads({ mock: 'algebra' });
const bool: boolean = await engine.queryBoolean({ mock: 'algebra' });
const done: void = await engine.queryVoid({ mock: 'algebra' });

// @ts-ignore
await engine.queryBoolean('ASK WHERE { ... }'); // Query type doesn't match AlgebraType
}

async function test_stringsparqlqueryable_partial() {
const engine: StringSparqlQueryable<BindingsResultSupport & QuadsResultSupport> = <any> {};

const bindings: ResultStream<Bindings> = await engine.queryBindings('SELECT * WHERE { ... }');
Expand All @@ -89,3 +102,15 @@ async function test_sparqlqueryable_partial() {
// @ts-ignore
const done: void = await engine.queryVoid('INSERT WHERE { ... }'); // Unsupported
}

async function test_algebrasparqlqueryable_partial() {
interface AlgebraType { mock: 'algebra' };
const engine: AlgebraSparqlQueryable<AlgebraType, BindingsResultSupport & QuadsResultSupport> = <any> {};

const bindings: ResultStream<Bindings> = await engine.queryBindings({ mock: 'algebra' });
const quads: ResultStream<Quad> = await engine.queryQuads({ mock: 'algebra' });
// @ts-ignore
const bool: boolean = await engine.queryBoolean({ mock: 'algebra' }); // Unsupported
// @ts-ignore
const done: void = await engine.queryVoid({ mock: 'algebra' }); // Unsupported
}

0 comments on commit 2fe5b33

Please sign in to comment.