File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
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
+ } )
You can’t perform that action at this time.
0 commit comments