Skip to content

Commit 1ff70bc

Browse files
comments
1 parent 96e2a4e commit 1ff70bc

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

test/unit/cmap/connection.test.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ import { connect } from '../../../src/cmap/connect';
99
import { Connection, CryptoConnection, SizedMessageTransform } from '../../../src/cmap/connection';
1010
import { MongoNetworkTimeoutError, MongoRuntimeError } from '../../../src/error';
1111
import { 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';
1320
import * as mock from '../../tools/mongodb-mock/index';
1421

1522
const 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

Comments
 (0)