diff --git a/lib/dao.js b/lib/dao.js index a55d9c9c..81e943ea 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -1284,6 +1284,10 @@ DataAccessObject.removeById = DataAccessObject.destroyById = DataAccessObject.de options = {}; } } + + options = options || {}; + cb = cb || noCallback; + assert(typeof options === 'object', 'The options argument must be an object'); assert(typeof cb === 'function', 'The cb argument must be a function'); diff --git a/test/crud-with-options.test.js b/test/crud-with-options.test.js index 1314732d..c7beef9e 100644 --- a/test/crud-with-options.test.js +++ b/test/crud-with-options.test.js @@ -77,7 +77,7 @@ describe('crud-with-options', function () { }); }); - + describe('findByIds', function () { before(function(done) { @@ -353,6 +353,12 @@ describe('crud-with-options', function () { }); + describe('deleteById', function() { + it('should allow deleteById(id)', function () { + User.deleteById(1); + }); + }); + describe('updateAll ', function () { beforeEach(seed); diff --git a/test/events.js b/test/events.js index b2867591..d78cd2a1 100644 --- a/test/events.js +++ b/test/events.js @@ -14,17 +14,13 @@ describe('events', function() { }); }); this.shouldEmitEvent = function(eventName, listener, done) { - var timeout = setTimeout(function() { - done(new Error('did not emit ' + eventName)); - }, 100); this.TestModel.on(eventName, function() { - clearTimeout(timeout); listener.apply(this, arguments); done(); }); } }); - + describe('changed', function() { it('should be emitted after save', function(done) { var model = new this.TestModel({name: 'foobar'}); @@ -50,7 +46,7 @@ describe('events', function() { }); }); }); - + describe('deleted', function() { it('should be emitted after destroy', function(done) { this.shouldEmitEvent('deleted', assertValidDeletedArgs, done); @@ -61,7 +57,7 @@ describe('events', function() { this.TestModel.deleteById(this.inst.id); }); }); - + describe('deletedAll', function() { it('should be emitted after destroyAll', function(done) { this.shouldEmitEvent('deletedAll', function(where) { @@ -78,4 +74,4 @@ function assertValidChangedArgs(obj) { function assertValidDeletedArgs(id) { id.should.be.ok; -} \ No newline at end of file +}