Skip to content

Commit

Permalink
feat: add default for implicitDatasetFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
jeswr committed Sep 14, 2022
1 parent bf0f397 commit 75163cb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions engines/query-sparql-file-reasoning/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
"@comunica/reasoning-context-entries": "^0.1.0",
"@comunica/runner": "^2.4.0",
"@comunica/runner-cli": "^2.4.0",
"@comunica/actor-context-preprocess-reasoning-defaults": "^0.0.0",
"n3": "^1.16.2"
},
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions engines/query-sparql-reasoning/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
"@comunica/reasoning-context-entries": "^0.1.0",
"@comunica/runner": "^2.4.0",
"@comunica/runner-cli": "^2.4.0",
"@comunica/actor-context-preprocess-reasoning-defaults": "^0.0.0",
"n3": "^1.16.2"
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ActorContextPreprocess, IActorContextPreprocessOutput, IActorContextPreprocessArgs } from '@comunica/bus-context-preprocess';
import { IActorArgs, IActorTest, IAction } from '@comunica/core';
import type { IActorContextPreprocessOutput, IActorContextPreprocessArgs } from '@comunica/bus-context-preprocess';
import { ActorContextPreprocess } from '@comunica/bus-context-preprocess';
import type { IActorTest, IAction } from '@comunica/core';
import { KeysRdfReason } from '@comunica/reasoning-context-entries';
import { Store } from 'n3';

Expand All @@ -18,7 +19,7 @@ export class ActorContextPreprocessReasoningDefaults extends ActorContextPreproc
public async run(action: IAction): Promise<IActorContextPreprocessOutput> {
return {
context: action.context
.setDefault(KeysRdfReason.implicitDatasetFactory, () => new Store())
}
.setDefault(KeysRdfReason.implicitDatasetFactory, () => new Store()),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
"lib/**/*.js"
],
"dependencies": {
"@comunica/bus-context-preprocess": "^2.4.0",
"@comunica/core": "^2.4.0",
"@comunica/bus-context-preprocess": "^2.4.0"
"@comunica/reasoning-context-entries": "^0.1.0",
"n3": "^1.16.2"
},
"scripts": {
"build": "npm run build:ts && npm run build:components",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ describe('ActorContextPreprocessReasoningDefaults', () => {
return expect(actor.test({ context: new ActionContext() })).resolves.toEqual(true);
});

it('should use N3Store default when no implicitDatasetFactory is available', async () => {
it('should use N3Store default when no implicitDatasetFactory is available', async() => {
const { context } = await actor.run({ context: new ActionContext() });
const factory = context.getSafe<() => any>(KeysRdfReason.implicitDatasetFactory)();
expect(factory).toBeInstanceOf(Store);
});

it('should use N3Store when implicitDatasetFactory is store input', async () => {
it('should use N3Store when implicitDatasetFactory is store input', async() => {
const { context } = await actor.run({ context: new ActionContext({
[KeysRdfReason.implicitDatasetFactory.name]: () => new Store(),
}) });
const factory = context.getSafe<() => any>(KeysRdfReason.implicitDatasetFactory)();
expect(factory).toBeInstanceOf(Store);
});

it('should use string when implicitDatasetFactory is string input', async () => {
it('should use string when implicitDatasetFactory is string input', async() => {
const { context } = await actor.run({ context: new ActionContext({
[KeysRdfReason.implicitDatasetFactory.name]: () => 'http://example.org',
}) });
Expand Down

0 comments on commit 75163cb

Please sign in to comment.