File tree Expand file tree Collapse file tree 2 files changed +36
-15
lines changed
Expand file tree Collapse file tree 2 files changed +36
-15
lines changed Original file line number Diff line number Diff line change @@ -18,28 +18,36 @@ describe("db.use()", function () {
1818 } ) ;
1919
2020 it ( "should be able to register a plugin" , function ( done ) {
21- var MyPlugin = function MyPlugin ( DB , opts ) {
22- db . should . equal ( DB ) ;
23- opts . should . eql ( { option : true } ) ;
24-
25- return {
26- define : function ( Model ) {
27- Model . should . be . a ( "function" ) ;
28- Model . id . should . be . a ( "object" ) ;
29- Model . id [ 0 ] . should . be . a ( "string" ) ;
30- calledDefine = true ;
31- }
32- } ;
21+ var MyPlugin = require ( "../support/my_plugin" ) ;
22+ var opts = {
23+ option : true ,
24+ calledDefine : false
3325 } ;
3426
35- db . use ( MyPlugin , { option : true } ) ;
27+ db . use ( MyPlugin , opts ) ;
3628
37- var calledDefine = false ;
3829 var MyModel = db . define ( "my_model" , { // db.define should call plugin.define method
3930 property : String
4031 } ) ;
4132
42- calledDefine . should . be . true ;
33+ opts . calledDefine . should . be . true ;
34+
35+ return done ( ) ;
36+ } ) ;
37+
38+ it ( "should be able to register a plugin as string" , function ( done ) {
39+ var opts = {
40+ option : true ,
41+ calledDefine : false
42+ } ;
43+
44+ db . use ( "../support/my_plugin" , opts ) ;
45+
46+ var MyModel = db . define ( "my_model" , { // db.define should call plugin.define method
47+ property : String
48+ } ) ;
49+
50+ opts . calledDefine . should . be . true ;
4351
4452 return done ( ) ;
4553 } ) ;
Original file line number Diff line number Diff line change 1+ module . exports = function MyPlugin ( DB , opts ) {
2+ opts . should . eql ( { option : true , calledDefine : false } ) ;
3+
4+ return {
5+ define : function ( Model ) {
6+ Model . should . be . a ( "function" ) ;
7+ Model . id . should . be . a ( "object" ) ;
8+ Model . id [ 0 ] . should . be . a ( "string" ) ;
9+
10+ opts . calledDefine = true ;
11+ }
12+ } ;
13+ } ;
You can’t perform that action at this time.
0 commit comments