@@ -9,7 +9,14 @@ import { connect } from '../../../src/cmap/connect';
99import { Connection , CryptoConnection , SizedMessageTransform } from '../../../src/cmap/connection' ;
1010import { MongoNetworkTimeoutError , MongoRuntimeError } from '../../../src/error' ;
1111import { MongoClientAuthProviders } from '../../../src/mongo_client_auth_providers' ;
12- import { isHello , MongoDBCollectionNamespace , ns , promiseWithResolvers } from '../../../src/utils' ;
12+ import {
13+ HostAddress ,
14+ isHello ,
15+ MongoDBCollectionNamespace ,
16+ MongoDBNamespace ,
17+ ns ,
18+ promiseWithResolvers
19+ } from '../../../src/utils' ;
1320import * as mock from '../../tools/mongodb-mock/index' ;
1421
1522const connectionOptionsDefaults = {
@@ -401,15 +408,20 @@ describe('new Connection()', function () {
401408 expect ( error ) . to . be . instanceOf ( MongoRuntimeError ) ;
402409 } ) ;
403410 } ) ;
411+ } ) ;
404412
413+ describe ( 'class CryptoConnection {}' , function ( ) {
405414 it ( 'CryptoConnection.command() throws if no autoEncrypter is configured' , async function ( ) {
406- const error = await connect ( {
415+ const connection = new CryptoConnection ( new Socket ( ) , {
407416 ...connectionOptionsDefaults ,
408- hostAddress : server . hostAddress ( ) ,
417+ hostAddress : HostAddress . fromString ( 'localhost:27017' ) ,
409418 authProviders : new MongoClientAuthProviders ( ) ,
410- connectionType : CryptoConnection ,
411419 extendedMetadata : Promise . resolve ( { } )
412- } ) . catch ( e => e ) ;
420+ } ) ;
421+
422+ const error = await connection
423+ . command ( MongoDBNamespace . fromString ( 'foo.bar' ) , { } , { } )
424+ . catch ( e => e ) ;
413425
414426 expect ( error )
415427 . to . be . instanceOf ( MongoRuntimeError )
0 commit comments