The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/panel/nodeGraph/Legend.test.tsx

29 lines
1.0 KiB

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)');
});
});