Skip to content

Commit d9bdadf

Browse files
committedNov 29, 2017
test: 504 & 500 errors
1 parent 50ba6d9 commit d9bdadf

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
 
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const chai = require('chai')
2+
const nock = require('nock')
3+
4+
const GitHub = require('../../')
5+
6+
const mocha = require('mocha')
7+
const describe = mocha.describe
8+
const it = mocha.it
9+
chai.should()
10+
11+
describe('request errors', () => {
12+
it('timeout', () => {
13+
nock('https://request-errors-test.com')
14+
.get('/orgs/myorg')
15+
.socketDelay(2000)
16+
.reply(200, {})
17+
18+
const github = new GitHub({
19+
host: 'request-errors-test.com',
20+
timeout: 1000
21+
})
22+
23+
return github.orgs.get({org: 'myorg'})
24+
25+
.catch(error => {
26+
error.code.should.equal('504')
27+
})
28+
})
29+
30+
it('500', () => {
31+
nock('https://request-errors-test.com')
32+
.get('/orgs/myorg')
33+
.replyWithError('ooops')
34+
35+
const github = new GitHub({
36+
host: 'request-errors-test.com',
37+
timeout: 1000
38+
})
39+
40+
return github.orgs.get({org: 'myorg'})
41+
42+
.catch(error => {
43+
error.code.should.equal('500')
44+
})
45+
})
46+
})

0 commit comments

Comments
 (0)
Please sign in to comment.