@@ -66,12 +66,12 @@ class InputStream extends Readable {
66
66
}
67
67
}
68
68
69
- describe ( 'new Connection()' , function ( ) {
69
+ describe ( 'new Connection()' , function ( ) {
70
70
let server ;
71
71
after ( ( ) => mock . cleanup ( ) ) ;
72
72
before ( ( ) => mock . createServer ( ) . then ( s => ( server = s ) ) ) ;
73
73
74
- it ( 'should support fire-and-forget messages' , function ( done ) {
74
+ it ( 'should support fire-and-forget messages' , function ( done ) {
75
75
server . setMessageHandler ( request => {
76
76
const doc = request . document ;
77
77
if ( isHello ( doc ) ) {
@@ -100,7 +100,7 @@ describe('new Connection()', function() {
100
100
} ) ;
101
101
} ) ;
102
102
103
- it ( 'should destroy streams which time out' , function ( done ) {
103
+ it ( 'should destroy streams which time out' , function ( done ) {
104
104
server . setMessageHandler ( request => {
105
105
const doc = request . document ;
106
106
if ( isHello ( doc ) ) {
@@ -131,7 +131,7 @@ describe('new Connection()', function() {
131
131
} ) ;
132
132
} ) ;
133
133
134
- it ( 'should throw a network error with kBeforeHandshake set to false on timeout after handshake' , function ( done ) {
134
+ it ( 'should throw a network error with kBeforeHandshake set to false on timeout after handshake' , function ( done ) {
135
135
server . setMessageHandler ( request => {
136
136
const doc = request . document ;
137
137
if ( isHello ( doc ) ) {
@@ -160,7 +160,7 @@ describe('new Connection()', function() {
160
160
} ) ;
161
161
} ) ;
162
162
163
- it ( 'should throw a network error with kBeforeHandshake set to true on timeout before handshake' , function ( done ) {
163
+ it ( 'should throw a network error with kBeforeHandshake set to true on timeout before handshake' , function ( done ) {
164
164
server . setMessageHandler ( ( ) => {
165
165
// respond to no requests to trigger timeout event
166
166
} ) ;
@@ -181,23 +181,23 @@ describe('new Connection()', function() {
181
181
} ) ;
182
182
} ) ;
183
183
184
- describe ( '#onMessage' , function ( ) {
185
- context ( 'when the connection is a monitoring connection' , function ( ) {
184
+ describe ( '#onMessage' , function ( ) {
185
+ context ( 'when the connection is a monitoring connection' , function ( ) {
186
186
let queue : Map < number , OperationDescription > ;
187
187
let driverSocket : FakeSocket ;
188
188
let connection : Connection ;
189
189
190
- beforeEach ( function ( ) {
190
+ beforeEach ( function ( ) {
191
191
driverSocket = sinon . spy ( new FakeSocket ( ) ) ;
192
192
} ) ;
193
193
194
- context ( 'when multiple hellos exist on the stream' , function ( ) {
194
+ context ( 'when multiple hellos exist on the stream' , function ( ) {
195
195
let callbackSpy ;
196
196
const inputStream = new InputStream ( ) ;
197
197
const document = { ok : 1 } ;
198
198
const last = { isWritablePrimary : true } ;
199
199
200
- beforeEach ( function ( ) {
200
+ beforeEach ( function ( ) {
201
201
callbackSpy = sinon . spy ( ) ;
202
202
const firstHello = generateOpMsgBuffer ( document ) ;
203
203
const secondHello = generateOpMsgBuffer ( document ) ;
@@ -223,18 +223,18 @@ describe('new Connection()', function() {
223
223
inputStream . push ( null ) ;
224
224
} ) ;
225
225
226
- it ( 'calls the callback with the last hello document' , async function ( ) {
226
+ it ( 'calls the callback with the last hello document' , async function ( ) {
227
227
const messages = await once ( connection , 'message' ) ;
228
228
expect ( messages [ 0 ] . responseTo ) . to . equal ( 0 ) ;
229
229
expect ( callbackSpy ) . to . be . calledOnceWith ( undefined , last ) ;
230
230
} ) ;
231
231
} ) ;
232
232
233
- context ( 'when requestId/responseTo do not match' , function ( ) {
233
+ context ( 'when requestId/responseTo do not match' , function ( ) {
234
234
let callbackSpy ;
235
235
const document = { ok : 1 } ;
236
236
237
- beforeEach ( function ( ) {
237
+ beforeEach ( function ( ) {
238
238
callbackSpy = sinon . spy ( ) ;
239
239
240
240
// @ts -expect-error: driverSocket does not fully satisfy the stream type, but that's okay
@@ -265,16 +265,16 @@ describe('new Connection()', function() {
265
265
connection . onMessage ( message ) ;
266
266
} ) ;
267
267
268
- it ( 'calls the operation description callback with the document' , function ( ) {
268
+ it ( 'calls the operation description callback with the document' , function ( ) {
269
269
expect ( callbackSpy ) . to . be . calledOnceWith ( undefined , document ) ;
270
270
} ) ;
271
271
} ) ;
272
272
273
- context ( 'when requestId/reponseTo match' , function ( ) {
273
+ context ( 'when requestId/reponseTo match' , function ( ) {
274
274
let callbackSpy ;
275
275
const document = { ok : 1 } ;
276
276
277
- beforeEach ( function ( ) {
277
+ beforeEach ( function ( ) {
278
278
callbackSpy = sinon . spy ( ) ;
279
279
280
280
// @ts -expect-error: driverSocket does not fully satisfy the stream type, but that's okay
@@ -305,23 +305,23 @@ describe('new Connection()', function() {
305
305
connection . onMessage ( message ) ;
306
306
} ) ;
307
307
308
- it ( 'calls the operation description callback with the document' , function ( ) {
308
+ it ( 'calls the operation description callback with the document' , function ( ) {
309
309
expect ( callbackSpy ) . to . be . calledOnceWith ( undefined , document ) ;
310
310
} ) ;
311
311
} ) ;
312
312
313
- context ( 'when no operation description is in the queue' , function ( ) {
313
+ context ( 'when no operation description is in the queue' , function ( ) {
314
314
const document = { ok : 1 } ;
315
315
316
- beforeEach ( function ( ) {
316
+ beforeEach ( function ( ) {
317
317
// @ts -expect-error: driverSocket does not fully satisfy the stream type, but that's okay
318
318
connection = sinon . spy ( new Connection ( driverSocket , connectionOptionsDefaults ) ) ;
319
319
connection . isMonitoringConnection = true ;
320
320
const queueSymbol = getSymbolFrom ( connection , 'queue' ) ;
321
321
queue = connection [ queueSymbol ] ;
322
322
} ) ;
323
323
324
- it ( 'does not error' , function ( ) {
324
+ it ( 'does not error' , function ( ) {
325
325
const msg = generateOpMsgBuffer ( document ) ;
326
326
const msgHeader : MessageHeader = {
327
327
length : msg . readInt32LE ( 0 ) ,
@@ -338,12 +338,12 @@ describe('new Connection()', function() {
338
338
} ) ;
339
339
} ) ;
340
340
341
- context ( 'when more than one operation description is in the queue' , function ( ) {
341
+ context ( 'when more than one operation description is in the queue' , function ( ) {
342
342
let spyOne ;
343
343
let spyTwo ;
344
344
const document = { ok : 1 } ;
345
345
346
- beforeEach ( function ( ) {
346
+ beforeEach ( function ( ) {
347
347
spyOne = sinon . spy ( ) ;
348
348
spyTwo = sinon . spy ( ) ;
349
349
@@ -380,7 +380,7 @@ describe('new Connection()', function() {
380
380
connection . onMessage ( message ) ;
381
381
} ) ;
382
382
383
- it ( 'calls all operation description callbacks with an error' , function ( ) {
383
+ it ( 'calls all operation description callbacks with an error' , function ( ) {
384
384
expect ( spyOne ) . to . be . calledOnce ;
385
385
expect ( spyTwo ) . to . be . calledOnce ;
386
386
const errorOne = spyOne . firstCall . args [ 0 ] ;
@@ -542,12 +542,12 @@ describe('new Connection()', function() {
542
542
} ) ;
543
543
} ) ;
544
544
545
- describe ( '.hasSessionSupport' , function ( ) {
545
+ describe ( '.hasSessionSupport' , function ( ) {
546
546
let connection ;
547
547
const stream = new Socket ( ) ;
548
548
549
- context ( 'when logicalSessionTimeoutMinutes is present' , function ( ) {
550
- beforeEach ( function ( ) {
549
+ context ( 'when logicalSessionTimeoutMinutes is present' , function ( ) {
550
+ beforeEach ( function ( ) {
551
551
const options = {
552
552
...connectionOptionsDefaults ,
553
553
hostAddress : server . hostAddress ( ) ,
@@ -556,14 +556,14 @@ describe('new Connection()', function() {
556
556
connection = new Connection ( stream , options ) ;
557
557
} ) ;
558
558
559
- it ( 'returns true' , function ( ) {
559
+ it ( 'returns true' , function ( ) {
560
560
expect ( hasSessionSupport ( connection ) ) . to . be . true ;
561
561
} ) ;
562
562
} ) ;
563
563
564
- context ( 'when logicalSessionTimeoutMinutes is not present' , function ( ) {
565
- context ( 'when in load balancing mode' , function ( ) {
566
- beforeEach ( function ( ) {
564
+ context ( 'when logicalSessionTimeoutMinutes is not present' , function ( ) {
565
+ context ( 'when in load balancing mode' , function ( ) {
566
+ beforeEach ( function ( ) {
567
567
const options = {
568
568
...connectionOptionsDefaults ,
569
569
hostAddress : server . hostAddress ( ) ,
@@ -572,13 +572,13 @@ describe('new Connection()', function() {
572
572
connection = new Connection ( stream , options ) ;
573
573
} ) ;
574
574
575
- it ( 'returns true' , function ( ) {
575
+ it ( 'returns true' , function ( ) {
576
576
expect ( hasSessionSupport ( connection ) ) . to . be . true ;
577
577
} ) ;
578
578
} ) ;
579
579
580
- context ( 'when not in load balancing mode' , function ( ) {
581
- beforeEach ( function ( ) {
580
+ context ( 'when not in load balancing mode' , function ( ) {
581
+ beforeEach ( function ( ) {
582
582
const options = {
583
583
...connectionOptionsDefaults ,
584
584
hostAddress : server . hostAddress ( ) ,
@@ -587,7 +587,7 @@ describe('new Connection()', function() {
587
587
connection = new Connection ( stream , options ) ;
588
588
} ) ;
589
589
590
- it ( 'returns false' , function ( ) {
590
+ it ( 'returns false' , function ( ) {
591
591
expect ( hasSessionSupport ( connection ) ) . to . be . false ;
592
592
} ) ;
593
593
} ) ;
@@ -616,7 +616,7 @@ describe('new Connection()', function() {
616
616
clock . restore ( ) ;
617
617
} ) ;
618
618
619
- context ( 'when options.force == true' , function ( ) {
619
+ context ( 'when options.force == true' , function ( ) {
620
620
it ( 'calls steam.destroy' , ( ) => {
621
621
connection . destroy ( { force : true } ) ;
622
622
clock . tick ( 1 ) ;
@@ -650,7 +650,7 @@ describe('new Connection()', function() {
650
650
} ) ;
651
651
} ) ;
652
652
653
- context ( 'when options.force == false' , function ( ) {
653
+ context ( 'when options.force == false' , function ( ) {
654
654
it ( 'calls stream.end' , ( ) => {
655
655
connection . destroy ( { force : false } ) ;
656
656
clock . tick ( 1 ) ;
0 commit comments