grafana/public/app/features/logs/components/LogLabels.test.tsx
Gábor Farkas 1ee6a1f7c2
Logs: move logs-components from grafana-ui to grafana-main (#55041)
* logs: added a copy of the grafana-ui logs-files

* fix: added the ansicolor package to the main grafana package

* logs-components: import things from grafana-ui

* import from local files

* logs-components: other fixes

* add betterer-exceptions

* apply updates from grafana-ui package
2022-09-19 10:51:46 +02:00

28 lines
1.1 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import React from 'react';
import { LogLabels } from './LogLabels';
describe('<LogLabels />', () => {
it('renders notice when no labels are found', () => {
render(<LogLabels labels={{}} />);
expect(screen.queryByText('(no unique labels)')).toBeInTheDocument();
});
it('renders labels', () => {
render(<LogLabels labels={{ foo: 'bar', baz: '42' }} />);
expect(screen.queryByText('bar')).toBeInTheDocument();
expect(screen.queryByText('42')).toBeInTheDocument();
});
it('excludes labels with certain names or labels starting with underscore', () => {
render(<LogLabels labels={{ foo: 'bar', level: '42', _private: '13' }} />);
expect(screen.queryByText('bar')).toBeInTheDocument();
expect(screen.queryByText('42')).not.toBeInTheDocument();
expect(screen.queryByText('13')).not.toBeInTheDocument();
});
it('excludes labels with empty string values', () => {
render(<LogLabels labels={{ foo: 'bar', baz: '' }} />);
expect(screen.queryByText('bar')).toBeInTheDocument();
expect(screen.queryByText('baz')).not.toBeInTheDocument();
});
});