mirror of
https://github.com/mshick/add-pr-comment.git
synced 2025-12-31 14:20:32 +11:00
build(typescript): refactoring project with typescript and test setup
This commit is contained in:
parent
026d9b8889
commit
fe6d191bcd
13 changed files with 4956 additions and 25713 deletions
41
__tests__/add-pr-comment.test.ts
Normal file
41
__tests__/add-pr-comment.test.ts
Normal 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()
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue