Skip to content

Commit 6ea62dd

Browse files
Reproduce Automattic#8317
1 parent a3b4ea1 commit 6ea62dd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/types.documentarray.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,20 @@ describe('types.documentarray', function() {
575575
assert.equal(arr.length, 1);
576576
assert.equal(doc.docs.length, 2);
577577
});
578+
579+
it('map() copies parent and path ()', function() {
580+
const personSchema = new Schema({ friends: [{ name: { type: String } }]});
581+
const Person = mongoose.model('Person', personSchema);
582+
583+
const person = new Person({ friends: [{ name: 'Hafez' }] });
584+
585+
const friendsNames = person.friends.map(friend => friend.name);
586+
587+
friendsNames.push('Sam');
588+
589+
assert.equal(friendsNames.length, 2);
590+
assert.equal(friendsNames[1], 'Sam');
591+
});
578592
});
579593

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

0 commit comments

Comments
 (0)