Skip to content

Commit

Permalink
Reproduce Automattic#8317
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanHafez committed Nov 17, 2019
1 parent a3b4ea1 commit 6ea62dd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/types.documentarray.test.js
Expand Up @@ -575,6 +575,20 @@ describe('types.documentarray', function() {
assert.equal(arr.length, 1);
assert.equal(doc.docs.length, 2);
});

it('map() copies parent and path ()', function() {
const personSchema = new Schema({ friends: [{ name: { type: String } }]});
const Person = mongoose.model('Person', personSchema);

const person = new Person({ friends: [{ name: 'Hafez' }] });

const friendsNames = person.friends.map(friend => friend.name);

friendsNames.push('Sam');

assert.equal(friendsNames.length, 2);
assert.equal(friendsNames[1], 'Sam');
});
});

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

0 comments on commit 6ea62dd

Please sign in to comment.