forked from wilsonchingg/node-github-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
50 lines (43 loc) · 888 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict'
const ava = require('ava')
const test = ava.test
const GithubGraphQLApi = require('.')
const nock = require('nock')
const apiQuery = `
viewer {
login
}`
const apiResponse = {
'data': {
'viewer': {
'login': 'wilsonchingg'
}
}
}
test.before(() => {
nock.disableNetConnect()
})
test('post /apps without params', t => {
let github = new GithubGraphQLApi()
let api = nock('https://api.github.com')
.post('/graphql')
.reply(201, apiResponse)
return github.query(apiQuery).then(() => {
t.pass()
api.done()
})
})
test('post /apps with params', t => {
let github = new GithubGraphQLApi({
userAgent: 'Test',
proxy: 'http://proxy.test.com'
})
let api = nock('https://api.github.com')
.post('/graphql')
.reply(201, apiResponse)
t.pass()
github.query(apiQuery, null, () => {
t.pass()
api.done()
})
})