@@ -71,7 +71,10 @@ describe('mongo db middleware', function() {
7171
7272 describe ( BEFORE_EDIT , function ( ) {
7373 it ( 'has the expected properties on the request object' , function ( done ) {
74+ var middlewareEntranceCount = 0 ;
75+
7476 db . use ( BEFORE_EDIT , function ( request , next ) {
77+ middlewareEntranceCount = middlewareEntranceCount + 1 ;
7578 expect ( request ) . to . have . all . keys ( [
7679 'action' ,
7780 'collectionName' ,
@@ -87,7 +90,6 @@ describe('mongo db middleware', function() {
8790 expect ( request . options . testOptions ) . to . equal ( 'yes' ) ;
8891 expect ( request . query . _id ) . to . equal ( 'test1' ) ;
8992 next ( ) ;
90- done ( ) ;
9193 } ) ;
9294
9395 var snapshot = { type : 'json0' , id : 'test1' , v : 1 , data : { foo : 'bar' } } ;
@@ -98,6 +100,9 @@ describe('mongo db middleware', function() {
98100 if ( err ) return done ( err ) ;
99101 db . commit ( 'testcollection' , snapshot . id , editOp , newSnapshot , { testOptions : 'yes' } , function ( err ) {
100102 if ( err ) return done ( err ) ;
103+
104+ expect ( middlewareEntranceCount ) . to . equal ( 1 ) ;
105+ done ( ) ;
101106 } ) ;
102107 } ) ;
103108 } ) ;
@@ -221,7 +226,10 @@ describe('mongo db middleware', function() {
221226
222227 describe ( BEFORE_SNAPSHOT_LOOKUP , function ( ) {
223228 it ( 'has the expected properties on the request object before getting a single snapshot' , function ( done ) {
229+ var middlewareEntranceCount = 0 ;
230+
224231 db . use ( BEFORE_SNAPSHOT_LOOKUP , function ( request , next ) {
232+ middlewareEntranceCount = middlewareEntranceCount + 1 ;
225233 expect ( request ) . to . have . all . keys ( [
226234 'action' ,
227235 'collectionName' ,
@@ -233,7 +241,6 @@ describe('mongo db middleware', function() {
233241 expect ( request . options . testOptions ) . to . equal ( 'yes' ) ;
234242 expect ( request . query . _id ) . to . equal ( 'test1' ) ;
235243 next ( ) ;
236- done ( ) ;
237244 } ) ;
238245
239246 var snapshot = { type : 'json0' , id : 'test1' , v : 1 , data : { foo : 'bar' } } ;
@@ -242,6 +249,8 @@ describe('mongo db middleware', function() {
242249 db . getSnapshot ( 'testcollection' , 'test1' , null , { testOptions : 'yes' } , function ( err , doc ) {
243250 if ( err ) return done ( err ) ;
244251 expect ( doc ) . to . exist ;
252+ expect ( middlewareEntranceCount ) . to . equal ( 1 ) ;
253+ done ( ) ;
245254 } ) ;
246255 } ) ;
247256 } ) ;
@@ -356,7 +365,9 @@ describe('mongo db middleware', function() {
356365 } ) ;
357366
358367 it ( 'has the expected properties on the request object before getting bulk snapshots' , function ( done ) {
368+ var middlewareEntranceCount = 0 ;
359369 db . use ( BEFORE_SNAPSHOT_LOOKUP , function ( request , next ) {
370+ middlewareEntranceCount = middlewareEntranceCount + 1 ;
360371 expect ( request ) . to . have . all . keys ( [
361372 'action' ,
362373 'collectionName' ,
@@ -368,7 +379,6 @@ describe('mongo db middleware', function() {
368379 expect ( request . options . testOptions ) . to . equal ( 'yes' ) ;
369380 expect ( request . query . _id ) . to . deep . equal ( { $in : [ 'test1' ] } ) ;
370381 next ( ) ;
371- done ( ) ;
372382 } ) ;
373383
374384 var snapshot = { type : 'json0' , id : 'test1' , v : 1 , data : { foo : 'bar' } } ;
@@ -377,6 +387,8 @@ describe('mongo db middleware', function() {
377387 db . getSnapshotBulk ( 'testcollection' , [ 'test1' ] , null , { testOptions : 'yes' } , function ( err , doc ) {
378388 if ( err ) return done ( err ) ;
379389 expect ( doc ) . to . exist ;
390+ expect ( middlewareEntranceCount ) . to . equal ( 1 ) ;
391+ done ( ) ;
380392 } ) ;
381393 } ) ;
382394 } ) ;
0 commit comments