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

Commit 1da66da2 by Sascha Depold

renamed beforeExit into exit

1 parent 760271a7
...@@ -14,21 +14,28 @@ var initUsers = function(callback) { ...@@ -14,21 +14,28 @@ var initUsers = function(callback) {
}) })
} }
module.exports = { module.exports = {
'all should return all created models': function(beforeExit) { 'all should return all created models': function(exit) {
initUsers(function(user, User) { initUsers(function(_, User) {
User.all.on('success', function(users) { User.all.on('success', function(users) {
assert.eql(users.length, 2) assert.eql(users.length, 2)
beforeExit() exit()
}) })
}) })
}, },
'find should return a single model': function(beforeExit) { 'find should return a single model': function(exit) {
initUsers(function(lastInsertedUser, User) { initUsers(function(lastInsertedUser, User) {
User.find(lastInsertedUser.id).on('success', function(user) { User.find(lastInsertedUser.id).on('success', function(user) {
assert.eql(user.id, lastInsertedUser.id) assert.eql(user.id, lastInsertedUser.id)
beforeExit() exit()
})
})
},
'find a specific user': function(exit) {
initUsers(function(u, User) {
User.find({name: 'foo'}).on('success', function(user) {
assert.eql(user.name, 'foo')
exit()
}) })
}) })
} }
......
...@@ -5,15 +5,15 @@ var assert = require("assert") ...@@ -5,15 +5,15 @@ var assert = require("assert")
, User = sequelize.define('User', { name: Sequelize.STRING, bio: Sequelize.TEXT }) , User = sequelize.define('User', { name: Sequelize.STRING, bio: Sequelize.TEXT })
module.exports = { module.exports = {
'sync should work with correct database config': function(beforeExit) { 'sync should work with correct database config': function(exit) {
User.sync().on('success', beforeExit) User.sync().on('success', exit)
}, },
'sync should fail with incorrect database config': function(beforeExit) { 'sync should fail with incorrect database config': function(exit) {
var s = new Sequelize('foo', 'bar', null, {logging: false}) var s = new Sequelize('foo', 'bar', null, {logging: false})
var User2 = s.define('User', { name: Sequelize.STRING, bio: Sequelize.TEXT }) var User2 = s.define('User', { name: Sequelize.STRING, bio: Sequelize.TEXT })
User2.sync().on('failure', beforeExit) User2.sync().on('failure', exit)
}, },
'drop should work': function(beforeExit) { 'drop should work': function(exit) {
User.drop().on('success', beforeExit) User.drop().on('success', exit)
} }
} }
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!