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