+ describe('_initTables', function () {
+ let preparedGet;
+ beforeEach(function () {
+ preparedGet = sinon.stub();
+ sinon.stub(db.db, 'prepare').returns({
+ pluck: () => ({
+ bind: () => ({
+ get: preparedGet,
+ }),
+ }),
+ });
+ sinon.stub(db, '_currentSchema').returns(db.schemaVersionsSupported.min);
+ sinon.stub(db.db, 'exec');
+ });
+ it('covers migration', async function() {
+ preparedGet.returns({});
+ await db._initTables();
+ assert(db.db.exec.called);
+ });
+ it('covers migration failure', async function() {
+ const expected = new Error('oh no');
+ preparedGet.returns({});
+ db.db.exec.throws(expected);
+ try {
+ await db._initTables();
+ assert.fail(noExpectedException);
+ } catch (e) {
+ assert.deepStrictEqual(e, expected);
+ }
+ });
+ }); // _initTables
+