Skip to content

Commit a598258

Browse files
add adapter unit test
1 parent c8a22e6 commit a598258

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/unit/runtime_adapters.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expect } from "chai"
2+
import { MongoClient, OsAdapter } from "../../src"
3+
import * as os from 'os';
4+
5+
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');
10+
11+
expect(client.options.runtime.os).to.equal(os);
12+
})
13+
})
14+
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+
});
25+
26+
expect(client.options.runtime.os).to.equal(osAdapter);
27+
})
28+
})
29+
})
30+
})

0 commit comments

Comments
 (0)