-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import N3Store from './N3Store'; | ||
|
||
export default class N3DatasetCoreFactory { | ||
dataset(quads) { | ||
return new N3Store(quads); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import N3Store from '../src/N3Store'; | ||
import N3DatasetCoreFactory from '../src/N3StoreFactory'; | ||
import DF from '../src/N3DataFactory'; | ||
|
||
const { quad, namedNode } = DF; | ||
|
||
describe('N3DatasetCoreFactory', () => { | ||
let factory; | ||
|
||
beforeEach(() => { | ||
factory = new N3DatasetCoreFactory(); | ||
}); | ||
|
||
it('should create a new dataset with given quads', () => { | ||
const quads = [ | ||
quad(namedNode('http://example.org/subject1'), namedNode('http://example.org/predicate1'), namedNode('http://example.org/object1')), | ||
quad(namedNode('http://example.org/subject2'), namedNode('http://example.org/predicate2'), namedNode('http://example.org/object2')), | ||
]; | ||
|
||
const dataset = factory.dataset(quads); | ||
|
||
expect(dataset).toBeInstanceOf(N3Store); | ||
expect([...dataset.match(namedNode('http://example.org/subject1'))]).toEqual([quads[0]]); | ||
}); | ||
}); |