mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
histogram: add UI tests for rendering histogram (#13631)
* histogram: add tests for rendering histograms Signed-off-by: Manik Rana <manikrana54@gmail.com> * histogram: add tests for rendering histograms Signed-off-by: Manik Rana <manikrana54@gmail.com> * chore: remove unused import Signed-off-by: Manik Rana <manikrana54@gmail.com> --------- Signed-off-by: Manik Rana <manikrana54@gmail.com>
This commit is contained in:
parent
c6c8f63516
commit
08832e2db8
|
@ -1,7 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
import DataTable, { DataTableProps } from './DataTable';
|
||||
import HistogramString, { HistogramStringProps } from './DataTable';
|
||||
import { Alert, Table } from 'reactstrap';
|
||||
import SeriesName from './SeriesName';
|
||||
|
||||
|
@ -130,7 +129,7 @@ describe('DataTable', () => {
|
|||
},
|
||||
useLocalTime: false,
|
||||
};
|
||||
const dataTable = shallow(<DataTable {...dataTableProps} />);
|
||||
const dataTable = mount(<DataTable {...dataTableProps} />);
|
||||
|
||||
it('renders a table', () => {
|
||||
const table = dataTable.find(Table);
|
||||
|
@ -142,10 +141,30 @@ describe('DataTable', () => {
|
|||
|
||||
it('renders rows', () => {
|
||||
const table = dataTable.find(Table);
|
||||
const histogramData = [{
|
||||
count: '10',
|
||||
sum: '3.3',
|
||||
buckets: [
|
||||
[1, '-1', '-0.5', '2'],
|
||||
[3, '-0.5', '0.5', '3'],
|
||||
[0, '0.5', '1', '5'],
|
||||
]
|
||||
},
|
||||
{
|
||||
count: '5',
|
||||
sum: '1.11',
|
||||
buckets: [
|
||||
[0, '0.5', '1', '2'],
|
||||
[0, '1', '2', '3'],
|
||||
],
|
||||
}];
|
||||
table.find('tr').forEach((row, idx) => {
|
||||
expect(row.find(SeriesName)).toHaveLength(1);
|
||||
// TODO(beorn7): This doesn't actually test the rendoring yet. Need to trigger it somehow.
|
||||
expect(row.find('td').at(1).text()).toEqual(` <HistogramString />`);
|
||||
const seriesNameComponent = dataTable.find('SeriesName');
|
||||
expect(seriesNameComponent).toHaveLength(dataTableProps.data?.result.length as number);
|
||||
|
||||
const histogramStringComponent = row.find('HistogramString');
|
||||
expect(histogramStringComponent).toHaveLength(1);
|
||||
expect(histogramStringComponent.prop('h')).toEqual(histogramData[idx]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue