mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Convert DataSourceDashboards test to RTL (#51294)
* Convert DataSourceDashboards test to RTL * Convert DataSourceDashboards test to RTL * Convert DataSourceDashboards test to RTL * Update public/app/features/datasources/DataSourceDashboards.test.tsx Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> * Convert DataSourceDashboards test to RTL Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
This commit is contained in:
parent
2705edf5f5
commit
ec1480b964
@ -95,9 +95,6 @@ exports[`no enzyme tests`] = {
|
||||
"public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx:2723773538": [
|
||||
[0, 35, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/datasources/DataSourceDashboards.test.tsx:1369048021": [
|
||||
[0, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.test.tsx:4164297658": [
|
||||
[0, 17, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
|
@ -1,16 +1,17 @@
|
||||
import { shallow } from 'enzyme';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { DataSourceSettings, NavModel } from '@grafana/data';
|
||||
import { DataSourceSettings } from '@grafana/data';
|
||||
import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps';
|
||||
import { RouteDescriptor } from 'app/core/navigation/types';
|
||||
import { PluginDashboard } from 'app/types';
|
||||
|
||||
import { DataSourceDashboards, Props } from './DataSourceDashboards';
|
||||
|
||||
const setup = (propOverrides?: object) => {
|
||||
const setup = (propOverrides?: Partial<Props>) => {
|
||||
const props: Props = {
|
||||
...getRouteComponentProps(),
|
||||
navModel: {} as NavModel,
|
||||
navModel: { main: { text: 'nav-text' }, node: { text: 'node-text' } },
|
||||
dashboards: [] as PluginDashboard[],
|
||||
dataSource: {} as DataSourceSettings,
|
||||
dataSourceId: 'x',
|
||||
@ -18,18 +19,26 @@ const setup = (propOverrides?: object) => {
|
||||
loadDataSource: jest.fn(),
|
||||
loadPluginDashboards: jest.fn(),
|
||||
removeDashboard: jest.fn(),
|
||||
route: {} as RouteDescriptor,
|
||||
isLoading: false,
|
||||
...propOverrides,
|
||||
};
|
||||
|
||||
Object.assign(props, propOverrides);
|
||||
|
||||
return shallow(<DataSourceDashboards {...props} />);
|
||||
return render(<DataSourceDashboards {...props} />);
|
||||
};
|
||||
|
||||
describe('Render', () => {
|
||||
it('should render without exploding', () => {
|
||||
expect(() => setup()).not.toThrow();
|
||||
});
|
||||
it('should render component', () => {
|
||||
const wrapper = setup();
|
||||
setup();
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(screen.getByRole('heading', { name: 'nav-text' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('table')).toBeInTheDocument();
|
||||
expect(screen.getByRole('list')).toBeInTheDocument();
|
||||
expect(screen.getByRole('link', { name: 'Documentation' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('link', { name: 'Support' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('link', { name: 'Community' })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
@ -1,17 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Render should render component 1`] = `
|
||||
<Page
|
||||
navModel={Object {}}
|
||||
>
|
||||
<PageContents
|
||||
isLoading={false}
|
||||
>
|
||||
<DashboardsTable
|
||||
dashboards={Array []}
|
||||
onImport={[Function]}
|
||||
onRemove={[Function]}
|
||||
/>
|
||||
</PageContents>
|
||||
</Page>
|
||||
`;
|
Loading…
Reference in New Issue
Block a user