mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
3f15170914
* moving to data WIP * more refactoring * add missing test * mock full path * remove sinon from grafana-ui
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
import { shallow } from 'enzyme';
|
|
import { Graph } from './Graph';
|
|
import { mockData } from './__mocks__/mockData';
|
|
import { DefaultTimeZone } from '@grafana/data';
|
|
|
|
const setup = (propOverrides?: object) => {
|
|
const props = {
|
|
size: { width: 10, height: 20 },
|
|
data: mockData().slice(0, 19),
|
|
range: { from: 0, to: 1 },
|
|
timeZone: DefaultTimeZone,
|
|
...propOverrides,
|
|
};
|
|
|
|
// 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();
|
|
});
|
|
});
|