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

Commit 75a910b4 by Sushant

(test) findAndCountAll properly clones the options, closes #4191, closes #4378

1 parent 5d0955bb
Showing with 59 additions and 0 deletions
'use strict';
/* jshint -W030 */
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, current = Support.sequelize
, sinon = require('sinon')
, DataTypes = require(__dirname + '/../../../lib/data-types')
, _ = require('lodash');
describe(Support.getTestDialectTeaser('Model'), function() {
describe('method findAndCountAll', function () {
var Model = current.define('model', {
name: DataTypes.STRING
}, { timestamps: false });
var Model2 = current.define('model2', {
name: DataTypes.STRING
}, { timestamps: false });
Model.hasMany(Model2);
Model2.belongsTo(Model);
before(function () {
this.stub = sinon.stub(current.getQueryInterface(), 'select', function () {
return Model.build({});
});
this.stubRaw = sinon.stub(current.getQueryInterface(), 'rawSelect', function () {
return Model.build({});
});
});
beforeEach(function () {
this.stub.reset();
this.stubRaw.reset();
});
after(function () {
this.stub.restore();
this.stubRaw.restore();
});
it('properly clones options values', function() {
var options = {
includes: [
{ model: 'model2', where: {
name: 'hello'
}}
]
};
var optionsClones = _.cloneDeep(options);
return Model.findAndCountAll(options).bind(this).then(function () {
expect(options).to.deep.equal(optionsClones);
});
});
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!