Skip to content

Commit d422319

Browse files
committed
fix: fix broken N3Store tests
1 parent 9d8afd8 commit d422319

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/N3Store.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,36 @@ export default class N3Store {
3232
}
3333

3434
_termFromId(id, factory) {
35-
if (id[0] === '_') {
35+
if (id[0] === '.') {
3636
const entities = this._entities;
37-
const terms = id.split('_');
37+
const terms = id.split('.');
3838
const q = this._factory.quad(
3939
this._termFromId(entities[terms[1]]),
4040
this._termFromId(entities[terms[2]]),
4141
this._termFromId(entities[terms[3]]),
42-
terms[4] && this._termFromId(entities[terms[4]]),
43-
)
42+
terms[4] && this._termFromId(entities[terms[4]])
43+
);
4444
return q;
4545
}
4646
return termFromId(id, factory);
4747
}
4848

4949
_termToId(term) {
50-
if (term.termType === 'Quad') {
50+
if (term && (term.termType === 'Quad')) {
5151
const subject = this._termToId(term.subject),
52-
predicate = this._termToId(term.predicate),
53-
object = this._termToId(term.object),
54-
graph = isDefaultGraph(term.graph) && this._termToId(term.graph),
55-
ids = this._ids,
56-
entities = this._entities;
57-
58-
const res = `_${
59-
ids[subject] || (ids[entities[++this._id] = subject] = this._id)
60-
}_${
61-
ids[predicate] || (ids[entities[++this._id] = predicate] = this._id)
62-
}_${
63-
ids[object] || (ids[entities[++this._id] = object] = this._id)
64-
}${graph ? ('_' + (ids[graph] || (ids[entities[++this._id] = graph] = this._id))) : ''}`;
52+
predicate = this._termToId(term.predicate),
53+
object = this._termToId(term.object),
54+
graph = !isDefaultGraph(term.graph) && this._termToId(term.graph),
55+
ids = this._ids,
56+
entities = this._entities;
57+
58+
const res = `.${
59+
ids[subject] || (ids[entities[++this._id] = subject] = this._id)
60+
}.${
61+
ids[predicate] || (ids[entities[++this._id] = predicate] = this._id)
62+
}.${
63+
ids[object] || (ids[entities[++this._id] = object] = this._id)
64+
}${graph ? (`.${ids[graph] || (ids[entities[++this._id] = graph] = this._id)}`) : ''}`;
6565
return res;
6666
}
6767
return termToId(term);

test/N3Store-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ describe('Store', () => {
304304
});
305305

306306
it('should allow matching using a quad', done => {
307-
const stream = store.removeMatches(termToId(new Quad(new NamedNode('s1'), new NamedNode('p1'), new NamedNode('o1'))));
307+
const stream = store.removeMatches(new Quad(new NamedNode('s1'), new NamedNode('p1'), new NamedNode('o1')));
308308
stream.on('end', () => {
309309
store.size.should.eql(1);
310310
done();

0 commit comments

Comments
 (0)