mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-13 06:47:28 -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 * as React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { mount, shallow } from 'enzyme';
|
||||||
import DataTable, { DataTableProps } from './DataTable';
|
import DataTable, { DataTableProps } from './DataTable';
|
||||||
import HistogramString, { HistogramStringProps } from './DataTable';
|
|
||||||
import { Alert, Table } from 'reactstrap';
|
import { Alert, Table } from 'reactstrap';
|
||||||
import SeriesName from './SeriesName';
|
import SeriesName from './SeriesName';
|
||||||
|
|
||||||
|
@ -130,7 +129,7 @@ describe('DataTable', () => {
|
||||||
},
|
},
|
||||||
useLocalTime: false,
|
useLocalTime: false,
|
||||||
};
|
};
|
||||||
const dataTable = shallow(<DataTable {...dataTableProps} />);
|
const dataTable = mount(<DataTable {...dataTableProps} />);
|
||||||
|
|
||||||
it('renders a table', () => {
|
it('renders a table', () => {
|
||||||
const table = dataTable.find(Table);
|
const table = dataTable.find(Table);
|
||||||
|
@ -142,10 +141,30 @@ describe('DataTable', () => {
|
||||||
|
|
||||||
it('renders rows', () => {
|
it('renders rows', () => {
|
||||||
const table = dataTable.find(Table);
|
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) => {
|
table.find('tr').forEach((row, idx) => {
|
||||||
expect(row.find(SeriesName)).toHaveLength(1);
|
const seriesNameComponent = dataTable.find('SeriesName');
|
||||||
// TODO(beorn7): This doesn't actually test the rendoring yet. Need to trigger it somehow.
|
expect(seriesNameComponent).toHaveLength(dataTableProps.data?.result.length as number);
|
||||||
expect(row.find('td').at(1).text()).toEqual(` <HistogramString />`);
|
|
||||||
|
const histogramStringComponent = row.find('HistogramString');
|
||||||
|
expect(histogramStringComponent).toHaveLength(1);
|
||||||
|
expect(histogramStringComponent.prop('h')).toEqual(histogramData[idx]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue