Skip to content

Commit

Permalink
test(populate): repro #6767
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jul 30, 2018
1 parent 2b5e18a commit 1e27f09
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/model.populate.test.js
Expand Up @@ -4256,6 +4256,27 @@ describe('model: populate:', function() {
});
});

it('catchable error if localField or foreignField not specified (gh-6767)', function() {
const PersonSchema = new Schema({
name: String,
band: String
});

const BandSchema = new Schema({
name: String
});
BandSchema.virtual('members');

const Person = db.model('gh6767_Person', PersonSchema);
const Band = db.model('gh6767_Band', BandSchema);

return Band.create({ name: 'Motley Crue' }).
then(() => Band.find().populate('members')).
catch(error => {
assert.ok(error.message.indexOf('foreignField') !== -1, error.message);
});
});

it('source array', function(done) {
var PersonSchema = new Schema({
name: String
Expand Down

0 comments on commit 1e27f09

Please sign in to comment.