Skip to content

Commit f814a0b

Browse files
committed
fix up comments and test
1 parent d14c4d1 commit f814a0b

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
node_modules/
12
!mongodb-legacy.d.ts
23
.vscode/
34
*.tgz

test/tools/api.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const asyncApi = [
4040
{ className: 'AggregationCursor', method: 'explain', returnType: 'Promise<Document>' },
4141

4242
// Super class of Unordered/Ordered Bulk operations
43+
// This is listed here as a reference for completeness, but it is tested manually
4344
// { className: 'BulkOperationBase', method: 'execute', returnType: 'Promise<BulkWriteResult>' },
4445
{ className: 'OrderedBulkOperation', method: 'execute', returnType: 'Promise<BulkWriteResult>' },
4546
{ className: 'UnorderedBulkOperation', method: 'execute', returnType: 'Promise<BulkWriteResult>' },
@@ -112,6 +113,7 @@ const asyncApi = [
112113
{ className: 'MongoClient', method: 'close', returnType: 'Promise<void>' },
113114
{ className: 'MongoClient', method: 'connect', returnType: 'Promise<this>' },
114115
// Manually test the static version of connect
116+
// This is listed here as a reference for completeness, but it is tested manually
115117
// { className: 'MongoClient', method: 'static connect', returnType: 'Promise<this>' },
116118
];
117119

test/unit/utils.test.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,25 @@ describe('utils.js', () => {
4545

4646
it('should not modify a rejection error promise', async () => {
4747
class MyError extends Error {}
48-
const rejection = Promise.reject(new MyError());
48+
const driverError = Object.freeze(new MyError());
49+
const rejection = Promise.reject(driverError);
4950
const thrownError = await maybeCallback(rejection, null).catch(error => error);
50-
expect(thrownError).to.be.instanceOf(MyError);
51+
expect(thrownError).to.be.equal(driverError);
52+
});
53+
54+
it('should not modify a rejection error when passed to callback', done => {
55+
class MyError extends Error {}
56+
const driverError = Object.freeze(new MyError());
57+
const rejection = Promise.reject(driverError);
58+
maybeCallback(rejection, error => {
59+
try {
60+
expect(error).to.exist;
61+
expect(error).to.equal(driverError);
62+
done();
63+
} catch (assertionError) {
64+
done(assertionError);
65+
}
66+
});
5167
});
5268
});
5369

0 commit comments

Comments
 (0)