Skip to content

Commit

Permalink
chore: re-enable entity index tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeswr committed Aug 5, 2024
1 parent 08bf9c1 commit f7871c8
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions test/N3Store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2309,51 +2309,51 @@ describe('Store', () => {
});
});

// describe('EntityIndex', () => {
// let entityIndex;
// beforeEach(() => {
// entityIndex = new EntityIndex();
// });

// it('should be a constructor', () => {
// expect(entityIndex).toBeInstanceOf(EntityIndex);
// });

// it('custom index should be used when instantiated with store', () => {
// const index = {
// '': 1,
// 's1': 2,
// 'p1': 3,
// 'o0': 4,
// 's2': 5,
// 'p2': 6,
// 'o2': 7,
// };

// const store = new Store([
// new Quad(new NamedNode('s1'), new NamedNode('p1'), new NamedNode('o0')),
// ], { entityIndex });
// expect(store.size).toBe(1);
// expect(entityIndex._id).toEqual(4);

// const substore = store.match();
// substore.add(new Quad(new NamedNode('s2'), new NamedNode('p2'), new NamedNode('o2')));
// expect(store.size).toBe(1);
// expect(substore.size).toBe(2);
// expect(entityIndex._id).toEqual(7);
// expect(entityIndex._ids).toEqual(index);

// const store2 = new Store([
// new Quad(new NamedNode('s1'), new NamedNode('p1'), new NamedNode('o5')),
// ], { entityIndex });
// expect(store2.size).toBe(1);
// expect(entityIndex._id).toEqual(8);
// expect(entityIndex._ids).toEqual({
// ...index,
// o5: 8,
// });
// });
// });
describe('EntityIndex', () => {
let entityIndex;
beforeEach(() => {
entityIndex = new EntityIndex();
});

it('should be a constructor', () => {
expect(entityIndex).toBeInstanceOf(EntityIndex);
});

it('custom index should be used when instantiated with store', () => {
const index = {
'': 1,
's1': 2,
'p1': 3,
'o0': 4,
's2': 5,
'p2': 6,
'o2': 7,
};

const store = new Store([
new Quad(new NamedNode('s1'), new NamedNode('p1'), new NamedNode('o0')),
], { entityIndex });
expect(store.size).toBe(1);
expect(entityIndex._id).toEqual(4);

const substore = store.match();
substore.add(new Quad(new NamedNode('s2'), new NamedNode('p2'), new NamedNode('o2')));
expect(store.size).toBe(1);
expect(substore.size).toBe(2);
expect(entityIndex._id).toEqual(7);
expect(entityIndex._ids).toEqual(index);

const store2 = new Store([
new Quad(new NamedNode('s1'), new NamedNode('p1'), new NamedNode('o5')),
], { entityIndex });
expect(store2.size).toBe(1);
expect(entityIndex._id).toEqual(8);
expect(entityIndex._ids).toEqual({
...index,
o5: 8,
});
});
});

function alwaysTrue() { return true; }
function alwaysFalse() { return false; }
Expand Down

0 comments on commit f7871c8

Please sign in to comment.