Skip to content

Commit

Permalink
test: fix tests re: #8273
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 3, 2019
1 parent dfde779 commit c1e49c3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/document.js
Expand Up @@ -1170,6 +1170,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
if (schema.$isMongooseDocumentArray &&
Array.isArray(val) &&
val.length > 0 &&
val[0] != null &&
val[0].$__ != null &&
val[0].$__.populated != null) {
const populatedPaths = Object.keys(val[0].$__.populated);
Expand Down
2 changes: 1 addition & 1 deletion lib/types/documentarray.js
Expand Up @@ -86,7 +86,7 @@ class CoreDocumentArray extends CoreMongooseArray {
}
}
}

if (Constructor.$isMongooseDocumentArray) {
return Constructor.cast(value, this, undefined, undefined, index);
}
Expand Down
8 changes: 3 additions & 5 deletions test/model.update.test.js
Expand Up @@ -2510,7 +2510,7 @@ describe('model: update:', function() {
catch(done);
});

it('$pullAll with null (gh-5164)', function(done) {
it('$pullAll with null (gh-5164)', function() {
const schema = new Schema({
name: String,
arr: [{ name: String }]
Expand All @@ -2519,7 +2519,7 @@ describe('model: update:', function() {

const doc = new Test({ name: 'Test', arr: [null, {name: 'abc'}] });

doc.save().
return doc.save().
then(function(doc) {
return Test.update({ _id: doc._id }, {
$pullAll: { arr: [null] }
Expand All @@ -2531,9 +2531,7 @@ describe('model: update:', function() {
then(function(doc) {
assert.equal(doc.arr.length, 1);
assert.equal(doc.arr[0].name, 'abc');
done();
}).
catch(done);
});
});

it('$set array (gh-5403)', function(done) {
Expand Down

0 comments on commit c1e49c3

Please sign in to comment.