Skip to content

Commit

Permalink
test(schema): repro #10029
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Mar 22, 2021
1 parent 96f7905 commit 171c31f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/schema.test.js
Expand Up @@ -2578,4 +2578,20 @@ describe('schema', function() {

assert.equal(schema.virtuals.displayAs.applyGetters(null, { name: 'test' }), 'test');
});

it('supports setting `ref` on array SchemaType (gh-10029)', function() {
const testSchema = new mongoose.Schema({
doesntpopulate: {
type: [mongoose.Schema.Types.ObjectId],
ref: 'features'
},
populatescorrectly: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'features'
}]
});

assert.equal(testSchema.path('doesntpopulate.$').options.ref, 'features');
assert.equal(testSchema.path('populatescorrectly.$').options.ref, 'features');
});
});

0 comments on commit 171c31f

Please sign in to comment.