Skip to content

Commit

Permalink
fix: clean up test failures re: #8883
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jun 13, 2020
1 parent 93f3424 commit d3858d6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/schema.js
Expand Up @@ -936,6 +936,7 @@ Schema.prototype.interpretAsType = function(path, obj, options) {
if (options.hasOwnProperty('typePojoToMixed')) {
childSchemaOptions.typePojoToMixed = options.typePojoToMixed;
}

if (this._userProvidedOptions.hasOwnProperty('_id')) {
childSchemaOptions._id = this._userProvidedOptions._id;
} else if (Schema.Types.DocumentArray.defaultOptions &&
Expand Down
2 changes: 2 additions & 0 deletions lib/schema/SingleNestedPath.js
Expand Up @@ -316,6 +316,8 @@ SingleNestedPath.prototype.discriminator = function(name, schema, value) {
* @api public
*/

SingleNestedPath.defaultOptions = {};

SingleNestedPath.set = SchemaType.set;

/*!
Expand Down
2 changes: 2 additions & 0 deletions lib/schema/documentarray.js
Expand Up @@ -526,6 +526,8 @@ function scopePaths(array, fields, init) {
* @api public
*/

DocumentArrayPath.defaultOptions = {};

DocumentArrayPath.set = SchemaType.set;

/*!
Expand Down
2 changes: 1 addition & 1 deletion test/schema.documentarray.test.js
Expand Up @@ -112,6 +112,6 @@ describe('schema.documentarray', function() {
assert.equal(doc.arr.length, 1);
assert.ok(!doc.arr[0]._id);

mongoose.Schema.Types.DocumentArray.set('_id', true);
mongoose.Schema.Types.DocumentArray.defaultOptions = {};
});
});
8 changes: 4 additions & 4 deletions test/schema.test.js
Expand Up @@ -2001,13 +2001,13 @@ describe('schema', function() {
});

assert.equal(schema.childSchemas.length, 2);
assert.equal(schema.childSchemas[0].schema, schema1);
assert.equal(schema.childSchemas[1].schema, schema2);
assert.strictEqual(schema.childSchemas[0].schema, schema1);
assert.strictEqual(schema.childSchemas[1].schema, schema2);

schema = schema.clone();
assert.equal(schema.childSchemas.length, 2);
assert.equal(schema.childSchemas[0].schema, schema1);
assert.equal(schema.childSchemas[1].schema, schema2);
assert.strictEqual(schema.childSchemas[0].schema, schema1);
assert.strictEqual(schema.childSchemas[1].schema, schema2);

done();
});
Expand Down

0 comments on commit d3858d6

Please sign in to comment.