Files
grafana/public/app/features/datasources/components/DataSourceDashboards.test.tsx
Ashley Harrison 47f8717149 React: Use new JSX transform (#88802)
* update eslint, tsconfig + esbuild to handle new jsx transform

* remove thing that breaks the new jsx transform

* remove react imports

* adjust grafana-icons build

* is this the correct syntax?

* try this

* well this was much easier than expected...

* change grafana-plugin-configs webpack config

* fixes

* fix lockfile

* fix 2 more violations

* use path.resolve instead of require.resolve

* remove react import

* fix react imports

* more fixes

* remove React import

* remove import React from docs

* remove another react import
2024-06-25 12:43:47 +01:00

52 lines
1.4 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import { Provider } from 'react-redux';
import { configureStore } from 'app/store/configureStore';
import { getMockDashboard } from '../__mocks__';
import { DataSourceDashboardsView, ViewProps } from './DataSourceDashboards';
const setup = ({
dashboards = [],
isLoading = false,
onImportDashboard = jest.fn(),
onRemoveDashboard = jest.fn(),
}: Partial<ViewProps>) => {
const store = configureStore();
return render(
<Provider store={store}>
<DataSourceDashboardsView
isLoading={isLoading}
dashboards={dashboards}
onImportDashboard={onImportDashboard}
onRemoveDashboard={onRemoveDashboard}
/>
</Provider>
);
};
describe('<DataSourceDashboards>', () => {
it('should show a loading indicator while loading', () => {
setup({ isLoading: true });
expect(screen.queryByText(/loading/i)).toBeVisible();
});
it('should not show a loading indicator when loaded', () => {
setup({ isLoading: false });
expect(screen.queryByText(/loading/i)).not.toBeInTheDocument();
});
it('should show a list of dashboards once loaded', () => {
setup({
dashboards: [getMockDashboard({ title: 'My Dashboard 1' }), getMockDashboard({ title: 'My Dashboard 2' })],
});
expect(screen.queryByText('My Dashboard 1')).toBeVisible();
expect(screen.queryByText('My Dashboard 2')).toBeVisible();
});
});