build(typescript): refactoring project with typescript and test setup

This commit is contained in:
Michael Shick 2020-05-21 13:17:40 -04:00
parent 026d9b8889
commit fe6d191bcd
No known key found for this signature in database
GPG key ID: ADF5BC9704BB4A61
13 changed files with 4956 additions and 25713 deletions

View file

@ -0,0 +1,41 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import {WebhookPayload} from '@actions/github/lib/interfaces'
import run from '../add-pr-comment'
beforeEach(() => {
jest.resetModules()
jest.spyOn(core, 'getInput').mockImplementation((name: string): string => {
switch (name) {
case 'message':
return 'hello world'
case 'repo-token':
return '12345'
case 'allow-repeats':
return 'false'
default:
return ''
}
})
// https://developer.github.com/webhooks/event-payloads/#issues
github.context.payload = {
action: 'created',
issue: {
number: 1,
},
comment: {
id: 1,
user: {
login: 'monalisa',
},
body: 'Honk',
},
} as WebhookPayload
})
describe('add-pr-comment action', () => {
it('runs', async () => {
await expect(run()).resolves.not.toThrow()
})
})