mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -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
60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import { shallow } from 'enzyme';
|
|
import React from 'react';
|
|
|
|
import { DataSourceSettings, NavModel, LayoutModes } from '@grafana/data';
|
|
|
|
import { DataSourcesListPage, Props } from './DataSourcesListPage';
|
|
import { getMockDataSources } from './__mocks__/dataSourcesMocks';
|
|
import { setDataSourcesLayoutMode, setDataSourcesSearchQuery } from './state/reducers';
|
|
|
|
jest.mock('app/core/core', () => {
|
|
return {
|
|
contextSrv: {
|
|
hasPermission: () => true,
|
|
},
|
|
};
|
|
});
|
|
|
|
const setup = (propOverrides?: object) => {
|
|
const props: Props = {
|
|
dataSources: [] as DataSourceSettings[],
|
|
layoutMode: LayoutModes.Grid,
|
|
loadDataSources: jest.fn(),
|
|
navModel: {
|
|
main: {
|
|
text: 'Configuration',
|
|
},
|
|
node: {
|
|
text: 'Data Sources',
|
|
},
|
|
} as NavModel,
|
|
dataSourcesCount: 0,
|
|
searchQuery: '',
|
|
setDataSourcesSearchQuery,
|
|
setDataSourcesLayoutMode,
|
|
hasFetched: false,
|
|
};
|
|
|
|
Object.assign(props, propOverrides);
|
|
|
|
return shallow(<DataSourcesListPage {...props} />);
|
|
};
|
|
|
|
describe('Render', () => {
|
|
it('should render component', () => {
|
|
const wrapper = setup();
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render action bar and datasources', () => {
|
|
const wrapper = setup({
|
|
dataSources: getMockDataSources(5),
|
|
dataSourcesCount: 5,
|
|
hasFetched: true,
|
|
});
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
});
|