Skip to content

Commit

Permalink
Add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
confused-Techie committed Dec 20, 2024
1 parent bcf7f48 commit 4788055
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions spec/state-store-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ describe('StateStore', () => {
});
});

it('returns a database instance via dbPromise', async () => {
const store = new StateStore(databaseName, version);
const instance = await store.dbPromise;
expect(instance instanceof IDBDatabase).toBe(true);
});

describe('when there is an error reading from the database', () => {
it('rejects the promise returned by load', () => {
const store = new StateStore(databaseName, version);
Expand Down Expand Up @@ -119,5 +125,12 @@ describe('StateStore', () => {
expect(count).toBe(0);
});
});

it('returns a database instance via dbPromise', async () => {
const store = new StateStore(databaseName, version);
const instance = await store.dbPromise;
const Database = require("better-sqlite3");
expect(instance instanceof Database).toBe(true);
});
});
});
2 changes: 1 addition & 1 deletion src/state-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = class StateStore {

get dbPromise() {
// Exposed due to usage in [`project-plus`](https://web.pulsar-edit.dev/packages/project-plus)
return this._getCorrectImplementation().then(i => i.dbPromise());
return this._getCorrectImplementation().then(i => i.dbPromise);
}

_getCorrectImplementation() {
Expand Down

0 comments on commit 4788055

Please sign in to comment.