From 0c0833a33de28c40eb56387b87b71d6437d8e413 Mon Sep 17 00:00:00 2001 From: Fonger <5862369+Fonger@users.noreply.github.com> Date: Thu, 14 Nov 2019 14:18:23 +0800 Subject: [PATCH] test(model): add test for issue #8040 re: #8048 #8326 --- test/model.test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/model.test.js b/test/model.test.js index 0ab154470aa..fc6c2b40a20 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -3816,6 +3816,23 @@ describe('Model', function() { }); }); }); + it('should clear $versionError and saveOptions after saved (gh-8040)', function(done) { + const schema = new Schema({name: String}); + const Model = db.model('gh8040', schema); + const doc = new Model({ + name: 'Fonger' + }); + + const savePromise = doc.save(); + assert.ok(doc.$__.$versionError); + assert.ok(doc.$__.saveOptions); + + savePromise.then(function() { + assert.ok(!doc.$__.$versionError); + assert.ok(!doc.$__.saveOptions); + done(); + }).catch(done); + }); });