@@ -273,58 +273,58 @@ describe('Connection', function () {
273
273
done ( ) ;
274
274
}
275
275
} ) ;
276
- } ) ;
277
-
278
- it (
279
- 'should be able to connect again after close' ,
280
- withClient ( function ( client , done ) {
281
- expect ( client . isConnected ( ) ) . to . be . true ;
282
276
283
- const collection = client . db ( 'shouldConnectAfterClose' ) . collection ( 'test' ) ;
284
- collection . insertOne ( { a : 1 , b : 2 } , ( err , result ) => {
285
- expect ( err ) . to . not . exist ;
286
- expect ( result ) . to . exist ;
277
+ it (
278
+ 'should be able to connect again after close' ,
279
+ withClient ( function ( client , done ) {
280
+ expect ( client . isConnected ( ) ) . to . be . true ;
287
281
288
- client . close ( err => {
282
+ const collection = client . db ( 'shouldConnectAfterClose' ) . collection ( 'test' ) ;
283
+ collection . insertOne ( { a : 1 , b : 2 } , ( err , result ) => {
289
284
expect ( err ) . to . not . exist ;
290
- expect ( client . isConnected ( ) ) . to . be . false ;
285
+ expect ( result ) . to . exist ;
291
286
292
- client . connect ( err => {
287
+ client . close ( err => {
293
288
expect ( err ) . to . not . exist ;
294
- expect ( client . isConnected ( ) ) . to . be . true ;
289
+ expect ( client . isConnected ( ) ) . to . be . false ;
295
290
296
- collection . findOne ( { a : 1 } , ( err , result ) => {
291
+ client . connect ( err => {
297
292
expect ( err ) . to . not . exist ;
298
- expect ( result ) . to . exist ;
299
- expect ( result ) . to . have . property ( 'a' , 1 ) ;
300
- expect ( result ) . to . have . property ( 'b' , 2 ) ;
301
- expect ( client . topology . isDestroyed ( ) ) . to . be . false ;
302
- done ( ) ;
293
+ expect ( client . isConnected ( ) ) . to . be . true ;
294
+
295
+ collection . findOne ( { a : 1 } , ( err , result ) => {
296
+ expect ( err ) . to . not . exist ;
297
+ expect ( result ) . to . exist ;
298
+ expect ( result ) . to . have . property ( 'a' , 1 ) ;
299
+ expect ( result ) . to . have . property ( 'b' , 2 ) ;
300
+ expect ( client . topology . isDestroyed ( ) ) . to . be . false ;
301
+ done ( ) ;
302
+ } ) ;
303
303
} ) ;
304
304
} ) ;
305
305
} ) ;
306
- } ) ;
307
- } )
308
- ) ;
309
-
310
- it (
311
- 'should correctly fail on retry when client has been closed' ,
312
- withClient ( function ( client , done ) {
313
- expect ( client . isConnected ( ) ) . to . be . true ;
314
- const collection = client . db ( 'shouldCorrectlyFailOnRetry' ) . collection ( 'test' ) ;
315
- collection . insertOne ( { a : 1 } , ( err , result ) => {
316
- expect ( err ) . to . not . exist ;
317
- expect ( result ) . to . exist ;
318
-
319
- client . close ( true , function ( err ) {
306
+ } )
307
+ ) ;
308
+
309
+ it (
310
+ 'should correctly fail on retry when client has been closed' ,
311
+ withClient ( function ( client , done ) {
312
+ expect ( client . isConnected ( ) ) . to . be . true ;
313
+ const collection = client . db ( 'shouldCorrectlyFailOnRetry' ) . collection ( 'test' ) ;
314
+ collection . insertOne ( { a : 1 } , ( err , result ) => {
320
315
expect ( err ) . to . not . exist ;
321
- expect ( client . isConnected ( ) ) . to . be . false ;
316
+ expect ( result ) . to . exist ;
322
317
323
- expect ( ( ) => {
324
- collection . insertOne ( { a : 2 } ) ;
325
- } ) . to . throw ( / m u s t b e c o n n e c t e d / ) ;
326
- done ( ) ;
318
+ client . close ( true , function ( err ) {
319
+ expect ( err ) . to . not . exist ;
320
+ expect ( client . isConnected ( ) ) . to . be . false ;
321
+
322
+ expect ( ( ) => {
323
+ collection . insertOne ( { a : 2 } ) ;
324
+ } ) . to . throw ( / m u s t b e c o n n e c t e d / ) ;
325
+ done ( ) ;
326
+ } ) ;
327
327
} ) ;
328
- } ) ;
329
- } )
330
- ) ;
328
+ } )
329
+ ) ;
330
+ } ) ;
0 commit comments