import path from 'path' ; import * as core from '@actions/core' ; import * as github from '@actions/github' ; import { WebhookPayload } from '@actions/github/lib/interfaces' ; import nock from 'nock' ; import run from '../autograding' ; beforeEach ( ( ) => { jest . resetModules ( ) ; jest . restoreAllMocks ( ) ; jest . spyOn ( core , 'setOutput' ) . mockImplementation ( ( ) => { return ; } ) ; jest . spyOn ( core , 'getInput' ) . mockImplementation ( ( name ) : string => { if ( name === 'token' ) return '12345' ; return '' ; } ) ; process . env [ 'GITHUB_WORKSPACE' ] = path . resolve ( __dirname , 'java' ) ; process . env [ 'GITHUB_REPOSITORY' ] = 'example/repository' ; github . context . payload = { ref : 'refs/tags/simple-tag' , before : '6113728f27ae82c7b1a177c8d03f9e96e0adf246' , after : '0000000000000000000000000000000000000000' , commits : [ ] , repository : { id : 186853002 , node_id : 'MDEwOlJlcG9zaXRvcnkxODY4NTMwMDI=' , name : 'repository' , full_name : 'example/repository' , owner : { name : 'Codertocat' , email : '21031067+Codertocat@users.noreply.github.com' , login : 'Codertocat' , id : 21031067 , } , } , } as WebhookPayload ; } ) ; afterEach ( ( ) => { expect ( nock . pendingMocks ( ) ) . toEqual ( [ ] ) ; nock . isDone ( ) ; nock . cleanAll ( ) ; } ) ; describe ( 'autograding action' , ( ) => { it ( 'runs' , async ( ) => { await expect ( run ( ) ) . resolves . not . toThrow ( ) ; } , 10000 ) ; } ) ;