mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* 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
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import { ErrorContainer, ErrorContainerProps } from './ErrorContainer';
|
|
|
|
describe('ErrorContainer', () => {
|
|
it('should render component and show message', () => {
|
|
const props: ErrorContainerProps = {
|
|
queryError: {
|
|
data: {
|
|
message: 'Error data message',
|
|
error: 'Error data content',
|
|
},
|
|
message: 'Error message',
|
|
status: 500,
|
|
statusText: 'Error status text',
|
|
refId: 'A',
|
|
},
|
|
};
|
|
render(<ErrorContainer {...props} />);
|
|
const alertEl = screen.getByRole('alert');
|
|
expect(alertEl).toBeInTheDocument();
|
|
expect(alertEl).toHaveTextContent(/query error/i);
|
|
expect(alertEl).toHaveTextContent('Error message');
|
|
});
|
|
|
|
it('should render component and show message if message is in data only', () => {
|
|
const props: ErrorContainerProps = {
|
|
queryError: {
|
|
data: {
|
|
message: 'Error data message',
|
|
error: 'Error data content',
|
|
},
|
|
status: 500,
|
|
statusText: 'Error status text',
|
|
refId: 'A',
|
|
},
|
|
};
|
|
render(<ErrorContainer {...props} />);
|
|
|
|
const alertEl = screen.getByRole('alert');
|
|
expect(alertEl).toBeInTheDocument();
|
|
expect(alertEl).toHaveTextContent(/query error/i);
|
|
expect(alertEl).toHaveTextContent('Error data message');
|
|
});
|
|
|
|
it('should have hidden unknown error if prop is not passed in', () => {
|
|
const props: ErrorContainerProps = {};
|
|
render(<ErrorContainer {...props} />);
|
|
|
|
const alertEl = screen.getByRole('alert', { hidden: true });
|
|
expect(alertEl).toBeInTheDocument();
|
|
expect(alertEl).toHaveTextContent('Unknown error');
|
|
});
|
|
});
|