Skip to content

Commit 58d8976

Browse files
unit tests and integration tests
1 parent 1d1c89e commit 58d8976

3 files changed

Lines changed: 37 additions & 28 deletions

File tree

test/integration/connection-monitoring-and-pooling/connection.test.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { LEGACY_HELLO_COMMAND } from '../../../src/constants';
2222
import { Topology } from '../../../src/sdam/topology';
2323
import { HostAddress, ns } from '../../../src/utils';
2424
import * as mock from '../../tools/mongodb-mock/index';
25-
import { processTick, sleep } from '../../tools/utils';
25+
import { processTick, runtime, sleep } from '../../tools/utils';
2626
import { assert as test, setupDatabase } from '../shared';
2727

2828
const commonConnectOptions = {
@@ -49,7 +49,10 @@ describe('Connection', function () {
4949
...commonConnectOptions,
5050
connectionType: Connection,
5151
...this.configuration.options,
52-
metadata: makeClientMetadata([], {})
52+
metadata: makeClientMetadata([], {
53+
runtime
54+
}),
55+
runtime
5356
};
5457

5558
let conn;
@@ -71,7 +74,8 @@ describe('Connection', function () {
7174
connectionType: Connection,
7275
...this.configuration.options,
7376
monitorCommands: true,
74-
metadata: makeClientMetadata([], {})
77+
runtime,
78+
metadata: makeClientMetadata([], { runtime })
7579
};
7680

7781
let conn;
@@ -102,7 +106,10 @@ describe('Connection', function () {
102106
connectionType: Connection,
103107
...this.configuration.options,
104108
monitorCommands: true,
105-
metadata: makeClientMetadata([], {})
109+
runtime,
110+
metadata: makeClientMetadata([], {
111+
runtime
112+
})
106113
};
107114

108115
let conn;

test/unit/cmap/handshake/client_metadata.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
makeClientMetadata
1313
} from '../../../../src/cmap/handshake/client_metadata';
1414
import { MongoInvalidArgumentError } from '../../../../src/error';
15+
import { runtime } from '../../../tools/utils';
1516

1617
describe('client metadata module', () => {
1718
afterEach(() => sinon.restore());

test/unit/runtime_adapters.test.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1-
import { expect } from "chai"
2-
import { MongoClient, OsAdapter } from "../../src"
1+
import { expect } from 'chai';
32
import * as os from 'os';
43

4+
import { MongoClient, type OsAdapter } from '../../src';
5+
56
describe('Runtime Adapters tests', function () {
6-
describe('`os`', function () {
7-
describe('when no os adapter is provided', function () {
8-
it(`defaults to Node's os module`, function () {
9-
const client = new MongoClient('mongodb://localhost:27017');
7+
describe('`os`', function () {
8+
describe('when no os adapter is provided', function () {
9+
it(`defaults to Node's os module`, function () {
10+
const client = new MongoClient('mongodb://localhost:27017');
1011

11-
expect(client.options.runtime.os).to.equal(os);
12-
})
13-
})
12+
expect(client.options.runtime.os).to.equal(os);
13+
});
14+
});
1415

15-
describe('when an os adapter is provided', function () {
16-
it(`uses the user provided adapter`, function () {
17-
const osAdapter: OsAdapter = {
18-
...os
19-
};
20-
const client = new MongoClient('mongodb://localhost:27017', {
21-
runtimeAdapters: {
22-
os: osAdapter
23-
}
24-
});
16+
describe('when an os adapter is provided', function () {
17+
it(`uses the user provided adapter`, function () {
18+
const osAdapter: OsAdapter = {
19+
...os
20+
};
21+
const client = new MongoClient('mongodb://localhost:27017', {
22+
runtimeAdapters: {
23+
os: osAdapter
24+
}
25+
});
2526

26-
expect(client.options.runtime.os).to.equal(osAdapter);
27-
})
28-
})
29-
})
30-
})
27+
expect(client.options.runtime.os).to.equal(osAdapter);
28+
});
29+
});
30+
});
31+
});

0 commit comments

Comments
 (0)