Skip to content

Commit

Permalink
add a test for 'fields' options (will be deprecated)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpangrazzi committed May 6, 2019
1 parent 39a3997 commit 1f3646b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@ test('findOne > should only provide selected fields', (t) => {
})
})

test('find > should project only specified fields using fields options', t => {
return users.insert([
{ a: 1, b: 2 },
{ a: 1, b: 1 }
]).then(() => {
return users.find({ sort: true }, { fields: { a: 1 } })
}).then((docs) => {
t.is(docs[0].a, 1)
t.is(docs[0].b, undefined)
t.is(docs[1].a, 1)
t.is(docs[1].b, undefined)
})
})

test.cb('findOne > callback', (t) => {
users.insert({ woot: 'e' }).then((doc) => {
return users.findOne(doc._id, t.end)
Expand Down

0 comments on commit 1f3646b

Please sign in to comment.