|
1 | | -import {getConventionalCommitTypes, lintPullRequest} from '../lint'; |
| 1 | +import { |
| 2 | + getConventionalCommitTypes, |
| 3 | + lintPullRequest, |
| 4 | + isBotIgnored, |
| 5 | +} from '../lint'; |
| 6 | +import {getInput} from '@actions/core'; |
| 7 | + |
| 8 | +jest.mock('@actions/core'); |
2 | 9 |
|
3 | 10 | describe('getConvetionalCommitTypes tests', () => { |
4 | | - it('should return types', () => { |
| 11 | + test('should return types', () => { |
5 | 12 | const types = getConventionalCommitTypes(); |
6 | 13 |
|
7 | 14 | expect( |
@@ -30,8 +37,26 @@ describe('lintPullRequest tests', () => { |
30 | 37 | ]; |
31 | 38 |
|
32 | 39 | tests.forEach(({args, expected}) => { |
33 | | - it(`should pass or fail linting ['${args}', '${expected}']`, async () => { |
| 40 | + test(`should pass or fail linting ['${args}', '${expected}']`, async () => { |
34 | 41 | expect(await lintPullRequest(args)).toBe(expected); |
35 | 42 | }); |
36 | 43 | }); |
37 | 44 | }); |
| 45 | + |
| 46 | +jest.mock('@actions/github', () => ({ |
| 47 | + context: { |
| 48 | + actor: 'test-bot', |
| 49 | + }, |
| 50 | +})); |
| 51 | + |
| 52 | +describe('isBotIgnored tests', () => { |
| 53 | + test('should return true if the bot is in the ignore list', () => { |
| 54 | + (getInput as jest.Mock).mockReturnValue('test-bot,another-bot'); |
| 55 | + expect(isBotIgnored()).toBe(true); |
| 56 | + }); |
| 57 | + |
| 58 | + test('should return false if the bot is not in the ignore list', () => { |
| 59 | + (getInput as jest.Mock).mockReturnValue('another-bot'); |
| 60 | + expect(isBotIgnored()).toBe(false); |
| 61 | + }); |
| 62 | +}); |
0 commit comments