1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
1
2
import { expect } from 'chai' ;
2
3
import { inspect } from 'util' ;
3
4
@@ -265,11 +266,11 @@ export function specialCheck(
265
266
entities : EntitiesMap ,
266
267
path : string [ ] = [ ] ,
267
268
checkExtraKeys : boolean
268
- ) : boolean {
269
+ ) : void {
269
270
if ( isUnsetOrMatchesOperator ( expected ) ) {
270
271
if ( actual === null || actual === undefined ) return ;
271
272
272
- resultCheck ( actual , expected . $$unsetOrMatches , entities , path , checkExtraKeys ) ;
273
+ resultCheck ( actual , expected . $$unsetOrMatches as any , entities , path , checkExtraKeys ) ;
273
274
} else if ( isMatchesEntityOperator ( expected ) ) {
274
275
// $$matchesEntity
275
276
const entity = entities . get ( expected . $$matchesEntity ) ;
@@ -291,15 +292,15 @@ export function specialCheck(
291
292
// $$sessionLsid
292
293
const session = entities . getEntity ( 'session' , expected . $$sessionLsid , false ) ;
293
294
expect ( session , `Session ${ expected . $$sessionLsid } does not exist in entities` ) . to . exist ;
294
- const entitySessionHex = session . id . id . buffer . toString ( 'hex' ) . toUpperCase ( ) ;
295
+ const entitySessionHex = session . id ! . id . buffer . toString ( 'hex' ) . toUpperCase ( ) ;
295
296
const actualSessionHex = actual . id . buffer . toString ( 'hex' ) . toUpperCase ( ) ;
296
297
expect (
297
298
entitySessionHex ,
298
299
`Session entity ${ expected . $$sessionLsid } does not match lsid`
299
300
) . to . equal ( actualSessionHex ) ;
300
301
} else if ( isTypeOperator ( expected ) ) {
301
302
// $$type
302
- let ok : boolean ;
303
+ let ok = false ;
303
304
const types = Array . isArray ( expected . $$type ) ? expected . $$type : [ expected . $$type ] ;
304
305
for ( const type of types ) {
305
306
ok ||= TYPE_MAP . get ( type ) ( actual ) ;
@@ -365,19 +366,23 @@ function compareCommandStartedEvents(
365
366
entities : EntitiesMap ,
366
367
prefix : string
367
368
) {
368
- if ( expected . command ) {
369
- resultCheck ( actual . command , expected . command , entities , [ `${ prefix } .command` ] ) ;
369
+ if ( expected ! . command ) {
370
+ resultCheck ( actual . command , expected ! . command , entities , [ `${ prefix } .command` ] ) ;
370
371
}
371
- if ( expected . commandName ) {
372
+ if ( expected ! . commandName ) {
372
373
expect (
373
- expected . commandName ,
374
- `expected ${ prefix } .commandName to equal ${ expected . commandName } but received ${ actual . commandName } `
374
+ expected ! . commandName ,
375
+ `expected ${ prefix } .commandName to equal ${ expected ! . commandName } but received ${
376
+ actual . commandName
377
+ } `
375
378
) . to . equal ( actual . commandName ) ;
376
379
}
377
- if ( expected . databaseName ) {
380
+ if ( expected ! . databaseName ) {
378
381
expect (
379
- expected . databaseName ,
380
- `expected ${ prefix } .databaseName to equal ${ expected . databaseName } but received ${ actual . databaseName } `
382
+ expected ! . databaseName ,
383
+ `expected ${ prefix } .databaseName to equal ${ expected ! . databaseName } but received ${
384
+ actual . databaseName
385
+ } `
381
386
) . to . equal ( actual . databaseName ) ;
382
387
}
383
388
}
@@ -388,13 +393,15 @@ function compareCommandSucceededEvents(
388
393
entities : EntitiesMap ,
389
394
prefix : string
390
395
) {
391
- if ( expected . reply ) {
392
- resultCheck ( actual . reply , expected . reply , entities , [ prefix ] ) ;
396
+ if ( expected ! . reply ) {
397
+ resultCheck ( actual . reply as Document , expected ! . reply , entities , [ prefix ] ) ;
393
398
}
394
- if ( expected . commandName ) {
399
+ if ( expected ! . commandName ) {
395
400
expect (
396
- expected . commandName ,
397
- `expected ${ prefix } .commandName to equal ${ expected . commandName } but received ${ actual . commandName } `
401
+ expected ! . commandName ,
402
+ `expected ${ prefix } .commandName to equal ${ expected ! . commandName } but received ${
403
+ actual . commandName
404
+ } `
398
405
) . to . equal ( actual . commandName ) ;
399
406
}
400
407
}
@@ -405,10 +412,12 @@ function compareCommandFailedEvents(
405
412
entities : EntitiesMap ,
406
413
prefix : string
407
414
) {
408
- if ( expected . commandName ) {
415
+ if ( expected ! . commandName ) {
409
416
expect (
410
- expected . commandName ,
411
- `expected ${ prefix } .commandName to equal ${ expected . commandName } but received ${ actual . commandName } `
417
+ expected ! . commandName ,
418
+ `expected ${ prefix } .commandName to equal ${ expected ! . commandName } but received ${
419
+ actual . commandName
420
+ } `
412
421
) . to . equal ( actual . commandName ) ;
413
422
}
414
423
}
@@ -501,7 +510,7 @@ export function expectErrorCheck(
501
510
error : Error | MongoError ,
502
511
expected : ExpectedError ,
503
512
entities : EntitiesMap
504
- ) : boolean {
513
+ ) : void {
505
514
const expectMessage = `\n\nOriginal Error Stack:\n${ error . stack } \n\n` ;
506
515
507
516
if ( ! isMongoCryptError ( error ) ) {
@@ -547,6 +556,6 @@ export function expectErrorCheck(
547
556
}
548
557
549
558
if ( expected . expectResult != null ) {
550
- resultCheck ( error , expected . expectResult , entities ) ;
559
+ resultCheck ( error , expected . expectResult as any , entities ) ;
551
560
}
552
561
}
0 commit comments