Skip to content

Commit

Permalink
Fix types check
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Nov 4, 2020
1 parent 3130434 commit 2303e80
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ export class EventsFactory {
}

addActiveInstance(instanceId: string, actionGroupId: string | undefined): EventsFactory {
const kibanaAlerting = (actionGroupId)
const kibanaAlerting = actionGroupId
? { instance_id: instanceId, action_group_id: actionGroupId }
: { instance_id: instanceId };
this.events.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import uuid from 'uuid';
import { shallow } from 'enzyme';
import { ToastsApi } from 'kibana/public';
import { AlertInstancesRoute, getAlertInstanceSummary } from './alert_instances_route';
import { Alert, AlertInstanceSummary } from '../../../../types';
import { Alert, AlertInstanceSummary, AlertType } from '../../../../types';
import { EuiLoadingSpinner } from '@elastic/eui';

const fakeNow = new Date('2020-02-09T23:15:41.941Z');
Expand All @@ -23,10 +23,11 @@ jest.mock('../../../app_context', () => {
describe('alert_instance_summary_route', () => {
it('render a loader while fetching data', () => {
const alert = mockAlert();
const alertType = mockAlertType();

expect(
shallow(
<AlertInstancesRoute readOnly={false} alert={alert} {...mockApis()} />
<AlertInstancesRoute readOnly={false} alert={alert} alertType={alertType} {...mockApis()} />
).containsMatchingElement(<EuiLoadingSpinner size="l" />)
).toBeTruthy();
});
Expand Down Expand Up @@ -140,6 +141,23 @@ function mockAlert(overloads: Partial<Alert> = {}): Alert {
};
}

function mockAlertType(overloads: Partial<AlertType> = {}): AlertType {
return {
id: 'test.testAlertType',
name: 'My Test Alert Type',
actionGroups: [{ id: 'default', name: 'Default Action Group' }],
actionVariables: {
context: [],
state: [],
params: [],
},
defaultActionGroupId: 'default',
authorizedConsumers: {},
producer: 'alerts',
...overloads,
};
}

function mockAlertInstanceSummary(overloads: Partial<any> = {}): any {
const summary: AlertInstanceSummary = {
id: 'alert-id',
Expand Down

0 comments on commit 2303e80

Please sign in to comment.