grafana/public/app/features/panel/components/PanelDataErrorView.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

53 lines
1.4 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import { defaultsDeep } from 'lodash';
import React from 'react';
import { Provider } from 'react-redux';
import { getDefaultTimeRange, LoadingState } from '@grafana/data';
import { PanelDataErrorViewProps } from '@grafana/runtime';
import { configureStore } from 'app/store/configureStore';
import { PanelDataErrorView } from './PanelDataErrorView';
describe('PanelDataErrorView', () => {
it('show No data when there is no data', () => {
renderWithProps();
expect(screen.getByText('No data')).toBeInTheDocument();
});
it('show no value field config when there is no data', () => {
renderWithProps({
fieldConfig: {
overrides: [],
defaults: {
noValue: 'Query returned nothing',
},
},
});
expect(screen.getByText('Query returned nothing')).toBeInTheDocument();
});
});
function renderWithProps(overrides?: Partial<PanelDataErrorViewProps>) {
const defaults: PanelDataErrorViewProps = {
panelId: 1,
data: {
state: LoadingState.Done,
series: [],
timeRange: getDefaultTimeRange(),
},
};
const props = defaultsDeep(overrides ?? {}, defaults);
const store = configureStore();
const stuff = render(
<Provider store={store}>
<PanelDataErrorView {...props} />
</Provider>
);
return { ...stuff };
}