Skip to content

Commit

Permalink
test(map): repro #7859
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jun 11, 2019
1 parent 08c348f commit d03129c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/types.map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,4 +716,23 @@ describe('Map', function() {
assert.deepEqual(calls, ['myMap.foo', 'myMap.foo']);
});
});

it('treats `of` as a schema if typeKey is not set (gh-7859)', function() {
const schema = new mongoose.Schema({
myMap: {
type: Map,
of: {
test: { type: String, required: true }
}
}
});
const Model = db.model('gh7859', schema);

const doc = new Model({ myMap: { foo: {} } });

const err = doc.validateSync();
assert.ok(err);
assert.ok(err.errors['myMap.foo.test'].message.indexOf('required') !== -1,
err.errors['myMap.foo.test'].message);
});
});

0 comments on commit d03129c

Please sign in to comment.