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

You need to sign in or sign up before continuing.
Commit 2cd3002f by sdepold

moved specs

1 parent 835a5f4b
Showing with 32 additions and 33 deletions
...@@ -129,6 +129,38 @@ describe('ModelFactory', function() { ...@@ -129,6 +129,38 @@ describe('ModelFactory', function() {
}) })
}) })
describe('count', function() {
it('counts all created objects', function() {
Helpers.async(function(done) {
User.create({name: 'user1'}).success(function() {
User.create({name: 'user2'}).success(done)
})
})
Helpers.async(function(done) {
User.count().success(function(count) {
expect(count).toEqual(2)
done()
})
})
})
it('filters object', function() {
Helpers.async(function(done) {
User.create({name: 'user1'}).success(function() {
User.create({name: 'foo'}).success(done)
})
})
Helpers.async(function(done) {
User.count({where: "name LIKE '%us%'"}).success(function(count) {
expect(count).toEqual(1)
done()
})
})
})
})
describe('min', function() { describe('min', function() {
it("should return the min value", function() { it("should return the min value", function() {
for(var i = 2; i < 5; i++) Helpers.Factories.User({ age: i }) for(var i = 2; i < 5; i++) Helpers.Factories.User({ age: i })
......
var assert = require("assert")
, config = require("./../config")
, Sequelize = require("./../../index")
, sequelize = new Sequelize(config.database, config.username, config.password, {logging: false, define: { charset: 'latin1' }})
module.exports = {
'it should correctly count all objects': function(exit) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({force: true}).on('success', function() {
User.create({username: 'user1'}).on('success', function() {
User.create({username: 'user2'}).on('success', function() {
User.count().on('success', function(count) {
assert.eql(count, 2)
exit(function(){})
})
})
})
})
},
'it should correctly count filtered objects': function(exit) {
var User = sequelize.define('User', { username: Sequelize.STRING })
User.sync({force: true}).on('success', function() {
User.create({username: 'user1'}).on('success', function() {
User.create({username: 'foo'}).on('success', function() {
User.count({where: "username LIKE '%us%'"}).on('success', function(count) {
assert.eql(count, 1)
exit(function(){})
})
})
})
})
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!