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

Commit 649e43cd by Sushant

Fix(#1150) : Test to verify findAll/find properly clone options

1 parent ddce5fb8
...@@ -6,7 +6,8 @@ var chai = require('chai') ...@@ -6,7 +6,8 @@ var chai = require('chai')
, Support = require(__dirname + '/../support') , Support = require(__dirname + '/../support')
, current = Support.sequelize , current = Support.sequelize
, sinon = require('sinon') , sinon = require('sinon')
, DataTypes = require(__dirname + '/../../../lib/data-types'); , DataTypes = require(__dirname + '/../../../lib/data-types')
, _ = require('lodash');
describe(Support.getTestDialectTeaser('Model'), function() { describe(Support.getTestDialectTeaser('Model'), function() {
describe('method findAll', function () { describe('method findAll', function () {
...@@ -87,6 +88,20 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -87,6 +88,20 @@ describe(Support.getTestDialectTeaser('Model'), function() {
]); ]);
}); });
}); });
it('properly clones options values', function() {
var options = {
attributes: {
exclude: ['name'],
include: ['name']
}
};
var optionsClones = _.clone(options);
return Model.findAll(options).bind(this).then(function () {
expect(options).to.deep.equal(optionsClones);
});
});
}); });
}); });
}); });
...@@ -7,7 +7,8 @@ var chai = require('chai') ...@@ -7,7 +7,8 @@ var chai = require('chai')
, current = Support.sequelize , current = Support.sequelize
, sinon = require('sinon') , sinon = require('sinon')
, DataTypes = require(__dirname + '/../../../lib/data-types') , DataTypes = require(__dirname + '/../../../lib/data-types')
, Promise = require('bluebird'); , Promise = require('bluebird')
, _ = require('lodash');
describe(Support.getTestDialectTeaser('Model'), function() { describe(Support.getTestDialectTeaser('Model'), function() {
describe('method findOne', function () { describe('method findOne', function () {
...@@ -67,5 +68,16 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -67,5 +68,16 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect(this.stub.getCall(0).args[0]).to.be.an('object').to.have.property('limit'); expect(this.stub.getCall(0).args[0]).to.be.an('object').to.have.property('limit');
}); });
}); });
it('properly clones options values', function() {
var options = { where: { id: { $gt: 42 }}}
, optionsClones = _.clone(options)
, Model = current.define('model');
return Model.findOne(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!