Skip to content

Commit

Permalink
test(QueryCursor): fix tests from #10015
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Mar 19, 2021
1 parent b983819 commit 7b14258
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions test/query.cursor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,8 @@ describe('QueryCursor', function() {

it('post hooks (gh-9435)', function() {
const schema = new mongoose.Schema({ name: String });
schema.post('find', function(doc) {
doc.name = doc.name.toUpperCase();
schema.post('find', function(docs) {
docs.forEach(doc => { doc.name = doc.name.toUpperCase(); });
});
const Movie = db.model('Movie', schema);

Expand All @@ -711,19 +711,4 @@ describe('QueryCursor', function() {
assert.deepEqual(arr, ['KICKBOXER', 'IP MAN', 'ENTER THE DRAGON']);
});
});
it('returns array for schema hooks gh-9982', () => {
const testSchema = new mongoose.Schema({ name: String });
testSchema.post('find', (result) => {
assert.ok(Array.isArray(result));
});
const Movie = db.model('Movie', testSchema);
return co(function*() {
yield Movie.deleteMany({});
yield Movie.create({ name: 'Daniel' }, { name: 'Val' }, { name: 'Daniel' });
const test = Movie.find({ name: 'Daniel' }).cursor();
test.next().then(doc => {
assert.ok(doc,doc);
});
});
});
});

0 comments on commit 7b14258

Please sign in to comment.