Skip to content

Commit

Permalink
fixed some more missed anys
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmorris committed Apr 23, 2020
1 parent 8a7e27c commit 5565c98
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
10 changes: 6 additions & 4 deletions x-pack/plugins/actions/server/builtin_action_types/slack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,12 @@ describe('execute()', () => {
params: { message: 'this invocation should succeed' },
});
expect(response).toMatchInlineSnapshot(`
Object {
"text": "slack mockExecutor success: this invocation should succeed",
}
`);
Object {
"actionId": "",
"status": "ok",
"text": "slack mockExecutor success: this invocation should succeed",
}
`);
});

test('calls the mock executor with failure', async () => {
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/alerting/server/alerts_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import uuid from 'uuid';
import { schema } from '@kbn/config-schema';
import { AlertsClient } from './alerts_client';
import { AlertsClient, CreateOptions } from './alerts_client';
import { savedObjectsClientMock, loggingServiceMock } from '../../../../src/core/server/mocks';
import { taskManagerMock } from '../../../plugins/task_manager/server/task_manager.mock';
import { alertTypeRegistryMock } from './alert_type_registry.mock';
Expand Down Expand Up @@ -45,6 +45,7 @@ beforeEach(() => {
});

const mockedDate = new Date('2019-02-12T21:01:22.479Z');
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(global as any).Date = class Date {
constructor() {
return mockedDate;
Expand All @@ -54,7 +55,7 @@ const mockedDate = new Date('2019-02-12T21:01:22.479Z');
}
};

function getMockData(overwrites: Record<string, any> = {}) {
function getMockData(overwrites: Record<string, unknown> = {}): CreateOptions['data'] {
return {
enabled: true,
name: 'abc',
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting/server/alerts_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export interface FindResult {
data: SanitizedAlert[];
}

interface CreateOptions {
export interface CreateOptions {
data: Omit<
Alert,
| 'id'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ test('createAPIKey() returns an API key when security is enabled', async () => {
const createAPIKeyResult = await constructorCall.createAPIKey();
expect(createAPIKeyResult).toEqual({
apiKeysEnabled: true,
result: { api_key: '123', id: 'abc' },
result: { api_key: '123', id: 'abc', name: '' },
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { getNextRunAt } from './get_next_run_at';

const mockedNow = new Date('2019-06-03T18:55:25.982Z');
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(global as any).Date = class Date extends global.Date {
static now() {
return mockedNow.getTime();
Expand Down
12 changes: 6 additions & 6 deletions x-pack/plugins/task_manager/server/task_runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,8 @@ describe('TaskManagerRunner', () => {

interface TestOpts {
instance?: Partial<ConcreteTaskInstance>;
definitions?: any;
onTaskEvent?: (event: TaskEvent<any, any>) => void;
definitions?: unknown;
onTaskEvent?: (event: TaskEvent<unknown, unknown>) => void;
}

function testOpts(opts: TestOpts) {
Expand Down Expand Up @@ -904,7 +904,7 @@ describe('TaskManagerRunner', () => {
title: 'Bar!',
createTaskRunner,
},
}),
}) as TaskDictionary<TaskDefinition>,
onTaskEvent: opts.onTaskEvent,
});

Expand All @@ -918,7 +918,7 @@ describe('TaskManagerRunner', () => {
};
}

async function testReturn(result: any, shouldBeValid: boolean) {
async function testReturn(result: unknown, shouldBeValid: boolean) {
const { runner, logger } = testOpts({
definitions: {
bar: {
Expand All @@ -939,11 +939,11 @@ describe('TaskManagerRunner', () => {
}
}

function allowsReturnType(result: any) {
function allowsReturnType(result: unknown) {
return testReturn(result, true);
}

function disallowsReturnType(result: any) {
function disallowsReturnType(result: unknown) {
return testReturn(result, false);
}
});

0 comments on commit 5565c98

Please sign in to comment.