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

Commit 1b49858a by Sushant Committed by Jan Aagaard Meier

(test) Model.count should not return NaN (#6101)

1 parent f232209b
Showing with 36 additions and 1 deletions
...@@ -10,7 +10,8 @@ var chai = require('chai') ...@@ -10,7 +10,8 @@ var chai = require('chai')
describe(Support.getTestDialectTeaser('Model'), function() { describe(Support.getTestDialectTeaser('Model'), function() {
beforeEach(function() { beforeEach(function() {
this.User = this.sequelize.define('User', { this.User = this.sequelize.define('User', {
username: DataTypes.STRING username: DataTypes.STRING,
age: DataTypes.INTEGER
}); });
this.Project = this.sequelize.define('Project', { this.Project = this.sequelize.define('Project', {
name: DataTypes.STRING name: DataTypes.STRING
...@@ -72,5 +73,39 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -72,5 +73,39 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}); });
}); });
it('should not return NaN', function() {
return this.sequelize.sync({ force: true })
.then(() =>
this.User.bulkCreate([
{ username: 'valak' , age: 10},
{ username: 'conjuring' , age: 20},
{ username: 'scary' , age: 10}
])
)
.then(() =>
this.User.count({
where: { age: 10 },
group: ['age'],
order: 'age'
})
)
.then((result) => {
expect(parseInt(result[0].count)).to.be.eql(2);
return this.User.count({
where: { username: 'fire' }
});
})
.then((count) => {
expect(count).to.be.eql(0);
return this.User.count({
where: { username: 'fire' },
group: 'age'
});
})
.then((count) => {
expect(count).to.be.eql([]);
});
});
}); });
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!