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
53 lines
1.4 KiB
TypeScript
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 };
|
|
}
|