@@ -100,6 +100,9 @@ let mockGitHubApiRequest = jest.fn((_context, _token, method, requestPath, paylo
100100 if ( method === 'GET' && requestPath === '/user' ) return {
101101 login : 'cheers'
102102 }
103+ if ( method === 'GET' && requestPath . endsWith ( '/pulls/86' ) ) return {
104+ head : { sha : '707a11ee' }
105+ }
103106 throw new Error ( `Unhandled ${ method } -${ requestPath } -${ JSON . stringify ( payload ) } ` )
104107} )
105108jest . mock ( '../GitForWindowsHelper/github-api-request' , ( ) => {
@@ -253,3 +256,41 @@ The MSYS workflow run [was started](dispatched-workflow-open-pr.yml)`
253256The MINGW workflow run [was started](dispatched-workflow-open-pr.yml)`
254257 } )
255258} )
259+
260+ let mockQueueCheckRun = jest . fn ( ( ) => 'check-run-id' )
261+ let mockUpdateCheckRun = jest . fn ( )
262+ jest . mock ( '../GitForWindowsHelper/check-runs' , ( ) => {
263+ return {
264+ queueCheckRun : mockQueueCheckRun ,
265+ updateCheckRun : mockUpdateCheckRun
266+ }
267+ } )
268+
269+ testIssueComment ( '/deploy' , {
270+ issue : {
271+ number : 86 ,
272+ title : 'gnutls: update to 3.8.0' ,
273+ body : 'This closes https://github.com/git-for-windows/git/issues/4281' ,
274+ pull_request : {
275+ html_url : 'https://github.com/git-for-windows/MSYS2-packages/pull/86'
276+ }
277+ } ,
278+ repository : {
279+ name : 'MSYS2-packages' ,
280+ }
281+ } , async ( context ) => {
282+ expect ( await index ( context , context . req ) ) . toBeUndefined ( )
283+ expect ( context . res ) . toEqual ( {
284+ body : `I edited the comment: appended-comment-body-existing comment body
285+
286+ The [x86_64](dispatched-workflow-build-and-deploy.yml) and the [i686](dispatched-workflow-build-and-deploy.yml) workflow runs were started.` ,
287+ headers : undefined ,
288+ status : undefined
289+ } )
290+ expect ( mockGetInstallationAccessToken ) . toHaveBeenCalledTimes ( 1 )
291+ expect ( mockGitHubApiRequestAsApp ) . not . toHaveBeenCalled ( )
292+ expect ( mockQueueCheckRun ) . toHaveBeenCalledTimes ( 2 )
293+ expect ( mockUpdateCheckRun ) . toHaveBeenCalledTimes ( 2 )
294+ expect ( dispatchedWorkflows ) . toHaveLength ( 2 )
295+ expect ( dispatchedWorkflows . map ( e => e . payload . inputs . architecture ) ) . toEqual ( [ 'i686' , 'x86_64' ] )
296+ } )
0 commit comments