Files
Ashley Harrison 47f8717149 React: Use new JSX transform (#88802)
* 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
2024-06-25 12:43:47 +01:00

39 lines
1.3 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { locationService } from '@grafana/runtime';
import { PanelNotSupported, Props } from './PanelNotSupported';
import { PanelEditorTabId } from './types';
const setupTestContext = (options: Partial<Props>) => {
const defaults: Props = { message: '' };
const props = { ...defaults, ...options };
render(<PanelNotSupported {...props} />);
return { props };
};
describe('PanelNotSupported', () => {
describe('when component is mounted', () => {
it('then the supplied message should be shown', () => {
setupTestContext({ message: 'Expected message' });
expect(screen.getByRole('heading', { name: /expected message/i })).toBeInTheDocument();
});
it('then the back to queries button should exist', () => {
setupTestContext({ message: 'Expected message' });
expect(screen.getByRole('button', { name: /go back to queries/i })).toBeInTheDocument();
});
});
describe('when the back to queries button is clicked', () => {
it('then correct action should be dispatched', async () => {
setupTestContext({});
await userEvent.click(screen.getByRole('button', { name: /go back to queries/i }));
expect(locationService.getSearchObject().tab).toBe(PanelEditorTabId.Query);
});
});
});