Commit c425a837 by Lukas Siatka Committed by Lukas Siatka

Explore: adds basic tests to TableContainer checking the render and output on 0 series returned

parent f7fe4d48
import React from 'react';
import { shallow, render } from 'enzyme';
import { TableContainer } from './TableContainer';
import { DataFrame } from '@grafana/data';
import { toggleTable } from './state/actions';
import { ExploreId } from 'app/types/explore';
describe('TableContainer', () => {
it('should render component', () => {
const props = {
exploreId: ExploreId.left as ExploreId,
loading: false,
width: 800,
onClickCell: jest.fn(),
showingTable: true,
tableResult: {} as DataFrame,
toggleTable: {} as typeof toggleTable,
};
const wrapper = shallow(<TableContainer {...props} />);
expect(wrapper).toMatchSnapshot();
});
it('should render 0 series returned on no items', () => {
const props = {
exploreId: ExploreId.left as ExploreId,
loading: false,
width: 800,
onClickCell: jest.fn(),
showingTable: true,
tableResult: {
name: 'TableResultName',
fields: [],
length: 0,
} as DataFrame,
toggleTable: {} as typeof toggleTable,
};
const wrapper = render(<TableContainer {...props} />);
expect(wrapper.find('0 series returned')).toBeTruthy();
});
});
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`TableContainer should render component 1`] = `
<Collapse
collapsible={true}
isOpen={true}
label="Table"
loading={false}
onToggle={[Function]}
>
<Component
metaItems={
Array [
Object {
"value": "0 series returned",
},
]
}
/>
</Collapse>
`;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment