mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
some basic selector tests
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
43
public/app/features/alerting/state/selectors.test.ts
Normal file
43
public/app/features/alerting/state/selectors.test.ts
Normal file
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -32,8 +32,8 @@ export interface AlertRule {
|
||||
stateIcon: string;
|
||||
stateClass: string;
|
||||
stateAge: string;
|
||||
info?: string;
|
||||
url: string;
|
||||
info?: string;
|
||||
executionError?: string;
|
||||
evalData?: { noData: boolean };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user