This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,21 @@ _beforeEach.withApp = function(app) {
26
26
} ) ;
27
27
}
28
28
29
+ _beforeEach . cleanDatasource = function ( dsName ) {
30
+ beforeEach ( function ( done ) {
31
+ if ( ! dsName ) dsName = 'db' ;
32
+
33
+ if ( typeof this . app === 'function'
34
+ && typeof this . app . datasources === 'object'
35
+ && typeof this . app . datasources [ dsName ] === 'object' ) {
36
+ this . app . datasources [ dsName ] . automigrate ( ) ;
37
+ this . app . datasources [ dsName ] . connector . ids = { } ;
38
+ }
39
+
40
+ done ( ) ;
41
+ } ) ;
42
+ }
43
+
29
44
function mixin ( obj , into ) {
30
45
Object . keys ( obj ) . forEach ( function ( key ) {
31
46
if ( typeof obj [ key ] === 'function' ) {
Original file line number Diff line number Diff line change @@ -86,4 +86,27 @@ describe('helpers', function () {
86
86
} ) ;
87
87
} ) ;
88
88
} ) ;
89
+
90
+ describe ( 'cleanDatasource' , function ( ) {
91
+ helpers . describe . staticMethod ( 'create' , function ( ) {
92
+ helpers . beforeEach . withArgs ( { foo : 'bar' } ) ;
93
+ helpers . describe . whenCalledRemotely ( 'POST' , '/xxx-test-models' , function ( ) {
94
+ it ( 'should call the method over rest' , function ( ) {
95
+ assert . equal ( this . res . statusCode , 200 ) ;
96
+ } ) ;
97
+ } ) ;
98
+ } ) ;
99
+
100
+ helpers . describe . staticMethod ( 'findById' , function ( ) {
101
+ helpers . beforeEach . givenModel ( 'xxx-test-model' , { foo : 'bar' } ) ;
102
+ helpers . beforeEach . cleanDatasource ( ) ;
103
+ helpers . describe . whenCalledRemotely ( 'GET' , function ( ) {
104
+ return '/xxx-test-models/' + this [ 'xxx-test-model' ] . id ;
105
+ } , function ( ) {
106
+ it ( 'should not find the given model' , function ( ) {
107
+ assert . equal ( this . res . statusCode , 404 ) ;
108
+ } ) ;
109
+ } ) ;
110
+ } ) ;
111
+ } ) ;
89
112
} ) ;
You can’t perform that action at this time.
0 commit comments