|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import { mount } from 'enzyme'; |
|
|
|
|
import { render, screen } from '@testing-library/react'; |
|
|
|
|
import React from 'react'; |
|
|
|
|
|
|
|
|
|
import { createDimension, ArrayVector, FieldType, DisplayProcessor } from '@grafana/data'; |
|
|
|
|
import { createDimension, createTheme, ArrayVector, FieldType, DisplayProcessor } from '@grafana/data'; |
|
|
|
|
|
|
|
|
|
import { ActiveDimensions } from '../../VizTooltip'; |
|
|
|
|
|
|
|
|
@ -12,6 +12,7 @@ let dimensions: GraphDimensions; |
|
|
|
|
|
|
|
|
|
describe('MultiModeGraphTooltip', () => { |
|
|
|
|
const display: DisplayProcessor = (v) => ({ numeric: v, text: String(v), color: 'red' }); |
|
|
|
|
const theme = createTheme(); |
|
|
|
|
|
|
|
|
|
describe('when shown when hovering over a datapoint', () => { |
|
|
|
|
beforeEach(() => { |
|
|
|
@ -57,7 +58,7 @@ describe('MultiModeGraphTooltip', () => { |
|
|
|
|
xAxis: [0, 1], // column, row
|
|
|
|
|
yAxis: [0, 1], // column, row
|
|
|
|
|
}; |
|
|
|
|
const container = mount( |
|
|
|
|
render( |
|
|
|
|
<MultiModeGraphTooltip |
|
|
|
|
dimensions={dimensions} |
|
|
|
|
activeDimensions={activeDimensions} |
|
|
|
@ -67,12 +68,13 @@ describe('MultiModeGraphTooltip', () => { |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// We rendered two series rows
|
|
|
|
|
const rows = container.find('SeriesTableRow'); |
|
|
|
|
const rows = screen.getAllByTestId('SeriesTableRow'); |
|
|
|
|
expect(rows.length).toEqual(2); |
|
|
|
|
|
|
|
|
|
// We expect A-series(1st row) to be highlighted
|
|
|
|
|
expect(rows.get(0).props.isActive).toBeTruthy(); |
|
|
|
|
// We expect A-series(1st row) not to be highlighted
|
|
|
|
|
expect(rows[0]).toHaveStyle(`font-weight: ${theme.typography.fontWeightMedium}`); |
|
|
|
|
// We expect B-series(2nd row) not to be highlighted
|
|
|
|
|
expect(rows.get(1).props.isActive).toBeFalsy(); |
|
|
|
|
expect(rows[1]).not.toHaveStyle(`font-weight: ${theme.typography.fontWeightMedium}`); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it("doesn't highlight series when not hovering over datapoint", () => { |
|
|
|
@ -82,7 +84,7 @@ describe('MultiModeGraphTooltip', () => { |
|
|
|
|
yAxis: null, // no active series
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const container = mount( |
|
|
|
|
render( |
|
|
|
|
<MultiModeGraphTooltip |
|
|
|
|
dimensions={dimensions} |
|
|
|
|
activeDimensions={activeDimensions} |
|
|
|
@ -92,12 +94,13 @@ describe('MultiModeGraphTooltip', () => { |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// We rendered two series rows
|
|
|
|
|
const rows = container.find('SeriesTableRow'); |
|
|
|
|
const rows = screen.getAllByTestId('SeriesTableRow'); |
|
|
|
|
expect(rows.length).toEqual(2); |
|
|
|
|
|
|
|
|
|
// We expect A-series(1st row) not to be highlighted
|
|
|
|
|
expect(rows.get(0).props.isActive).toBeFalsy(); |
|
|
|
|
expect(rows[0]).not.toHaveStyle(`font-weight: ${theme.typography.fontWeightMedium}`); |
|
|
|
|
// We expect B-series(2nd row) not to be highlighted
|
|
|
|
|
expect(rows.get(1).props.isActive).toBeFalsy(); |
|
|
|
|
expect(rows[1]).not.toHaveStyle(`font-weight: ${theme.typography.fontWeightMedium}`); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|