@@ -9,6 +9,7 @@ import readFixture from '../read-fixture.js'
99import jenkinsStatus from '../../scripts/jenkins-status.js'
1010
1111fetchMock . config . overwriteRoutes = true
12+ fetchMock . mockGlobal ( )
1213
1314jenkinsStatus ( app , events )
1415
@@ -18,7 +19,7 @@ tap.test('Sends POST requests to https://api.github.com/repos/nodejs/node/status
1819 const listCommitsUrl = setupListCommitsMock ( 'node' )
1920
2021 const url = 'https://api.github.com/repos/nodejs/node/statuses/8a5fec2a6bade91e544a30314d7cf21f8a200de1'
21- fetchMock . mock ( { url, method : 'POST' } , 201 )
22+ fetchMock . route ( { url, method : 'POST' } , 201 )
2223
2324 t . plan ( 3 )
2425
@@ -28,8 +29,8 @@ tap.test('Sends POST requests to https://api.github.com/repos/nodejs/node/status
2829 . expect ( 200 )
2930 . end ( ( err , res ) => {
3031 t . equal ( err , null )
31- t . equal ( fetchMock . done ( url ) , true )
32- t . equal ( fetchMock . done ( listCommitsUrl ) , true )
32+ t . equal ( fetchMock . callHistory . called ( url ) , true )
33+ t . equal ( fetchMock . callHistory . called ( listCommitsUrl ) , true )
3334 } )
3435} )
3536
@@ -39,7 +40,7 @@ tap.test('Allows repository name to be provided with URL parameter when pushing
3940 const listCommitsUrl = setupListCommitsMock ( 'citgm' )
4041
4142 const url = 'https://api.github.com/repos/nodejs/citgm/statuses/8a5fec2a6bade91e544a30314d7cf21f8a200de1'
42- fetchMock . mock ( { url, method : 'POST' } , 201 )
43+ fetchMock . route ( { url, method : 'POST' } , 201 )
4344
4445 t . plan ( 3 )
4546
@@ -49,8 +50,8 @@ tap.test('Allows repository name to be provided with URL parameter when pushing
4950 . expect ( 200 )
5051 . end ( ( err , res ) => {
5152 t . equal ( err , null )
52- t . equal ( fetchMock . done ( url ) , true )
53- t . equal ( fetchMock . done ( listCommitsUrl ) , true )
53+ t . equal ( fetchMock . callHistory . called ( url ) , true )
54+ t . equal ( fetchMock . callHistory . called ( listCommitsUrl ) , true )
5455 } )
5556} )
5657
@@ -60,7 +61,7 @@ tap.test('Allows repository name to be provided with URL parameter when pushing
6061 const listCommitsUrl = setupListCommitsMock ( 'citgm' )
6162
6263 const url = 'https://api.github.com/repos/nodejs/citgm/statuses/8a5fec2a6bade91e544a30314d7cf21f8a200de1'
63- fetchMock . mock ( { url, method : 'POST' } , 201 )
64+ fetchMock . route ( { url, method : 'POST' } , 201 )
6465
6566 t . plan ( 3 )
6667
@@ -70,8 +71,8 @@ tap.test('Allows repository name to be provided with URL parameter when pushing
7071 . expect ( 200 )
7172 . end ( ( err , res ) => {
7273 t . equal ( err , null )
73- t . equal ( fetchMock . done ( url ) , true )
74- t . equal ( fetchMock . done ( listCommitsUrl ) , true )
74+ t . equal ( fetchMock . callHistory . called ( url ) , true )
75+ t . equal ( fetchMock . callHistory . called ( listCommitsUrl ) , true )
7576 } )
7677} )
7778
@@ -87,7 +88,7 @@ tap.test('Forwards payload provided in incoming POST to GitHub status API', (t)
8788 description : 'tests passed' ,
8889 target_url : 'https://ci.nodejs.org/job/node-test-commit-osx/3157/'
8990 }
90- fetchMock . mock ( { url, method : 'POST' , body } , 201 )
91+ fetchMock . route ( { url, method : 'POST' , body } , 201 )
9192
9293 t . plan ( 3 )
9394
@@ -97,8 +98,8 @@ tap.test('Forwards payload provided in incoming POST to GitHub status API', (t)
9798 . expect ( 200 )
9899 . end ( ( err , res ) => {
99100 t . equal ( err , null )
100- t . equal ( fetchMock . done ( url ) , true )
101- t . equal ( fetchMock . done ( listCommitsUrl ) , true )
101+ t . equal ( fetchMock . callHistory . called ( url ) , true )
102+ t . equal ( fetchMock . callHistory . called ( listCommitsUrl ) , true )
102103 } )
103104} )
104105
@@ -107,11 +108,11 @@ tap.test('Posts a CI comment in the related PR when Jenkins build is named node-
107108
108109 const url = 'https://api.github.com/repos/nodejs/node/issues/12345/comments'
109110 const body = { body : 'CI: https://ci.nodejs.org/job/node-test-pull-request/21633/' }
110- fetchMock . mock ( { url, method : 'POST' , body } , 200 )
111+ fetchMock . route ( { url, method : 'POST' , body } , 200 )
111112
112113 // we don't care about asserting the scopes below, just want to stop the requests from actually being sent
113114 setupListCommitsMock ( 'node' )
114- fetchMock . mock (
115+ fetchMock . route (
115116 {
116117 url : 'https://api.github.com/repos/nodejs/node/statuses/8a5fec2a6bade91e544a30314d7cf21f8a200de1' ,
117118 method : 'POST'
@@ -124,7 +125,7 @@ tap.test('Posts a CI comment in the related PR when Jenkins build is named node-
124125 . send ( fixture )
125126 . expect ( 200 )
126127 . end ( ( err , res ) => {
127- t . equal ( fetchMock . done ( url ) , true )
128+ t . equal ( fetchMock . callHistory . called ( url ) , true )
128129 t . equal ( err , null )
129130 } )
130131} )
@@ -135,11 +136,11 @@ tap.test('Posts a CI comment in the related PR when Jenkins build is named node-
135136
136137 const url = 'https://api.github.com/repos/nodejs/node/issues/12345/comments'
137138 const body = { body : 'Lite-CI: https://ci.nodejs.org/job/node-test-pull-request/21633/' }
138- fetchMock . mock ( { url, body, method : 'POST' } , 200 )
139+ fetchMock . route ( { url, body, method : 'POST' } , 200 )
139140
140141 // we don't care about asserting the scopes below, just want to stop the requests from actually being sent
141142 setupListCommitsMock ( 'node' )
142- fetchMock . mock (
143+ fetchMock . route (
143144 {
144145 url : 'https://api.github.com/repos/nodejs/node/statuses/8a5fec2a6bade91e544a30314d7cf21f8a200de1' ,
145146 method : 'POST'
@@ -152,7 +153,7 @@ tap.test('Posts a CI comment in the related PR when Jenkins build is named node-
152153 . send ( fixture )
153154 . expect ( 200 )
154155 . end ( ( err , res ) => {
155- t . equal ( fetchMock . done ( url ) , true )
156+ t . equal ( fetchMock . callHistory . called ( url ) , true )
156157 t . equal ( err , null )
157158 } )
158159} )
@@ -161,7 +162,7 @@ tap.test('Responds with 400 / "Bad request" when incoming request has invalid pa
161162 const fixture = readFixture ( 'invalid-payload.json' )
162163
163164 // don't care about the results, just want to prevent any HTTP request ever being made
164- fetchMock . mock ( 'https://api.github.com' , 200 )
165+ fetchMock . route ( 'https://api.github.com' , 200 )
165166
166167 t . plan ( 1 )
167168
@@ -178,7 +179,7 @@ tap.test('Responds with 400 / "Bad request" when build started status update is
178179 const fixture = readFixture ( 'jenkins-staging-failure-payload.json' )
179180
180181 // don't care about the results, just want to prevent any HTTP request ever being made
181- fetchMock . mock ( 'https://api.github.com' , 200 )
182+ fetchMock . route ( 'https://api.github.com' , 200 )
182183
183184 t . plan ( 1 )
184185
@@ -195,7 +196,7 @@ tap.test('Responds with 400 / "Bad request" when build ended status update is no
195196 const fixture = readFixture ( 'jenkins-staging-failure-payload.json' )
196197
197198 // don't care about the results, just want to prevent any HTTP request ever being made
198- fetchMock . mock ( 'https://api.github.com/' , 200 )
199+ fetchMock . route ( 'https://api.github.com/' , 200 )
199200
200201 t . plan ( 1 )
201202
@@ -212,7 +213,7 @@ tap.test('Responds with 400 / "Bad request" when incoming providing invalid repo
212213 const fixture = readFixture ( 'pending-payload.json' )
213214
214215 // don't care about the results, just want to prevent any HTTP request ever being made
215- fetchMock . mock ( 'https://api.github.com/' , 200 )
216+ fetchMock . route ( 'https://api.github.com/' , 200 )
216217
217218 t . plan ( 1 )
218219
@@ -229,6 +230,6 @@ function setupListCommitsMock (repoName) {
229230 const commitsResponse = readFixture ( 'pr-commits.json' )
230231 const url = `https://api.github.com/repos/nodejs/${ repoName } /pulls/12345/commits`
231232
232- fetchMock . mock ( url , commitsResponse )
233+ fetchMock . route ( url , commitsResponse )
233234 return url
234235}
0 commit comments