-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathconnection_pool_events.test.ts
61 lines (56 loc) · 1.77 KB
/
connection_pool_events.test.ts
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
49
50
51
52
53
54
55
56
57
58
59
60
61
import { expect } from 'chai';
import { type ConnectionPool, ConnectionPoolCreatedEvent } from '../../mongodb';
describe('Connection Pool Events', function () {
const connectionPoolMock = {
address: 'localhost:9000',
time: new Date()
};
describe('ConnectionPoolCreatedEvent', function () {
describe('constructor', function () {
context('when provided expected option fields', function () {
it(`Sets the allowed fields appropriately`, function () {
const options = {
maxIdleTimeMS: 0,
maxConnecting: 2,
minPoolSize: 0,
maxPoolSize: 100,
waitQueueTimeoutMS: 1000
};
const event = new ConnectionPoolCreatedEvent({
...connectionPoolMock,
options
} as unknown as ConnectionPool);
expect(event).to.have.deep.property('options', options);
});
});
context('when provided unallowed fields', function () {
it('only stores expected fields', function () {
const options = {
maxIdleTimeMS: 0,
maxConnecting: 2,
minPoolSize: 0,
maxPoolSize: 100,
waitQueueTimeoutMS: 1000,
credentials: {
user: 'user',
pass: 'pass'
},
foo: 'foo',
hello: 'world'
};
const event = new ConnectionPoolCreatedEvent({
...connectionPoolMock,
options
} as unknown as ConnectionPool);
expect(event).to.have.deep.property('options', {
maxIdleTimeMS: 0,
maxConnecting: 2,
minPoolSize: 0,
maxPoolSize: 100,
waitQueueTimeoutMS: 1000
});
});
});
});
});
});