-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathserver_description.test.ts
More file actions
48 lines (38 loc) · 1.64 KB
/
server_description.test.ts
File metadata and controls
48 lines (38 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { expect } from 'chai';
import { MongoClient } from '../../mongodb';
import { configureMongocryptdSpawnHooks } from '../../tools/utils';
describe('class ServerDescription', function () {
describe('when connecting to mongocryptd', { requires: { mongodb: '>=4.4' } }, function () {
let client: MongoClient;
const { port: mongocryptdTestPort } = configureMongocryptdSpawnHooks();
beforeEach(async function () {
client = new MongoClient(`mongodb://localhost:${mongocryptdTestPort}`);
});
afterEach(async function () {
await client?.close();
});
it('iscryptd is set to true ', async function () {
const descriptions = [];
client.on('serverDescriptionChanged', description => descriptions.push(description));
const hello = await client.db().command({ hello: true });
expect(hello).to.have.property('iscryptd', true);
expect(descriptions.at(-1)).to.have.nested.property('newDescription.iscryptd', true);
});
});
describe('when connecting to anything other than mongocryptd', function () {
let client: MongoClient;
beforeEach(async function () {
client = this.configuration.newClient();
});
afterEach(async function () {
await client?.close();
});
it('iscryptd is set to false ', async function () {
const descriptions = [];
client.on('serverDescriptionChanged', description => descriptions.push(description));
const hello = await client.db().command({ hello: true });
expect(hello).to.not.have.property('iscryptd');
expect(descriptions.at(-1)).to.have.nested.property('newDescription.iscryptd', false);
});
});
});