UNPKG

machinomy

Version:

Micropayments powered by Ethereum

39 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const PostgresqlMigrator_1 = require("./PostgresqlMigrator"); const sinon = require("sinon"); const chai_1 = require("chai"); describe('PostgresqlMigrator', () => { let migrator = new PostgresqlMigrator_1.default('postgresql://dummy@example.com/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=PostgresqlMigrator.test.js.map