Skip to content

Commit

Permalink
test: skip #8524 test if not mongodb 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jan 25, 2020
1 parent dfaa40e commit b26e1e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 14 additions & 0 deletions test/model.update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3433,5 +3433,19 @@ describe('model: updateOne: ', function() {
assert.strictEqual(doc.newProp, void 0);
});
});

it('update pipeline timestamps (gh-8524)', function() {
const Cat = db.model('Cat', Schema({ name: String }, { timestamps: true }));

return co(function*() {
const cat = yield Cat.create({ name: 'Entei' });
const updatedAt = cat.updatedAt;

yield new Promise(resolve => setTimeout(resolve), 50);
const updated = yield Cat.findOneAndUpdate({ _id: cat._id },
[{ $set: { name: 'Raikou' } }], { new: true });
assert.ok(updated.updatedAt.getTime() > updatedAt.getTime());
});
});
});
});
12 changes: 0 additions & 12 deletions test/schema.timestamps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,6 @@ describe('schema options.timestamps', function() {
});
});

it('with update pipeline (gh-8524)', function() {
return co(function*() {
const cat = yield Cat.create({ name: 'Entei' });
const updatedAt = cat.updatedAt;

yield new Promise(resolve => setTimeout(resolve), 50);
const updated = yield Cat.findOneAndUpdate({ _id: cat._id },
[{ $set: { name: 'Raikou' } }], { new: true });
assert.ok(updated.updatedAt.getTime() > updatedAt.getTime());
});
});

after(function() {
return Cat.deleteMany({});
});
Expand Down

0 comments on commit b26e1e0

Please sign in to comment.