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/core/components/PageActionBar/PageActionBar.test.tsx

32 lines
934 B

import { render, screen } from '@testing-library/react';
import React from 'react';
import PageActionBar, { Props } from './PageActionBar';
const setup = (propOverrides?: object) => {
const props: Props = {
searchQuery: '',
setSearchQuery: jest.fn(),
target: '_blank',
linkButton: { href: 'some/url', title: 'test' },
};
Object.assign(props, propOverrides);
return render(<PageActionBar {...props} />);
};
describe('Render', () => {
it('should render component', () => {
setup();
expect(screen.getByRole('textbox')).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'test' })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Clear' })).not.toBeInTheDocument();
});
it('should render button when text is present', () => {
setup({ searchQuery: 'test query' });
expect(screen.getByRole('button', { name: 'Clear' })).toBeInTheDocument();
});
});