2018-09-25 04:50:55 -05:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
2018-10-05 04:39:00 -05:00
|
|
|
import { Graph } from './Graph';
|
2018-09-25 04:50:55 -05:00
|
|
|
import { mockData } from './__mocks__/mockData';
|
2019-07-06 01:05:53 -05:00
|
|
|
import { DefaultTimeZone } from '@grafana/data';
|
2018-09-25 04:50:55 -05:00
|
|
|
|
|
|
|
const setup = (propOverrides?: object) => {
|
2018-10-22 10:51:42 -05:00
|
|
|
const props = {
|
2019-02-05 02:57:54 -06:00
|
|
|
size: { width: 10, height: 20 },
|
2018-10-22 10:51:42 -05:00
|
|
|
data: mockData().slice(0, 19),
|
2019-04-29 11:28:41 -05:00
|
|
|
range: { from: 0, to: 1 },
|
|
|
|
timeZone: DefaultTimeZone,
|
2018-10-22 10:51:42 -05:00
|
|
|
...propOverrides,
|
|
|
|
};
|
2018-09-25 04:50:55 -05:00
|
|
|
|
|
|
|
// Enzyme.shallow did not work well with jquery.flop. Mocking the draw function.
|
|
|
|
Graph.prototype.draw = jest.fn();
|
|
|
|
|
|
|
|
const wrapper = shallow(<Graph {...props} />);
|
|
|
|
const instance = wrapper.instance() as Graph;
|
|
|
|
|
|
|
|
return {
|
|
|
|
wrapper,
|
|
|
|
instance,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('Render', () => {
|
|
|
|
it('should render component', () => {
|
|
|
|
const { wrapper } = setup();
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render component with disclaimer', () => {
|
|
|
|
const { wrapper } = setup({
|
|
|
|
data: mockData(),
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should show query return no time series', () => {
|
|
|
|
const { wrapper } = setup({
|
|
|
|
data: [],
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|