grafana/public/app/features/dashboard/components/PanelEditor/PanelNotSupported.test.tsx
Hugo Häggmark 058ac6becf
Chore: Bumps Immer, Redux Toolkit, Redux and React Redux (#38872)
* Chore: Bumps immer and redux/toolkit

* WIP: transpile errors

* Chore: bumps redux and react redux

* Chore: removes unused dispatch

* make alerting compile with updated redux toolkit

* Test: Fixes broken test

* Chore: fixes strict errors

Co-authored-by: Domas <domasx2@gmail.com>
2021-09-07 10:44:47 +02:00

38 lines
1.4 KiB
TypeScript

import { locationService } from '@grafana/runtime';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
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', () => {
setupTestContext({});
userEvent.click(screen.getByRole('button', { name: /go back to queries/i }));
expect(locationService.getSearchObject().tab).toBe(PanelEditorTabId.Query);
});
});
});