mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: adds basic tests to TableContainer checking the render and output on 0 series returned
This commit is contained in:
committed by
Lukas Siatka
parent
f7fe4d4865
commit
c425a837a9
42
public/app/features/explore/TableContainer.test.tsx
Normal file
42
public/app/features/explore/TableContainer.test.tsx
Normal 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();
|
||||
});
|
||||
});
|
||||
@@ -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>
|
||||
`;
|
||||
Reference in New Issue
Block a user