|
| 1 | +const BaseRef = require('../../../lib/filters/baseRef') |
| 2 | +const Helper = require('../../../__fixtures__/unit/helper') |
| 3 | + |
| 4 | +test('should fail with unexpected baseRef', async () => { |
| 5 | + const baseRef = new BaseRef() |
| 6 | + const settings = { |
| 7 | + do: 'baseRef', |
| 8 | + must_include: { |
| 9 | + regex: 'some-other-ref' |
| 10 | + } |
| 11 | + } |
| 12 | + const filter = await baseRef.processFilter(createMockContext('some-ref'), settings) |
| 13 | + expect(filter.status).toBe('fail') |
| 14 | +}) |
| 15 | + |
| 16 | +test('should pass with expected baseRef', async () => { |
| 17 | + const baseRef = new BaseRef() |
| 18 | + const settings = { |
| 19 | + do: 'baseRef', |
| 20 | + must_include: { |
| 21 | + regex: 'some-ref' |
| 22 | + } |
| 23 | + } |
| 24 | + const filter = await baseRef.processFilter(createMockContext('some-ref'), settings) |
| 25 | + expect(filter.status).toBe('pass') |
| 26 | +}) |
| 27 | + |
| 28 | +test('should fail with excluded baseRef', async () => { |
| 29 | + const baseRef = new BaseRef() |
| 30 | + const settings = { |
| 31 | + do: 'baseRef', |
| 32 | + must_exclude: { |
| 33 | + regex: 'some-ref' |
| 34 | + } |
| 35 | + } |
| 36 | + const filter = await baseRef.processFilter(createMockContext('some-ref'), settings) |
| 37 | + expect(filter.status).toBe('fail') |
| 38 | +}) |
| 39 | + |
| 40 | +test('should pass with excluded baseRef', async () => { |
| 41 | + const baseRef = new BaseRef() |
| 42 | + const settings = { |
| 43 | + do: 'baseRef', |
| 44 | + must_exclude: { |
| 45 | + regex: 'some-other-ref' |
| 46 | + } |
| 47 | + } |
| 48 | + const filter = await baseRef.processFilter(createMockContext('some-ref'), settings) |
| 49 | + expect(filter.status).toBe('pass') |
| 50 | +}) |
| 51 | + |
| 52 | +const createMockContext = (baseRef) => { |
| 53 | + return Helper.mockContext({ baseRef }) |
| 54 | +} |
0 commit comments