From 62480732c1fbe199f3ead728368334faf2d66217 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Sun, 1 Dec 2019 11:03:45 -0500 Subject: [PATCH] test(map): repro #8357 --- test/types.map.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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); + }); });