Skip to content

Commit

Permalink
Fix broken jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Jul 26, 2019
1 parent d145f25 commit cad9add
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
36 changes: 19 additions & 17 deletions x-pack/legacy/plugins/actions/server/action_type_registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@ describe('register()', () => {
expect(actionTypeRegistry.has('my-action-type')).toEqual(true);
expect(mockTaskManager.registerTaskDefinitions).toHaveBeenCalledTimes(1);
expect(mockTaskManager.registerTaskDefinitions.mock.calls[0]).toMatchInlineSnapshot(`
Array [
Object {
"actions:my-action-type": Object {
"createTaskRunner": [MockFunction],
"title": "My action type",
"type": "actions:my-action-type",
},
},
]
`);
Array [
Object {
"actions:my-action-type": Object {
"createTaskRunner": [MockFunction],
"getRetry": [Function],
"maxAttempts": 1,
"title": "My action type",
"type": "actions:my-action-type",
},
},
]
`);
expect(getCreateTaskRunnerFunction).toHaveBeenCalledTimes(1);
const call = getCreateTaskRunnerFunction.mock.calls[0][0];
expect(call.actionTypeRegistry).toBeTruthy();
Expand Down Expand Up @@ -99,13 +101,13 @@ describe('get()', () => {
});
const actionType = actionTypeRegistry.get('my-action-type');
expect(actionType).toMatchInlineSnapshot(`
Object {
"executor": [Function],
"id": "my-action-type",
"name": "My action type",
"unencryptedAttributes": Array [],
}
`);
Object {
"executor": [Function],
"id": "my-action-type",
"name": "My action type",
"unencryptedAttributes": Array [],
}
`);
});

test(`throws an error when action type doesn't exist`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ test('executes the task by calling the executor with proper parameters', async (
const { execute: mockExecute } = jest.requireMock('./execute');
const createTaskRunner = getCreateTaskRunnerFunction(getCreateTaskRunnerFunctionParams);
const runner = createTaskRunner({ taskInstance: taskInstanceMock });

mockExecute.mockResolvedValueOnce({ status: 'ok' });

const runnerResult = await runner.run();

expect(runnerResult).toBeUndefined();
Expand Down

0 comments on commit cad9add

Please sign in to comment.