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

Commit 47611d44 by Sascha Depold

moved async to factories

1 parent 9d1c45bb
...@@ -8,10 +8,14 @@ Factories.prototype.Model = function(modelName, options, callback, count) { ...@@ -8,10 +8,14 @@ Factories.prototype.Model = function(modelName, options, callback, count) {
var self = this var self = this
this.sequelize.modelManager.getModel(modelName).create(options).on('success', function(model){ this.helpers.async(function(done) {
--count ? self.Model(modelName, options, callback, count) : callback(model) self.sequelize.modelManager.getModel(modelName).create(options).on('success', function(model){
}).on('failure', function(err) { done()
console.log(err) --count ? self.Model(modelName, options, callback, count) : (callback && callback(model))
}).on('failure', function(err) {
console.log(err)
done()
})
}) })
} }
......
...@@ -13,9 +13,7 @@ describe('ModelDefinition', function() { ...@@ -13,9 +13,7 @@ describe('ModelDefinition', function() {
describe('.all', function() { describe('.all', function() {
beforeEach(function() { beforeEach(function() {
Helpers.async(function(done) { Helpers.Factories.User({name: 'user', bio: 'foobar'}, null, 2)
Helpers.Factories.User({name: 'user', bio: 'foobar'}, done, 2)
})
}) })
it("should return all users", function() { it("should return all users", function() {
...@@ -34,12 +32,9 @@ describe('ModelDefinition', function() { ...@@ -34,12 +32,9 @@ describe('ModelDefinition', function() {
var Person = sequelize.define('Person', { name: Sequelize.STRING, options: Sequelize.TEXT }) var Person = sequelize.define('Person', { name: Sequelize.STRING, options: Sequelize.TEXT })
it('should allow the creation of an object with options as attribute', function() { it('should allow the creation of an object with options as attribute', function() {
Helpers.async(function(done) { var options = JSON.stringify({ foo: 'bar', bar: 'foo' })
var options = JSON.stringify({ foo: 'bar', bar: 'foo' }) Helpers.Factories.Model('Person', {name: 'John Doe', options: options}, function(person) {
Helpers.Factories.Model('Person', {name: 'John Doe', options: options}, function(person) { expect(person.options).toEqual(options)
expect(person.options).toEqual(options)
done()
})
}) })
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!