setup-php/__tests__/matchers.test.ts

25 lines
778 B
TypeScript
Raw Normal View History

2019-12-19 04:08:12 +07:00
import * as io from '@actions/io';
import * as matchers from '../src/matchers';
jest.mock('@actions/io');
describe('Matchers', () => {
it('Add matchers', async () => {
process.env['RUNNER_TOOL_CACHE'] = __dirname;
await matchers.addMatchers();
const spy = jest.spyOn(io, 'cp');
expect(spy).toHaveBeenCalledTimes(1);
});
it('Test Regex', async () => {
const regex1 = /^\d+\)\s.*$/;
2020-01-26 06:29:20 +07:00
const regex2 = /^(.*Failed\sasserting\sthat.*)$/;
2019-12-19 04:08:12 +07:00
const regex3 = /^\s*$/;
const regex4 = /^(.*):(\d+)$/;
expect(regex1.test('1) Tests\\Test::it_tests')).toBe(true);
expect(regex2.test('Failed asserting that false is true')).toBe(true);
expect(regex3.test('\n')).toBe(true);
expect(regex4.test('/path/to/file.php:42')).toBe(true);
});
});