Skip to content

Commit

Permalink
test(update): repro #7909
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jun 22, 2019
1 parent 35e9e6e commit ef79737
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/model.findOneAndUpdate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,26 @@ describe('model: findOneAndUpdate:', function() {
});
});

it('skips setting defaults within maps (gh-7909)', function() {
const socialMediaHandleSchema = Schema({ links: [String] });
const profileSchema = Schema({
username: String,
socialMediaHandles: {
type: Map,
of: socialMediaHandleSchema,
}
});

const Profile = db.model('gh7909', profileSchema);

return co(function*() {
const update = { $setOnInsert: { username: 'test' } };
const opts = { upsert: true, setDefaultsOnInsert: true, new: true };
const doc = yield Profile.findOneAndUpdate({}, update, opts);
assert.equal(doc.socialMediaHandles, undefined);
});
});

it('runs validators if theyre set', function(done) {
const s = new Schema({
topping: {
Expand Down

0 comments on commit ef79737

Please sign in to comment.