1 |
|
2 |
|
3 | const testTask = jest.fn();
|
4 | const plugin = { id: 'testPlugin' };
|
5 |
|
6 | jest.mock('./plugin_config', () => () => plugin);
|
7 | jest.mock('./tasks', () => {
|
8 | return { testTask };
|
9 | });
|
10 | const run = require('./run');
|
11 |
|
12 | describe('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 |