diff --git a/public/app/features/alerting/AlertRuleItem.test.tsx b/public/app/features/alerting/AlertRuleItem.test.tsx index 0a1c5cbe437..397c5c5ac0c 100644 --- a/public/app/features/alerting/AlertRuleItem.test.tsx +++ b/public/app/features/alerting/AlertRuleItem.test.tsx @@ -2,6 +2,10 @@ import React from 'react'; import { shallow } from 'enzyme'; import AlertRuleItem, { Props } from './AlertRuleItem'; +jest.mock('react-redux', () => ({ + connect: params => params, +})); + const setup = (propOverrides?: object) => { const props: Props = { rule: { @@ -17,6 +21,7 @@ const setup = (propOverrides?: object) => { url: 'https://something.something.darkside', }, search: '', + togglePauseAlertRule: jest.fn(), }; Object.assign(props, propOverrides); diff --git a/public/app/features/alerting/state/selectors.test.ts b/public/app/features/alerting/state/selectors.test.ts new file mode 100644 index 00000000000..2d6d48caa2d --- /dev/null +++ b/public/app/features/alerting/state/selectors.test.ts @@ -0,0 +1,43 @@ +import { getSearchQuery, getAlertRuleItems } from './selectors'; +import { AlertRulesState } from '../../../types'; + +const defaultState: AlertRulesState = { + items: [], + searchQuery: '', +}; + +const getState = (overrides?: object) => Object.assign(defaultState, overrides); + +describe('Get search query', () => { + it('should get search query', () => { + const state = getState({ searchQuery: 'dashboard' }); + const result = getSearchQuery(state); + + expect(result).toEqual(state.searchQuery); + }); +}); + +describe('Get alert rule items', () => { + it('should get alert rule items', () => { + const state = getState({ + items: [ + { + id: 1, + dashboardId: 1, + panelId: 1, + name: '', + state: '', + stateText: '', + stateIcon: '', + stateClass: '', + stateAge: '', + url: '', + }, + ], + }); + + const result = getAlertRuleItems(state); + + expect(result.length).toEqual(0); + }); +}); diff --git a/public/app/types/index.ts b/public/app/types/index.ts index 6aa4dc23d97..1f17962a70b 100644 --- a/public/app/types/index.ts +++ b/public/app/types/index.ts @@ -32,8 +32,8 @@ export interface AlertRule { stateIcon: string; stateClass: string; stateAge: string; - info?: string; url: string; + info?: string; executionError?: string; evalData?: { noData: boolean }; }