|
1 | 1 | /* eslint-disable no-magic-numbers */
|
2 | 2 | import { resolve } from 'path';
|
3 | 3 | import { testEnv, getOctokit, generateContext } from '@technote-space/github-action-test-helper';
|
4 |
| -import { getRunId, getTargetBranch } from '../../src/utils/misc'; |
| 4 | +import { isExcludeContext, getRunId, getTargetBranch } from '../../src/utils/misc'; |
5 | 5 |
|
6 | 6 | const rootDir = resolve(__dirname, '../..');
|
7 | 7 |
|
| 8 | +describe('isExcludeContext', () => { |
| 9 | + testEnv(rootDir); |
| 10 | + |
| 11 | + it('should true 1', () => { |
| 12 | + expect(isExcludeContext(generateContext({event: 'push', ref: 'refs/tags/v1.2.3'}))).toBe(true); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should true 2', () => { |
| 16 | + process.env.INPUT_EXCLUDE_MERGED = 'true'; |
| 17 | + expect(isExcludeContext(generateContext({event: 'push', ref: 'refs/heads/feature/change'}, { |
| 18 | + payload: { |
| 19 | + 'head_commit': { |
| 20 | + message: 'Merge pull request #260 from test', |
| 21 | + }, |
| 22 | + }, |
| 23 | + }))).toBe(true); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should false 1', () => { |
| 27 | + process.env.INPUT_EXCLUDE_TAG_PUSH = 'false'; |
| 28 | + expect(isExcludeContext(generateContext({event: 'push', ref: 'refs/tags/v1.2.3'}))).toBe(false); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should false 2', () => { |
| 32 | + expect(isExcludeContext(generateContext({event: 'push', ref: 'refs/heads/feature/change'}))).toBe(false); |
| 33 | + }); |
| 34 | + |
| 35 | + it('should false 3', () => { |
| 36 | + expect(isExcludeContext(generateContext({event: 'push', ref: 'refs/heads/feature/change'}, { |
| 37 | + payload: { |
| 38 | + 'head_commit': { |
| 39 | + message: 'Merge pull request #260 from test', |
| 40 | + }, |
| 41 | + }, |
| 42 | + }))).toBe(false); |
| 43 | + }); |
| 44 | +}); |
| 45 | + |
8 | 46 | describe('getRunId', () => {
|
9 | 47 | testEnv(rootDir);
|
10 | 48 |
|
|
0 commit comments