Skip to content

Commit

Permalink
removed casting to LicenseType
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Dec 8, 2020
1 parent 5f3fa51 commit 3d264d9
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions x-pack/plugins/alerts/server/task_runner/task_runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ import { IEventLogger } from '../../../event_log/server';
import { SavedObjectsErrorHelpers } from '../../../../../src/core/server';
import { Alert, RecoveredActionGroup } from '../../common';
import { omit } from 'lodash';
import { LicenseType } from '../../../licensing/server';
import { NormalizedAlertType } from '../alert_type_registry';
const alertType = {
id: 'test',
name: 'My test alert',
actionGroups: [{ id: 'default', name: 'Default' }, RecoveredActionGroup],
defaultActionGroupId: 'default',
minimumLicenseRequired: 'basic' as LicenseType,
minimumLicenseRequired: 'basic',
recoveryActionGroup: RecoveredActionGroup,
executor: jest.fn(),
producer: 'alerts',
};

let fakeTimer: sinon.SinonFakeTimers;

describe('Task Runner', () => {
Expand Down Expand Up @@ -142,7 +143,7 @@ describe('Task Runner', () => {

test('successfully executes the task', async () => {
const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
{
...mockedTaskInstance,
state: {
Expand Down Expand Up @@ -228,7 +229,7 @@ describe('Task Runner', () => {
}
);
const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -363,7 +364,7 @@ describe('Task Runner', () => {
}
);
const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -530,7 +531,7 @@ describe('Task Runner', () => {
}
);
const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
{
...mockedTaskInstance,
state: {
Expand Down Expand Up @@ -613,7 +614,7 @@ describe('Task Runner', () => {
}
);
const taskRunner = new TaskRunner(
alertTypeWithCustomRecovery,
alertTypeWithCustomRecovery as NormalizedAlertType,
{
...mockedTaskInstance,
state: {
Expand Down Expand Up @@ -704,7 +705,7 @@ describe('Task Runner', () => {
);
const date = new Date().toISOString();
const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
{
...mockedTaskInstance,
state: {
Expand Down Expand Up @@ -833,7 +834,7 @@ describe('Task Runner', () => {
param1: schema.string(),
}),
},
},
} as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -861,7 +862,7 @@ describe('Task Runner', () => {

test('uses API key when provided', async () => {
const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -894,7 +895,7 @@ describe('Task Runner', () => {

test(`doesn't use API key when not provided`, async () => {
const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -924,7 +925,7 @@ describe('Task Runner', () => {

test('rescheduled the Alert if the schedule has update during a task run', async () => {
const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -965,7 +966,7 @@ describe('Task Runner', () => {
);

const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -1032,7 +1033,7 @@ describe('Task Runner', () => {
});

const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -1091,7 +1092,7 @@ describe('Task Runner', () => {
});

const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -1158,7 +1159,7 @@ describe('Task Runner', () => {
});

const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -1228,7 +1229,7 @@ describe('Task Runner', () => {
const legacyTaskInstance = omit(mockedTaskInstance, 'schedule');

const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
legacyTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down Expand Up @@ -1266,7 +1267,7 @@ describe('Task Runner', () => {
);

const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
{
...mockedTaskInstance,
state: originalAlertSate,
Expand Down Expand Up @@ -1297,7 +1298,7 @@ describe('Task Runner', () => {
});

const taskRunner = new TaskRunner(
alertType,
alertType as NormalizedAlertType,
mockedTaskInstance,
taskRunnerFactoryInitializerParams
);
Expand Down

0 comments on commit 3d264d9

Please sign in to comment.