Skip to content

Commit ef1fb6d

Browse files
committed
test: limit globals
1 parent ba8fc52 commit ef1fb6d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/node/bson_type_classes.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ describe('BSON Type classes common interfaces', () => {
104104
for (const [name, factory] of BSONTypeClassCtors) {
105105
it(`${name} returns string that is runnable and has deep equality`, () => {
106106
const bsonValue = factory();
107-
const ctx = { ...BSON, module: { exports: { result: null } } };
107+
// All BSON types should only need exactly their constructor available on the global
108+
const ctx = { [name]: bsonValue.constructor, module: { exports: { result: null } } };
109+
if (name === 'DBRef') {
110+
// DBRef is the only type that requires another BSON type
111+
ctx.ObjectId = ObjectId;
112+
}
108113
vm.runInNewContext(`module.exports.result = ${bsonValue.inspect()}`, ctx);
109114
expect(ctx.module.exports.result).to.deep.equal(bsonValue);
110115
});

0 commit comments

Comments
 (0)