Skip to content

Commit fa38476

Browse files
committed
Added more plugin tests
1 parent 48bcbb6 commit fa38476

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/plugins.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,44 @@ describe('plugins', function() {
3131
});
3232
});
3333
});
34+
35+
describe('model creation', function() {
36+
var plugin = {
37+
newModel: function(db, collection, schema, options) {
38+
options.done();
39+
}
40+
};
41+
42+
it('should correctly trigger the newModel hook', function(done) {
43+
var model = new Model({
44+
plugins: [plugin],
45+
db: {
46+
collection: function() { return null; }
47+
}
48+
}, 'collection',
49+
{ name: String, age: 'Positive' },
50+
{ done: done });
51+
});
52+
});
53+
54+
describe('instance creation', function() {
55+
var plugin = {
56+
newInstance: function(model, doc, isNew) {
57+
model.options.done();
58+
}
59+
};
60+
61+
it('should correctly trigger the newInstance hook', function(done) {
62+
var model = new Model({
63+
plugins: [plugin]
64+
}, 'collection',
65+
{ name: String, age: 'Positive' },
66+
{ done: done, preprocessors: [] });
67+
68+
var instance = new Instance(model, {
69+
name: 'Test',
70+
age: 10
71+
});
72+
});
73+
});
3474
});

0 commit comments

Comments
 (0)