File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -31,4 +31,44 @@ describe('plugins', function() {
31
31
} ) ;
32
32
} ) ;
33
33
} ) ;
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
+ } ) ;
34
74
} ) ;
You can’t perform that action at this time.
0 commit comments