2018-09-28 11:05:34 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
|
import { DataSourcesListPage, Props } from './DataSourcesListPage';
|
2019-10-31 10:48:05 +01:00
|
|
|
import { DataSourceSettings } from '@grafana/data';
|
2019-06-18 08:17:27 -07:00
|
|
|
import { NavModel } from '@grafana/data';
|
2018-09-28 11:05:34 +02:00
|
|
|
import { LayoutModes } from '../../core/components/LayoutSelector/LayoutSelector';
|
|
|
|
|
import { getMockDataSources } from './__mocks__/dataSourcesMocks';
|
2019-01-30 20:07:14 +01:00
|
|
|
import { setDataSourcesSearchQuery, setDataSourcesLayoutMode } from './state/actions';
|
2018-09-28 11:05:34 +02:00
|
|
|
|
|
|
|
|
const setup = (propOverrides?: object) => {
|
|
|
|
|
const props: Props = {
|
2019-01-17 18:51:07 +01:00
|
|
|
dataSources: [] as DataSourceSettings[],
|
2018-09-28 11:05:34 +02:00
|
|
|
layoutMode: LayoutModes.Grid,
|
|
|
|
|
loadDataSources: jest.fn(),
|
2019-01-16 16:29:07 +01:00
|
|
|
navModel: {
|
|
|
|
|
main: {
|
2019-01-30 20:07:14 +01:00
|
|
|
text: 'Configuration',
|
2019-01-16 16:29:07 +01:00
|
|
|
},
|
|
|
|
|
node: {
|
2019-01-30 20:07:14 +01:00
|
|
|
text: 'Data Sources',
|
|
|
|
|
},
|
2019-01-16 16:29:07 +01:00
|
|
|
} as NavModel,
|
2018-09-28 11:29:18 +02:00
|
|
|
dataSourcesCount: 0,
|
2018-10-03 09:43:10 +02:00
|
|
|
searchQuery: '',
|
2019-01-30 20:07:14 +01:00
|
|
|
setDataSourcesSearchQuery,
|
|
|
|
|
setDataSourcesLayoutMode,
|
2018-10-11 11:49:34 +02:00
|
|
|
hasFetched: false,
|
2018-09-28 11:05:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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),
|
2018-09-28 11:29:18 +02:00
|
|
|
dataSourcesCount: 5,
|
2018-10-11 11:49:34 +02:00
|
|
|
hasFetched: true,
|
2018-09-28 11:05:34 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
|
});
|
|
|
|
|
});
|