mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
convert TestRuleResult to RTL (#53953)
This commit is contained in:
parent
4ca845e479
commit
b6835ef87d
@ -68,9 +68,6 @@ exports[`no enzyme tests`] = {
|
||||
"public/app/features/alerting/AlertRuleList.test.tsx:2998938420": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/alerting/TestRuleResult.test.tsx:2358420489": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx:3716733755": [
|
||||
[0, 35, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { shallow } from 'enzyme';
|
||||
import { render } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { DashboardModel, PanelModel } from '../dashboard/state';
|
||||
@ -16,35 +16,20 @@ jest.mock('@grafana/runtime', () => {
|
||||
};
|
||||
});
|
||||
|
||||
const setup = (propOverrides?: object) => {
|
||||
const props: Props = {
|
||||
panel: new PanelModel({ id: 1 }),
|
||||
dashboard: new DashboardModel({ panels: [{ id: 1 }] }),
|
||||
};
|
||||
|
||||
Object.assign(props, propOverrides);
|
||||
|
||||
const wrapper = shallow(<TestRuleResult {...props} />);
|
||||
|
||||
return { wrapper, instance: wrapper.instance() as TestRuleResult };
|
||||
const props: Props = {
|
||||
panel: new PanelModel({ id: 1 }),
|
||||
dashboard: new DashboardModel({ panels: [{ id: 1 }] }),
|
||||
};
|
||||
|
||||
describe('Render', () => {
|
||||
it('should render component', () => {
|
||||
const { wrapper } = setup();
|
||||
describe('TestRuleResult', () => {
|
||||
it('should render without error', () => {
|
||||
expect(() => render(<TestRuleResult {...props} />)).not.toThrow();
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Life cycle', () => {
|
||||
describe('component did mount', () => {
|
||||
it('should call testRule', () => {
|
||||
const { instance } = setup();
|
||||
instance.testRule = jest.fn();
|
||||
instance.componentDidMount();
|
||||
|
||||
expect(instance.testRule).toHaveBeenCalled();
|
||||
});
|
||||
it('should call testRule when mounting', () => {
|
||||
jest.spyOn(TestRuleResult.prototype, 'testRule');
|
||||
render(<TestRuleResult {...props} />);
|
||||
|
||||
expect(TestRuleResult.prototype.testRule).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Render should render component 1`] = `
|
||||
<LoadingPlaceholder
|
||||
text="Evaluating rule"
|
||||
/>
|
||||
`;
|
Loading…
Reference in New Issue
Block a user