UNPKG

769 BJavaScriptView Raw
1/*eslint-env jest*/
2
3const testTask = jest.fn();
4const plugin = { id: 'testPlugin' };
5
6jest.mock('./plugin_config', () => () => plugin);
7jest.mock('./tasks', () => {
8 return { testTask };
9});
10const run = require('./run');
11
12describe('task runner', () => {
13 beforeEach(() => jest.resetAllMocks());
14
15 it('throw given an invalid task', function () {
16 const invalidTaskName = 'thisisnotavalidtasknameandneverwillbe';
17 const runner = () => run(invalidTaskName);
18
19 expect(runner).toThrow(/invalid task/i);
20 });
21
22 it('runs specified task with plugin and runner', function () {
23 run('testTask');
24
25 const args = testTask.mock.calls[0];
26 expect(testTask.mock.calls).toHaveLength(1);
27 expect(args[0]).toBe(plugin);
28 expect(args[1]).toBe(run);
29 });
30});
\No newline at end of file