@@ -59,7 +59,6 @@ const createCommitResponse: GitCreateCommitResponseData = {
59
59
verified : true ,
60
60
} ,
61
61
} ;
62
- const escape = value => encodeURIComponent ( value ) . replace ( new RegExp ( '%2F' , 'g' ) , '%252F' ) ;
63
62
64
63
describe ( 'ApiHelper' , ( ) => {
65
64
disableNetConnect ( nock ) ;
@@ -213,7 +212,7 @@ describe('ApiHelper', () => {
213
212
const fn1 = jest . fn ( ) ;
214
213
const fn2 = jest . fn ( ) ;
215
214
nock ( 'https://api.github.com' )
216
- . patch ( ' /repos/hello/world/git/refs/' + escape ( 'heads/test' ) , body => {
215
+ . patch ( ` /repos/hello/world/git/refs/${ encodeURIComponent ( 'heads/test' ) } ` , body => {
217
216
fn1 ( ) ;
218
217
expect ( body ) . toHaveProperty ( 'sha' ) ;
219
218
return body ;
@@ -223,7 +222,7 @@ describe('ApiHelper', () => {
223
222
return getApiFixture ( rootDir , 'repos.git.refs.update' ) ;
224
223
} ) ;
225
224
226
- await helper . updateRef ( createCommitResponse , await helper . getRefForUpdate ( true ) , false ) ;
225
+ await helper . updateRef ( createCommitResponse , await helper . getRefForUpdate ( false ) , false ) ;
227
226
228
227
expect ( fn1 ) . toBeCalledTimes ( 1 ) ;
229
228
expect ( fn2 ) . toBeCalledTimes ( 1 ) ;
@@ -234,7 +233,7 @@ describe('ApiHelper', () => {
234
233
const fn2 = jest . fn ( ) ;
235
234
const fn3 = jest . fn ( ) ;
236
235
nock ( 'https://api.github.com' )
237
- . patch ( ' /repos/hello/world/git/refs/' + escape ( 'heads/new-topic' ) , body => {
236
+ . patch ( ` /repos/hello/world/git/refs/${ encodeURIComponent ( 'heads/new-topic' ) } ` , body => {
238
237
fn1 ( ) ;
239
238
expect ( body ) . toHaveProperty ( 'sha' ) ;
240
239
return body ;
@@ -253,7 +252,7 @@ describe('ApiHelper', () => {
253
252
ref : 'refs/pull/123/merge' ,
254
253
} ) ;
255
254
const helper = new ApiHelper ( octokit , _context , logger ) ;
256
- await helper . updateRef ( createCommitResponse , await helper . getRefForUpdate ( true ) , false ) ;
255
+ await helper . updateRef ( createCommitResponse , await helper . getRefForUpdate ( false ) , false ) ;
257
256
258
257
expect ( fn1 ) . toBeCalledTimes ( 1 ) ;
259
258
expect ( fn2 ) . toBeCalledTimes ( 1 ) ;
@@ -263,7 +262,7 @@ describe('ApiHelper', () => {
263
262
it ( 'should cache PR get api' , async ( ) => {
264
263
const fn = jest . fn ( ) ;
265
264
nock ( 'https://api.github.com' )
266
- . patch ( ' /repos/hello/world/git/refs/' + escape ( 'heads/new-topic' ) )
265
+ . patch ( ` /repos/hello/world/git/refs/${ encodeURIComponent ( 'heads/new-topic' ) } ` )
267
266
. reply ( 200 , ( ) => {
268
267
return getApiFixture ( rootDir , 'repos.git.refs.update' ) ;
269
268
} )
@@ -279,22 +278,22 @@ describe('ApiHelper', () => {
279
278
const helper = new ApiHelper ( octokit , _context , logger ) ;
280
279
await helper . getRefForUpdate ( true ) ;
281
280
await helper . getRefForUpdate ( true ) ;
282
- await helper . updateRef ( createCommitResponse , await helper . getRefForUpdate ( true ) , false ) ;
281
+ await helper . updateRef ( createCommitResponse , await helper . getRefForUpdate ( false ) , false ) ;
283
282
284
283
expect ( fn ) . toBeCalledTimes ( 1 ) ;
285
284
} ) ;
286
285
287
286
it ( 'should output warning' , async ( ) => {
288
287
nock ( 'https://api.github.com' )
289
- . patch ( ' /repos/hello/world/git/refs/' + escape ( 'heads/test' ) , body => {
288
+ . patch ( ` /repos/hello/world/git/refs/${ encodeURIComponent ( 'heads/test' ) } ` , body => {
290
289
expect ( body ) . toHaveProperty ( 'sha' ) ;
291
290
return body ;
292
291
} )
293
292
. reply ( 403 , {
294
293
'message' : 'Required status check "Test" is expected.' ,
295
294
} ) ;
296
295
297
- await expect ( helper . updateRef ( createCommitResponse , await helper . getRefForUpdate ( true ) , false ) ) . rejects . toThrow ( 'Required status check "Test" is expected.' ) ;
296
+ await expect ( helper . updateRef ( createCommitResponse , await helper . getRefForUpdate ( false ) , false ) ) . rejects . toThrow ( 'Required status check "Test" is expected.' ) ;
298
297
} ) ;
299
298
} ) ;
300
299
@@ -579,7 +578,7 @@ describe('ApiHelper', () => {
579
578
. reply ( 201 , ( ) => getApiFixture ( rootDir , 'repos.git.trees' ) )
580
579
. post ( '/repos/hello/world/git/commits' )
581
580
. reply ( 201 , ( ) => getApiFixture ( rootDir , 'repos.git.commits' ) )
582
- . patch ( ' /repos/hello/world/git/refs/' + escape ( 'heads/test' ) )
581
+ . patch ( ` /repos/hello/world/git/refs/${ encodeURIComponent ( 'heads/test' ) } ` )
583
582
. reply ( 200 , ( ) => getApiFixture ( rootDir , 'repos.git.refs.update' ) ) ;
584
583
585
584
expect ( await helper . commit ( rootDir , 'test commit message' , [ 'build1.json' , 'build2.json' ] ) ) . toBe ( true ) ;
@@ -590,7 +589,7 @@ describe('ApiHelper', () => {
590
589
'::endgroup::' ,
591
590
'::group::Creating commit... [cd8274d15fa3ae2ab983129fb037999f264ba9a7]' ,
592
591
'::endgroup::' ,
593
- '::group::Updating ref... [heads%252Ftest ] [7638417db6d59f3c431d3e1f261cc637155684cd]' ,
592
+ '::group::Updating ref... [heads/test ] [7638417db6d59f3c431d3e1f261cc637155684cd]' ,
594
593
'::set-env name=GITHUB_SHA::7638417db6d59f3c431d3e1f261cc637155684cd' ,
595
594
'::endgroup::' ,
596
595
] ) ;
0 commit comments