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

This commit is contained in:
Lukas Siatka
2020-01-27 04:27:09 +00:00
committed by Lukas Siatka
parent f7fe4d4865
commit c425a837a9
2 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
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();
});
});

View File

@@ -0,0 +1,21 @@
// 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>
`;