Skip to content

Commit

Permalink
test: don’t send empty variables object
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Jan 8, 2019
1 parent 0040601 commit 295da93
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/graphql-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,23 @@ describe('graphql()', () => {
repo: 'graphql.js'
})
})

it('Don’t send empty variables object', () => {
const query = '{ viewer { login } }'

mockable.fetch = fetchMock.sandbox()
.post('https://api.github.com/graphql', (url, options) => {
const body = JSON.parse(options.body)
expect(body.query).to.equal(query)
expect(body.variables).to.equal(undefined)

return { data: {} }
})

return graphql(query, {
headers: {
authorization: `token secret123`
}
})
})
})

0 comments on commit 295da93

Please sign in to comment.