Skip to content

Commit

Permalink
test: remove __proto__ usage in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Aug 22, 2022
1 parent 27130ac commit 39d76e8
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion test/document.isselected.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function TestDocument() {
* Inherits from Document.
*/

TestDocument.prototype.__proto__ = Document.prototype;
Object.setPrototypeOf(TestDocument.prototype, Document.prototype);

for (const i in EventEmitter.prototype) {
TestDocument[i] = EventEmitter.prototype[i];
Expand Down
2 changes: 1 addition & 1 deletion test/document.populate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function TestDocument() {
* Inherits from Document.
*/

TestDocument.prototype.__proto__ = Document.prototype;
Object.setPrototypeOf(TestDocument.prototype, Document.prototype);

/**
* Set a dummy schema to simulate compilation.
Expand Down
2 changes: 1 addition & 1 deletion test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function TestDocument() {
* Inherits from Document.
*/

TestDocument.prototype.__proto__ = Document.prototype;
Object.setPrototypeOf(TestDocument.prototype, Document.prototype);

for (const i in EventEmitter.prototype) {
TestDocument[i] = EventEmitter.prototype[i];
Expand Down
2 changes: 1 addition & 1 deletion test/document.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('sharding', function() {
this.$__schema = mockSchema;
this.$__ = {};
};
Stub.prototype.__proto__ = mongoose.Document.prototype;
Object.setPrototypeOf(Stub.prototype, mongoose.Document.prototype);
const d = new Stub();
const currentTime = new Date();
d._doc = { date: currentTime };
Expand Down
2 changes: 0 additions & 2 deletions test/model.discriminator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ describe('model', function() {
const employee = new Employee();
assert.ok(employee instanceof Person);
assert.ok(employee instanceof Employee);
assert.strictEqual(employee.__proto__.constructor, Employee);
assert.strictEqual(employee.__proto__.__proto__.constructor, Person);
});

it('can define static and instance methods', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function TestDocument() {
* Inherits from Document.
*/

TestDocument.prototype.__proto__ = Document.prototype;
Object.setPrototypeOf(TestDocument.prototype, Document.prototype);

/**
* Test.
Expand Down
4 changes: 2 additions & 2 deletions test/types.document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('types.document', function() {
mongoose.Document.call(this, {});
}
Dummy = _Dummy;
Dummy.prototype.__proto__ = mongoose.Document.prototype;
Object.setPrototypeOf(Dummy.prototype, mongoose.Document.prototype);
Dummy.prototype.$__setSchema(new Schema());

function _Subdocument() {
Expand All @@ -43,7 +43,7 @@ describe('types.document', function() {
}
Subdocument = _Subdocument;

Subdocument.prototype.__proto__ = ArraySubdocument.prototype;
Object.setPrototypeOf(Subdocument.prototype, ArraySubdocument.prototype);

for (const i in EventEmitter.prototype) {
Subdocument[i] = EventEmitter.prototype[i];
Expand Down
2 changes: 1 addition & 1 deletion test/types.documentarray.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function TestDoc(schema) {
* Inherits from ArraySubdocument.
*/

Subdocument.prototype.__proto__ = ArraySubdocument.prototype;
Object.setPrototypeOf(Subdocument.prototype, ArraySubdocument.prototype);

/**
* Set schema.
Expand Down

0 comments on commit 39d76e8

Please sign in to comment.