add test for issue option (#20)
This commit is contained in:
44
__tests__/issue.test.ts
Normal file
44
__tests__/issue.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import * as issue from '../src/issue'
|
||||
import {IssueOption} from '../src/interface'
|
||||
|
||||
describe('getIssueOption', () => {
|
||||
test('without assignee and label', () => {
|
||||
process.env.INPUT_ISSUE_TITLE = 'npm audit found vulnerabilities'
|
||||
|
||||
const expected: IssueOption = {
|
||||
title: 'npm audit found vulnerabilities',
|
||||
body: 'hi',
|
||||
assignees: [''],
|
||||
labels: ['']
|
||||
}
|
||||
expect(issue.getIssueOption('hi')).toEqual(expected)
|
||||
})
|
||||
|
||||
test('with 1 assignee and 1 label', () => {
|
||||
process.env.INPUT_ISSUE_TITLE = 'npm audit found vulnerabilities'
|
||||
process.env.INPUT_ISSUE_ASSIGNEES = 'alice'
|
||||
process.env.INPUT_ISSUE_LABELS = 'foo'
|
||||
|
||||
const expected: IssueOption = {
|
||||
title: 'npm audit found vulnerabilities',
|
||||
body: 'hi',
|
||||
assignees: ['alice'],
|
||||
labels: ['foo']
|
||||
}
|
||||
expect(issue.getIssueOption('hi')).toEqual(expected)
|
||||
})
|
||||
|
||||
test('with 2 assignees and 2 labels', () => {
|
||||
process.env.INPUT_ISSUE_TITLE = 'npm audit found vulnerabilities'
|
||||
process.env.INPUT_ISSUE_ASSIGNEES = 'alice,bob'
|
||||
process.env.INPUT_ISSUE_LABELS = 'foo,bar'
|
||||
|
||||
const expected: IssueOption = {
|
||||
title: 'npm audit found vulnerabilities',
|
||||
body: 'hi',
|
||||
assignees: ['alice', 'bob'],
|
||||
labels: ['foo', 'bar']
|
||||
}
|
||||
expect(issue.getIssueOption('hi')).toEqual(expected)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user