mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 15:42:13 +08:00

* update eslint, tsconfig + esbuild to handle new jsx transform * remove thing that breaks the new jsx transform * remove react imports * adjust grafana-icons build * is this the correct syntax? * try this * well this was much easier than expected... * change grafana-plugin-configs webpack config * fixes * fix lockfile * fix 2 more violations * use path.resolve instead of require.resolve * remove react import * fix react imports * more fixes * remove React import * remove import React from docs * remove another react import
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
|
|
import { FieldColorModeId } from '@grafana/data';
|
|
|
|
import { Legend } from './Legend';
|
|
import { NodeDatum } from './types';
|
|
|
|
describe('Legend', () => {
|
|
it('renders ok without nodes', () => {
|
|
render(<Legend nodes={[]} onSort={(sort) => {}} sortable={false} />);
|
|
});
|
|
|
|
it('renders ok with color fields', () => {
|
|
const nodes = [
|
|
{
|
|
id: 'nodeId',
|
|
mainStat: { config: { displayName: 'stat1' } },
|
|
secondaryStat: { config: { displayName: 'stat2' } },
|
|
arcSections: [{ config: { displayName: 'error', color: { mode: FieldColorModeId.Fixed, fixedColor: 'red' } } }],
|
|
},
|
|
] as NodeDatum[];
|
|
render(<Legend nodes={nodes} onSort={(sort) => {}} sortable={false} />);
|
|
const items = screen.getAllByTestId(/VizLegend series/);
|
|
expect(items.length).toBe(3);
|
|
|
|
const item = screen.getByTestId(/VizLegend series error/);
|
|
expect((item.firstChild as HTMLDivElement).style.getPropertyValue('background')).toBe('rgb(242, 73, 92)');
|
|
});
|
|
});
|