Skip to content

Commit

Permalink
Add support for mquery 2.1.0 (selecting arrays of fields)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-gran committed Jan 30, 2017
1 parent 6e70102 commit b180b4d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions test/integration/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,19 +744,23 @@ module.exports = function (createFn, setup, dismantle) {
})

describe('select', () => {
it('GET /Customer?select=["name"] 400 - yields an error', (done) => {
it('GET /Customer?select=["name"] 200 - select an array of fields', (done) => {
request.get({
url: `${testUrl}/api/v1/Customer`,
qs: {
select: ['name']
select: ['name', 'favorites']
},
json: true
}, (err, res, body) => {
assert.ok(!err)
assert.equal(res.statusCode, 400)
assert.deepEqual(body, {
name: 'TypeError',
message: 'Invalid select() argument. Must be string or object.'
assert.equal(res.statusCode, 200)
assert.equal(body.length, 3)
body.forEach((item) => {
assert.equal(Object.keys(item).length, 3)
assert.ok(item._id)
assert.ok(item.name)
assert.ok(item.favorites)
assert.ok(typeof item.favorites === 'object')
})
done()
})
Expand Down

0 comments on commit b180b4d

Please sign in to comment.