Skip to content

Commit

Permalink
Added more plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Dec 11, 2013
1 parent 48bcbb6 commit fa38476
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,44 @@ describe('plugins', function() {
});
});
});

describe('model creation', function() {
var plugin = {
newModel: function(db, collection, schema, options) {
options.done();
}
};

it('should correctly trigger the newModel hook', function(done) {
var model = new Model({
plugins: [plugin],
db: {
collection: function() { return null; }
}
}, 'collection',
{ name: String, age: 'Positive' },
{ done: done });
});
});

describe('instance creation', function() {
var plugin = {
newInstance: function(model, doc, isNew) {
model.options.done();
}
};

it('should correctly trigger the newInstance hook', function(done) {
var model = new Model({
plugins: [plugin]
}, 'collection',
{ name: String, age: 'Positive' },
{ done: done, preprocessors: [] });

var instance = new Instance(model, {
name: 'Test',
age: 10
});
});
});
});

0 comments on commit fa38476

Please sign in to comment.