Skip to content

Commit

Permalink
test(document): repro #9351
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Aug 24, 2020
1 parent 43a840d commit ae5d739
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/document.test.js
Expand Up @@ -9270,4 +9270,20 @@ describe('document', function() {
assert.deepEqual(fromDb.toObject().keys, [{ name: 'test' }]);
});
});

it('allows accessing document values from function default on array (gh-9351) (gh-6155)', function() {
const schema = Schema({
publisher: String,
authors: {
type: [String],
default: function() {
return [this.publisher];
}
}
});
const Test = db.model('Test', schema);

const doc = new Test({ publisher: 'Mastering JS' });
assert.deepEqual(doc.toObject().authors, ['Mastering JS']);
});
});

0 comments on commit ae5d739

Please sign in to comment.