diff --git a/test/types.map.test.js b/test/types.map.test.js index df99d479a5e..aee37832760 100644 --- a/test/types.map.test.js +++ b/test/types.map.test.js @@ -743,4 +743,20 @@ describe('Map', function() { assert.ok(err.errors['myMap.foo.test'].message.indexOf('required') !== -1, err.errors['myMap.foo.test'].message); }); + + it('works with clone() (gh-8357)', function() { + const childSchema = mongoose.Schema({ name: String }); + const schema = mongoose.Schema({ + myMap: { + type: Map, + of: childSchema + } + }); + const Model = db.model('gh8357', schema.clone()); + + const doc = new Model({ myMap: { foo: { name: 'bar' } } }); + + const err = doc.validateSync(); + assert.ifError(err); + }); });