Skip to content

Commit

Permalink
test(documentarray): repro #8317
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 17, 2019
1 parent 5a1dbd8 commit 203450c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/types.documentarray.test.js
Expand Up @@ -546,7 +546,7 @@ describe('types.documentarray', function() {
});

it('clears listeners on cast error (gh-6723)', function() {
const nested = new Schema({v: {type: Number}});
const nested = new Schema({ v: Number });
const schema = new Schema({
docs: [nested]
});
Expand All @@ -559,6 +559,22 @@ describe('types.documentarray', function() {

return m.save();
});

it('slice() copies parent and path (gh-8317)', function() {
const nested = new Schema({ v: Number });
const schema = new Schema({
docs: [nested]
});
const M = db.model('gh8317', schema);

const doc = M.hydrate({ docs: [{ v: 1 }, { v: 2 }]});
let arr = doc.docs;
arr = arr.slice();
arr.splice(0, 1);

assert.equal(arr.length, 1);
assert.equal(doc.docs.length, 2);
});
});

it('cleans modified subpaths on splice() (gh-7249)', function() {
Expand Down

0 comments on commit 203450c

Please sign in to comment.