grafana/public/app/features/dashboard/components/PanelEditor/PanelNotSupported.test.tsx
Josh Hunt 3c6e0e8ef8
Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

40 lines
1.4 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
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);
});
});
});