|
| 1 | +import { render } from "@testing-library/react"; |
| 2 | +import { LineChartProps, LineTimeSerieChart } from "./linetimeseriechart.component"; |
| 3 | +import { ChartLegendWrapper } from "../chartlegend/ChartLegendWrapper"; |
| 4 | +import { ThemeProvider } from "styled-components"; |
| 5 | +import { coreUIAvailableThemes } from "../../style/theme"; |
| 6 | + |
| 7 | +const TestSeries = [ |
| 8 | + { |
| 9 | + |
| 10 | + resource: "Series 1", |
| 11 | + getTooltipLabel: () => `Series 1`, |
| 12 | + data: [ |
| 13 | + [1622505600000, 10], |
| 14 | + [1622509200000, 20], |
| 15 | + [1622512800000, 30], |
| 16 | + ] as [number, number][], |
| 17 | + }, |
| 18 | + { |
| 19 | + resource: "Series 2", |
| 20 | + getTooltipLabel: () => `Series 2`, |
| 21 | + data: [ |
| 22 | + [1622505600000, 15], |
| 23 | + [1622509200000, 25], |
| 24 | + [1622512800000, 35], |
| 25 | + ] as [number, number][], |
| 26 | + }, |
| 27 | +]; |
| 28 | + |
| 29 | +const ColorSet = { |
| 30 | + "Series 1": "#FF0000", |
| 31 | + "Series 2": "#00FF00", |
| 32 | +}; |
| 33 | + |
| 34 | +const renderLineTimeSerieChart = (props: Partial<LineChartProps> = {}) => { |
| 35 | + return render( |
| 36 | + <ThemeProvider theme={coreUIAvailableThemes.artescaLight}> |
| 37 | + <ChartLegendWrapper colorSet={ColorSet}> |
| 38 | + <LineTimeSerieChart |
| 39 | + { |
| 40 | + ...{ |
| 41 | + title: "Test Chart", |
| 42 | + yAxisType: "default", |
| 43 | + series: TestSeries, |
| 44 | + height: 400, |
| 45 | + startingTimeStamp: TestSeries[0].data[0][0], |
| 46 | + interval: TestSeries[0].data[1][0] - TestSeries[0].data[0][0], |
| 47 | + duration: TestSeries[0].data[TestSeries[0].data.length - 1][0] - TestSeries[0].data[0][0], |
| 48 | + unitRange: [{ label: 'units', value: 1 }], |
| 49 | + ...props |
| 50 | + } as LineChartProps |
| 51 | + } |
| 52 | + /> |
| 53 | + </ChartLegendWrapper> |
| 54 | + </ThemeProvider> |
| 55 | + ); |
| 56 | +}; |
| 57 | + |
| 58 | +describe('LineTimeSerieChart', () => { |
| 59 | + it('should render when with basic parameters', async () => { |
| 60 | + const { container } = renderLineTimeSerieChart(); |
| 61 | + expect(container).toBeInTheDocument(); |
| 62 | + }); |
| 63 | + |
| 64 | + it('should render when no unitRange is provided', async () => { |
| 65 | + const { container } = renderLineTimeSerieChart({ unitRange: undefined }); |
| 66 | + expect(container).toBeInTheDocument(); |
| 67 | + }); |
| 68 | +}); |
0 commit comments