grafana/public/app/features/datasources/DataSourcesListPage.test.tsx

51 lines
1.3 KiB
TypeScript
Raw Normal View History

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