|
| 1 | +import * as path from 'path'; |
| 2 | +import addMatchers from './matchers'; |
| 3 | +import { createTempDir } from 'broccoli-test-helper'; |
| 4 | +import type { TempDir } from 'broccoli-test-helper'; |
| 5 | + |
| 6 | +const ORIGNAL_CONSOLE = Object.assign({}, console); |
| 7 | + |
| 8 | +describe('addMatchers', () => { |
| 9 | + let output: string[][]; |
| 10 | + let tmpdir: TempDir; |
| 11 | + |
| 12 | + beforeEach(async () => { |
| 13 | + output = []; |
| 14 | + |
| 15 | + console.log = (...args: string[]) => { |
| 16 | + output.push(args); |
| 17 | + }; |
| 18 | + |
| 19 | + tmpdir = await createTempDir(); |
| 20 | + }); |
| 21 | + |
| 22 | + afterEach(() => { |
| 23 | + Object.assign(console, ORIGNAL_CONSOLE); |
| 24 | + }); |
| 25 | + |
| 26 | + test('adds each of the matchers in the `matchers` directory', async () => { |
| 27 | + await addMatchers(); |
| 28 | + |
| 29 | + expect(output).toEqual([ |
| 30 | + [`##[add-matcher]${path.join(__dirname, '..', 'matchers', 'eslint-compact.json')}`], |
| 31 | + [`##[add-matcher]${path.join(__dirname, '..', 'matchers', 'eslint-stylish.json')}`], |
| 32 | + [`##[add-matcher]${path.join(__dirname, '..', 'matchers', 'tsc.json')}`], |
| 33 | + ]); |
| 34 | + }); |
| 35 | + |
| 36 | + test('adds matchers found', async () => { |
| 37 | + tmpdir.write({ |
| 38 | + 'foo.json': '{}', |
| 39 | + 'bar.json': '{}', |
| 40 | + }); |
| 41 | + await addMatchers(tmpdir.path()); |
| 42 | + |
| 43 | + expect(output).toEqual([ |
| 44 | + [`##[add-matcher]${path.normalize(tmpdir.path('bar.json'))}`], |
| 45 | + [`##[add-matcher]${path.normalize(tmpdir.path('foo.json'))}`], |
| 46 | + ]); |
| 47 | + }); |
| 48 | +}); |
0 commit comments