machinomy
Version:
Micropayments powered by Ethereum
39 lines • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const sinon = require("sinon");
const chai_1 = require("chai");
const SqliteMigrator_1 = require("./SqliteMigrator");
describe('SqliteMigrator', () => {
let migrator = new SqliteMigrator_1.default('sqlite://./example');
describe('.isLatest', () => {
specify('pass db-migrate.check', async () => {
let trueStub = sinon.stub(migrator.dbmigrate, 'check').returns(Promise.resolve(true));
chai_1.assert.isTrue(await migrator.isLatest());
chai_1.assert.isTrue(trueStub.called);
trueStub.restore();
let falseStub = sinon.stub(migrator.dbmigrate, 'check').returns(Promise.resolve(false));
chai_1.assert.isFalse(await migrator.isLatest());
chai_1.assert.isTrue(falseStub.called);
falseStub.restore();
});
});
describe('.sync', () => {
specify('pass db-migrate.sync', async () => {
let destination = 'n';
let stub = sinon.stub(migrator.dbmigrate, 'sync').returns(Promise.resolve());
await migrator.sync(destination);
chai_1.assert.isTrue(stub.calledWith(destination));
stub.restore();
});
specify('pass latest migration to db-migrate.sync', async () => {
let destination = 'm';
let last = sinon.stub(migrator, 'lastMigrationNumber').returns(Promise.resolve(destination));
let stub = sinon.stub(migrator.dbmigrate, 'sync').returns(Promise.resolve());
await migrator.sync();
chai_1.assert.isTrue(stub.calledWith(destination));
stub.restore();
last.restore();
});
});
});
//# sourceMappingURL=SqliteMigrator.test.js.map