mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added tests for TestRuleButton
This commit is contained in:
parent
8b8af6436c
commit
9b8a5333cb
44
public/app/features/alerting/TestRuleButton.test.tsx
Normal file
44
public/app/features/alerting/TestRuleButton.test.tsx
Normal file
@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { DashboardModel } from '../dashboard/dashboard_model';
|
||||
import { Props, TestRuleButton } from './TestRuleButton';
|
||||
|
||||
jest.mock('app/core/services/backend_srv', () => ({
|
||||
getBackendSrv: () => ({
|
||||
post: jest.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
const setup = (propOverrides?: object) => {
|
||||
const props: Props = {
|
||||
panelId: 1,
|
||||
dashboard: new DashboardModel({ panels: [{ id: 1 }] }),
|
||||
LoadingPlaceholder: {},
|
||||
};
|
||||
|
||||
Object.assign(props, propOverrides);
|
||||
|
||||
const wrapper = shallow(<TestRuleButton {...props} />);
|
||||
|
||||
return { wrapper, instance: wrapper.instance() as TestRuleButton };
|
||||
};
|
||||
|
||||
describe('Render', () => {
|
||||
it('should render component', () => {
|
||||
const { wrapper } = setup();
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,15 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Render should render component 1`] = `
|
||||
<Fragment>
|
||||
<JSONFormatter
|
||||
config={
|
||||
Object {
|
||||
"animateOpen": true,
|
||||
}
|
||||
}
|
||||
json={Object {}}
|
||||
open={3}
|
||||
/>
|
||||
</Fragment>
|
||||
`;
|
Loading…
Reference in New Issue
Block a user