mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com> Co-authored-by: Josh Hunt <joshhunt@users.noreply.github.com> Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> Co-authored-by: polinaboneva <polina.boneva@grafana.com>
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { render } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import { PanelModel } from '../dashboard/state';
|
|
import { createDashboardModelFixture, createPanelJSONFixture } from '../dashboard/state/__fixtures__/dashboardFixtures';
|
|
|
|
import { TestRuleResult, Props } from './TestRuleResult';
|
|
|
|
jest.mock('@grafana/runtime', () => {
|
|
const original = jest.requireActual('@grafana/runtime');
|
|
|
|
return {
|
|
...original,
|
|
getBackendSrv: () => ({
|
|
post: jest.fn(),
|
|
}),
|
|
};
|
|
});
|
|
|
|
const props: Props = {
|
|
panel: new PanelModel({ id: 1 }),
|
|
dashboard: createDashboardModelFixture({
|
|
panels: [createPanelJSONFixture({ id: 1 })],
|
|
}),
|
|
};
|
|
|
|
describe('TestRuleResult', () => {
|
|
it('should render without error', () => {
|
|
expect(() => render(<TestRuleResult {...props} />)).not.toThrow();
|
|
});
|
|
|
|
it('should call testRule when mounting', () => {
|
|
jest.spyOn(TestRuleResult.prototype, 'testRule');
|
|
render(<TestRuleResult {...props} />);
|
|
|
|
expect(TestRuleResult.prototype.testRule).toHaveBeenCalled();
|
|
});
|
|
});
|