不要怂,就是干,撸起袖子干!

Commit 1e7e4108 by Simon Schick Committed by Sushant

chore(tests): use sinon resolves (#10567)

1 parent 80a79315
......@@ -7,8 +7,7 @@ const chai = require('chai'),
Config = require('../../../config/config'),
ConnectionManager = require('../../../../lib/dialects/abstract/connection-manager'),
Pool = require('sequelize-pool').Pool,
_ = require('lodash'),
Promise = require('../../../../lib/promise');
_ = require('lodash');
const baseConf = Config[Support.getTestDialect()];
const poolEntry = {
......@@ -22,6 +21,7 @@ describe('Connection Manager', () => {
beforeEach(() => {
sandbox = sinon.createSandbox();
sandbox.usingPromise(require('bluebird'));
});
afterEach(() => {
......@@ -75,15 +75,13 @@ describe('Connection Manager', () => {
const sequelize = Support.createSequelizeInstance(options);
const connectionManager = new ConnectionManager(Support.getTestDialect(), sequelize);
const resolvedPromise = new Promise(resolve => {
resolve({
const res = {
queryType: 'read'
});
});
};
const connectStub = sandbox.stub(connectionManager, '_connect').returns(resolvedPromise);
sandbox.stub(connectionManager, '_disconnect').returns(resolvedPromise);
sandbox.stub(sequelize, 'databaseVersion').returns(resolvedPromise);
const connectStub = sandbox.stub(connectionManager, '_connect').resolves(res);
sandbox.stub(connectionManager, '_disconnect').resolves(res);
sandbox.stub(sequelize, 'databaseVersion').resolves(res);
connectionManager.initPools();
const queryOptions = {
......@@ -121,15 +119,12 @@ describe('Connection Manager', () => {
const sequelize = Support.createSequelizeInstance(options);
const connectionManager = new ConnectionManager(Support.getTestDialect(), sequelize);
const resolvedPromise = new Promise(resolve => {
resolve({
const res = {
queryType: 'read'
});
});
const connectStub = sandbox.stub(connectionManager, '_connect').returns(resolvedPromise);
sandbox.stub(connectionManager, '_disconnect').returns(resolvedPromise);
sandbox.stub(sequelize, 'databaseVersion').returns(resolvedPromise);
};
const connectStub = sandbox.stub(connectionManager, '_connect').resolves(res);
sandbox.stub(connectionManager, '_disconnect').resolves(res);
sandbox.stub(sequelize, 'databaseVersion').resolves(res);
connectionManager.initPools();
const queryOptions = {
......
......@@ -186,7 +186,7 @@ if (dialect.match(/^postgres/)) {
it('should handle native postgres timestamp format', () => {
// Make sure nameOidMap is loaded
Support.sequelize.connectionManager.getConnection().then(connection => {
return Support.sequelize.connectionManager.getConnection().then(connection => {
Support.sequelize.connectionManager.releaseConnection(connection);
const tsName = DataTypes.postgres.DATE.types.postgres[0],
......
......@@ -5,19 +5,11 @@ const chai = require('chai'),
Support = require('./support'),
Promise = require('../../lib/promise'),
Transaction = require('../../lib/transaction'),
sinon = require('sinon'),
current = Support.sequelize;
if (current.dialect.supports.transactions) {
describe(Support.getTestDialectTeaser('Sequelize#transaction'), () => {
beforeEach(function() {
this.sinon = sinon.createSandbox();
});
afterEach(function() {
this.sinon.restore();
});
describe('then', () => {
it('gets triggered once a transaction has been successfully committed', function() {
......
'use strict';
const fs = require('fs'),
path = require('path'),
_ = require('lodash'),
Sequelize = require('../index'),
DataTypes = require('../lib/data-types'),
Config = require('./config/config'),
chai = require('chai'),
expect = chai.expect,
AbstractQueryGenerator = require('../lib/dialects/abstract/query-generator');
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
const Sequelize = require('../index');
const DataTypes = require('../lib/data-types');
const Config = require('./config/config');
const chai = require('chai');
const expect = chai.expect;
const AbstractQueryGenerator = require('../lib/dialects/abstract/query-generator');
const sinon = require('sinon');
sinon.usingPromise(require('bluebird'));
chai.use(require('chai-spies'));
chai.use(require('chai-datetime'));
......
......@@ -5,8 +5,6 @@ const sinon = require('sinon');
const expect = chai.expect;
const stub = sinon.stub;
const _ = require('lodash');
const Sequelize = require('../../../index');
const Promise = Sequelize.Promise;
const Support = require('../support');
const DataTypes = require('../../../lib/data-types');
const BelongsTo = require('../../../lib/associations/belongs-to');
......@@ -171,9 +169,9 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
});
beforeEach(function() {
this.findAll = stub(UserTasks, 'findAll').returns(Promise.resolve([]));
this.bulkCreate = stub(UserTasks, 'bulkCreate').returns(Promise.resolve([]));
this.destroy = stub(UserTasks, 'destroy').returns(Promise.resolve([]));
this.findAll = stub(UserTasks, 'findAll').resolves([]);
this.bulkCreate = stub(UserTasks, 'bulkCreate').resolves([]);
this.destroy = stub(UserTasks, 'destroy').resolves([]);
});
afterEach(function() {
......@@ -191,11 +189,11 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
it('uses one delete from statement', function() {
this.findAll
.onFirstCall().returns(Promise.resolve([]))
.onSecondCall().returns(Promise.resolve([
.onFirstCall().resolves([])
.onSecondCall().resolves([
{ userId: 42, taskId: 15 },
{ userId: 42, taskId: 16 }
]));
]);
return user.setTasks([task1, task2]).then(() => {
return user.setTasks(null);
......
......@@ -38,8 +38,8 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
});
beforeEach(function() {
this.findAll = stub(Task, 'findAll').returns(Promise.resolve([]));
this.update = stub(Task, 'update').returns(Promise.resolve([]));
this.findAll = stub(Task, 'findAll').resolves([]);
this.update = stub(Task, 'update').resolves([]);
});
afterEach(function() {
......@@ -56,11 +56,11 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
it('uses one delete from statement', function() {
this.findAll
.onFirstCall().returns(Promise.resolve([]))
.onSecondCall().returns(Promise.resolve([
.onFirstCall().resolves([])
.onSecondCall().resolves([
{ userId: 42, taskId: 15 },
{ userId: 42, taskId: 16 }
]));
]);
return user.setTasks([task1, task2]).then(() => {
this.update.resetHistory();
......@@ -145,10 +145,10 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
foreignKey = 'user_id';
it('should fetch associations for a single instance', () => {
const findAll = stub(Task, 'findAll').returns(Promise.resolve([
const findAll = stub(Task, 'findAll').resolves([
Task.build({}),
Task.build({})
]));
]);
User.Tasks = User.hasMany(Task, { foreignKey });
const actual = User.Tasks.get(User.build({ id: idA }));
......
......@@ -4,32 +4,25 @@ const chai = require('chai'),
sinon = require('sinon'),
expect = chai.expect,
Support = require('./support'),
Sequelize = require('../../index'),
ConnectionManager = require('../../lib/dialects/abstract/connection-manager'),
Promise = Sequelize.Promise;
ConnectionManager = require('../../lib/dialects/abstract/connection-manager');
describe('connection manager', () => {
describe('_connect', () => {
beforeEach(function() {
this.sinon = sinon.createSandbox();
this.connection = {};
this.dialect = {
connectionManager: {
connect: this.sinon.stub().returns(Promise.resolve(this.connection))
connect: sinon.stub().resolves(this.connection)
}
};
this.sequelize = Support.createSequelizeInstance();
});
afterEach(function() {
this.sinon.restore();
});
it('should resolve connection on dialect connection manager', function() {
const connection = {};
this.dialect.connectionManager.connect.returns(Promise.resolve(connection));
this.dialect.connectionManager.connect.resolves(connection);
const connectionManager = new ConnectionManager(this.dialect, this.sequelize);
......
......@@ -23,9 +23,7 @@ if (dialect === 'mssql') {
isolationLevel: 'REPEATABLE_READ',
logging: false
};
sandbox.stub(connectionStub, 'beginTransaction').callsFake(cb => {
cb();
});
sandbox.stub(connectionStub, 'beginTransaction').callsArg(0);
query = new Query(connectionStub, sequelize, options);
});
......
......@@ -35,10 +35,10 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
describe('proxies', () => {
beforeEach(() => {
sinon.stub(current, 'query').returns(Promise.resolve([{
sinon.stub(current, 'query').resolves([{
_previousDataValues: {},
dataValues: { id: 1, name: 'abc' }
}]));
}]);
});
afterEach(() => {
......
......@@ -5,7 +5,6 @@ const expect = chai.expect;
const Support = require('./support');
const InstanceValidator = require('../../lib/instance-validator');
const sinon = require('sinon');
const Promise = Support.Sequelize.Promise;
const SequelizeValidationError = require('../../lib/errors').ValidationError;
describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
......@@ -84,7 +83,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
describe('_validateAndRunHooks', () => {
beforeEach(function() {
this.successfulInstanceValidator = new InstanceValidator(this.User.build());
sinon.stub(this.successfulInstanceValidator, '_validate').returns(Promise.resolve());
sinon.stub(this.successfulInstanceValidator, '_validate').resolves();
});
it('should run beforeValidate and afterValidate hooks when _validate is successful', function() {
......@@ -101,9 +100,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
it('should run beforeValidate hook but not afterValidate hook when _validate is unsuccessful', function() {
const failingInstanceValidator = new InstanceValidator(this.User.build());
sinon.stub(failingInstanceValidator, '_validate').callsFake(() => {
return Promise.reject(new Error());
});
sinon.stub(failingInstanceValidator, '_validate').rejects(new Error());
const beforeValidate = sinon.spy();
const afterValidate = sinon.spy();
this.User.beforeValidate(beforeValidate);
......@@ -126,9 +123,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
describe('validatedFailed hook', () => {
it('should call validationFailed hook when validation fails', function() {
const failingInstanceValidator = new InstanceValidator(this.User.build());
sinon.stub(failingInstanceValidator, '_validate').callsFake(() => {
return Promise.reject(new Error());
});
sinon.stub(failingInstanceValidator, '_validate').rejects(new Error());
const validationFailedHook = sinon.spy();
this.User.validationFailed(validationFailedHook);
......@@ -139,10 +134,8 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
it('should not replace the validation error in validationFailed hook by default', function() {
const failingInstanceValidator = new InstanceValidator(this.User.build());
sinon.stub(failingInstanceValidator, '_validate').callsFake(() => {
return Promise.reject(new SequelizeValidationError());
});
const validationFailedHook = sinon.stub().returns(Promise.resolve());
sinon.stub(failingInstanceValidator, '_validate').rejects(new SequelizeValidationError());
const validationFailedHook = sinon.stub().resolves();
this.User.validationFailed(validationFailedHook);
return expect(failingInstanceValidator._validateAndRunHooks()).to.be.rejected.then(err => {
......@@ -152,9 +145,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
it('should replace the validation error if validationFailed hook creates a new error', function() {
const failingInstanceValidator = new InstanceValidator(this.User.build());
sinon.stub(failingInstanceValidator, '_validate').callsFake(() => {
return Promise.reject(new SequelizeValidationError());
});
sinon.stub(failingInstanceValidator, '_validate').rejects(new SequelizeValidationError());
const validationFailedHook = sinon.stub().throws(new Error('validation failed hook error'));
this.User.validationFailed(validationFailedHook);
......
......@@ -20,11 +20,11 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
before(() => {
stub = sinon.stub(current, 'query').returns(
Sequelize.Promise.resolve({
stub = sinon.stub(current, 'query').resolves(
{
_previousDataValues: { id: 3 },
dataValues: { id: 1 }
})
}
);
});
......
......@@ -20,11 +20,11 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
before(() => {
stub = sinon.stub(current, 'query').returns(
Sequelize.Promise.resolve({
stub = sinon.stub(current, 'query').resolves(
{
_previousDataValues: {},
dataValues: { id: 1 }
})
}
);
});
......
......@@ -20,11 +20,11 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
before(() => {
stub = sinon.stub(current, 'query').returns(
Sequelize.Promise.resolve({
stub = sinon.stub(current, 'query').resolves(
{
_previousDataValues: { id: 1 },
dataValues: { id: 3 }
})
}
);
});
......
......@@ -25,11 +25,11 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
before(() => {
stub = sinon.stub(current, 'query').returns(
Sequelize.Promise.resolve({
stub = sinon.stub(current, 'query').resolves(
{
_previousDataValues: { id: 1 },
dataValues: { id: 2 }
})
}
);
});
......
......@@ -25,11 +25,11 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
before(() => {
stub = sinon.stub(current, 'query').returns(
Sequelize.Promise.resolve([{
stub = sinon.stub(current, 'query').resolves(
[{
_previousDataValues: { id: 1 },
dataValues: { id: 2 }
}, 1])
}, 1]
);
});
......
......@@ -31,11 +31,11 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
before(() => {
stub = sinon.stub(current, 'query').returns(
Sequelize.Promise.resolve([{
stub = sinon.stub(current, 'query').resolves(
[{
_previousDataValues: {},
dataValues: { id: 1 }
}, 1])
}, 1]
);
});
......
......@@ -4,8 +4,6 @@ const chai = require('chai'),
expect = chai.expect,
sinon = require('sinon'),
Support = require('../support'),
Sequelize = require('../../../index'),
Promise = Sequelize.Promise,
DataTypes = require('../../../lib/data-types'),
current = Support.sequelize;
......@@ -20,7 +18,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
}, { timestamps: false });
this.stub = sinon.stub(current.getQueryInterface(), 'bulkInsert').returns(Promise.resolve([]));
this.stub = sinon.stub(current.getQueryInterface(), 'bulkInsert').resolves([]);
});
afterEach(function() {
......
......@@ -6,8 +6,7 @@ const chai = require('chai'),
Sequelize = Support.Sequelize,
current = Support.sequelize,
sinon = require('sinon'),
DataTypes = require('../../../lib/data-types'),
Promise = require('bluebird');
DataTypes = require('../../../lib/data-types');
describe(Support.getTestDialectTeaser('Model'), () => {
describe('method count', () => {
......@@ -15,7 +14,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
this.oldFindAll = Sequelize.Model.findAll;
this.oldAggregate = Sequelize.Model.aggregate;
Sequelize.Model.findAll = sinon.stub().returns(Promise.resolve());
Sequelize.Model.findAll = sinon.stub().resolves();
this.User = current.define('User', {
username: DataTypes.STRING,
......@@ -35,7 +34,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
beforeEach(function() {
this.stub = Sequelize.Model.aggregate = sinon.stub().returns(Promise.resolve());
this.stub = Sequelize.Model.aggregate = sinon.stub().resolves();
});
describe('should pass the same options to model.aggregate as findAndCountAll', () => {
......
......@@ -2,8 +2,6 @@
const chai = require('chai'),
expect = chai.expect,
Sequelize = require('../../../index'),
Promise = Sequelize.Promise,
Support = require('../support'),
current = Support.sequelize,
sinon = require('sinon'),
......@@ -19,9 +17,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
before(function() {
this.stubDelete = sinon.stub(current.getQueryInterface(), 'bulkDelete').callsFake(() => {
return Promise.resolve([]);
});
this.stubDelete = sinon.stub(current.getQueryInterface(), 'bulkDelete').resolves([]);
});
beforeEach(function() {
......
......@@ -23,13 +23,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
age: DataTypes.INTEGER
});
this.findAll = sinon.stub(this.User, 'findAll').callsFake(() => {
return Promise.reject(new Error());
});
this.findAll = sinon.stub(this.User, 'findAll').rejects(new Error());
this.count = sinon.stub(this.User, 'count').callsFake(() => {
return Promise.reject(new Error());
});
this.count = sinon.stub(this.User, 'count').rejects(new Error());
});
after(function() {
......
......@@ -14,6 +14,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
beforeEach(function() {
this.sinon = sinon.createSandbox();
this.sinon.usingPromise(Promise);
});
afterEach(function() {
......@@ -23,7 +24,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should return the result of the first find call if not empty', function() {
const result = {},
where = { prop: Math.random().toString() },
findSpy = this.sinon.stub(Model, 'findOne').returns(Promise.resolve(result));
findSpy = this.sinon.stub(Model, 'findOne').resolves(result);
return expect(Model.findCreateFind({
where
......@@ -36,9 +37,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should create if first find call is empty', function() {
const result = {},
where = { prop: Math.random().toString() },
createSpy = this.sinon.stub(Model, 'create').returns(Promise.resolve(result));
createSpy = this.sinon.stub(Model, 'create').resolves(result);
this.sinon.stub(Model, 'findOne').returns(Promise.resolve(null));
this.sinon.stub(Model, 'findOne').resolves(null);
return expect(Model.findCreateFind({
where
......@@ -52,12 +53,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
where = { prop: Math.random().toString() },
findSpy = this.sinon.stub(Model, 'findOne');
this.sinon.stub(Model, 'create').callsFake(() => {
return Promise.reject(new UniqueConstraintError());
});
this.sinon.stub(Model, 'create').rejects(new UniqueConstraintError());
findSpy.onFirstCall().returns(Promise.resolve(null));
findSpy.onSecondCall().returns(Promise.resolve(result));
findSpy.onFirstCall().resolves(null);
findSpy.onSecondCall().resolves(result);
return expect(Model.findCreateFind({
where
......
......@@ -6,8 +6,7 @@ const chai = require('chai'),
current = Support.sequelize,
cls = require('continuation-local-storage'),
sinon = require('sinon'),
stub = sinon.stub,
Promise = require('bluebird');
stub = sinon.stub;
describe(Support.getTestDialectTeaser('Model'), () => {
......@@ -26,11 +25,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
name: 'John'
});
this.transactionStub = stub(this.User.sequelize, 'transaction');
this.transactionStub.returns(new Promise(() => {}));
this.transactionStub = stub(this.User.sequelize, 'transaction').rejects(new Error('abort'));
this.clsStub = stub(current.constructor._cls, 'get');
this.clsStub.returns({ id: 123 });
this.clsStub = stub(current.constructor._cls, 'get').returns({ id: 123 });
});
afterEach(function() {
......@@ -46,11 +43,16 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
};
this.User.findOrCreate(options);
return this.User.findOrCreate(options)
.then(() => {
expect.fail('expected to fail');
})
.catch(/abort/, () => {
expect(this.clsStub.calledOnce).to.equal(true, 'expected to ask for transaction');
});
});
it('should not use transaction from cls if provided as argument', function() {
const options = {
......@@ -60,9 +62,13 @@ describe(Support.getTestDialectTeaser('Model'), () => {
transaction: { id: 123 }
};
this.User.findOrCreate(options);
return this.User.findOrCreate(options)
.then(() => {
expect.fail('expected to fail');
})
.catch(/abort/, () => {
expect(this.clsStub.called).to.equal(false);
});
});
});
});
......@@ -45,9 +45,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, { timestamps: false });
before(function() {
this.stub = sinon.stub(current.getQueryInterface(), 'select').callsFake(() => {
return Model.build({});
});
this.stub = sinon.stub(current.getQueryInterface(), 'select').callsFake(() => Model.build({}));
this.warnOnInvalidOptionsStub = sinon.stub(Model, 'warnOnInvalidOptions');
});
......
......@@ -5,7 +5,6 @@ const chai = require('chai'),
Support = require('../support'),
Sequelize = Support.Sequelize,
Op = Sequelize.Op,
Promise = Sequelize.Promise,
current = Support.sequelize,
sinon = require('sinon'),
DataTypes = require('../../../lib/data-types');
......@@ -20,7 +19,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
beforeEach(function() {
this.stub = Sequelize.Model.findAll = sinon.stub().returns(Promise.resolve());
this.stub = Sequelize.Model.findAll = sinon.stub().resolves();
});
describe('should not add limit when querying on a primary key', () => {
......
......@@ -2,8 +2,6 @@
const chai = require('chai'),
expect = chai.expect,
Sequelize = require('../../../index'),
Promise = Sequelize.Promise,
Support = require('../support'),
current = Support.sequelize,
sinon = require('sinon'),
......@@ -20,7 +18,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
beforeEach(function() {
this.stubUpdate = sinon.stub(current.getQueryInterface(), 'bulkUpdate').returns(Promise.resolve([]));
this.stubUpdate = sinon.stub(current.getQueryInterface(), 'bulkUpdate').resolves([]);
this.updates = { name: 'Batman', secretValue: '7' };
this.cloneUpdates = _.clone(this.updates);
});
......
......@@ -3,7 +3,6 @@
const chai = require('chai'),
expect = chai.expect,
Sequelize = require('../../../index'),
Promise = Sequelize.Promise,
Support = require('../support'),
current = Support.sequelize,
sinon = require('sinon'),
......@@ -43,14 +42,13 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
beforeEach(function() {
this.sinon = sinon.createSandbox();
this.query = this.sinon.stub(current, 'query').returns(Promise.resolve());
this.stub = this.sinon.stub(current.getQueryInterface(), 'upsert').returns(Promise.resolve([true, undefined]));
this.query = sinon.stub(current, 'query').resolves();
this.stub = sinon.stub(current.getQueryInterface(), 'upsert').resolves([true, undefined]);
});
afterEach(function() {
this.sinon.restore();
this.query.restore();
this.stub.restore();
});
it('skip validations for missing fields', function() {
......
......@@ -273,11 +273,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
before(function() {
this.stub = sinon.stub(current, 'query').callsFake(() => {
return new Promise(resolve => {
resolve([User.build({}), 1]);
});
});
this.stub = sinon.stub(current, 'query').callsFake(() => new Promise.resolve([User.build({}), 1]));
});
after(function() {
......@@ -484,7 +480,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
before(function() {
this.stub = sinon.stub(current, 'query').returns(Promise.resolve([User.build(), 1]));
this.stub = sinon.stub(current, 'query').resolves([User.build(), 1]);
});
after(function() {
......@@ -559,7 +555,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
before(function() {
this.stub = sinon.stub(current, 'query').returns(Promise.resolve([User.build(), 1]));
this.stub = sinon.stub(current, 'query').resolves([User.build(), 1]);
});
after(function() {
......@@ -628,7 +624,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}
});
this.stub = sinon.stub(current, 'query').returns(Promise.resolve([this.User.build(), 1]));
this.stub = sinon.stub(current, 'query').resolves([this.User.build(), 1]);
});
after(function() {
......@@ -697,7 +693,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}
});
this.stub = sinon.stub(current, 'query').returns(Promise.resolve([this.User.build(), 1]));
this.stub = sinon.stub(current, 'query').resolves([this.User.build(), 1]);
});
after(function() {
......
'use strict';
const sinon = require('sinon'),
Sequelize = require('../../../index'),
Promise = Sequelize.Promise,
Support = require('../support'),
DataTypes = require('../../../lib/data-types'),
expectsql = Support.expectsql,
......@@ -24,10 +22,7 @@ if (current.dialect.name !== 'sqlite') {
}, { timestamps: false });
before(function() {
this.stub = sinon.stub(current, 'query').callsFake(sql => {
return Promise.resolve(sql);
});
this.stub = sinon.stub(current, 'query').resolvesArg(0);
});
beforeEach(function() {
......
......@@ -10,16 +10,16 @@ const current = Support.sequelize;
describe('Transaction', () => {
before(function() {
this.stub = sinon.stub(current, 'query').returns(Sequelize.Promise.resolve({}));
this.stub = sinon.stub(current, 'query').resolves({});
this.stubConnection = sinon.stub(current.connectionManager, 'getConnection')
.returns(Sequelize.Promise.resolve({
.resolves({
uuid: 'ssfdjd-434fd-43dfg23-2d',
close() {}
}));
});
this.stubRelease = sinon.stub(current.connectionManager, 'releaseConnection')
.returns(Sequelize.Promise.resolve());
.resolves();
});
beforeEach(function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!