2018-09-25 09:50:13 -05:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import { PluginListPage, Props } from './PluginListPage';
|
2020-01-13 01:03:22 -06:00
|
|
|
import { NavModel, PluginMeta } from '@grafana/data';
|
|
|
|
import { mockToolkitActionCreator } from 'test/core/redux/mocks';
|
2020-04-23 04:52:11 -05:00
|
|
|
import { setPluginsSearchQuery } from './state/reducers';
|
2018-09-25 09:50:13 -05:00
|
|
|
|
|
|
|
const setup = (propOverrides?: object) => {
|
|
|
|
const props: Props = {
|
2019-01-16 09:29:07 -06:00
|
|
|
navModel: {
|
|
|
|
main: {
|
2019-02-13 04:14:53 -06:00
|
|
|
text: 'Configuration',
|
2019-01-16 09:29:07 -06:00
|
|
|
},
|
|
|
|
node: {
|
2019-02-13 04:14:53 -06:00
|
|
|
text: 'Plugins',
|
|
|
|
},
|
2019-01-16 09:29:07 -06:00
|
|
|
} as NavModel,
|
2019-04-29 11:14:39 -05:00
|
|
|
plugins: [] as PluginMeta[],
|
2018-10-03 02:43:10 -05:00
|
|
|
searchQuery: '',
|
2020-01-13 01:03:22 -06:00
|
|
|
setPluginsSearchQuery: mockToolkitActionCreator(setPluginsSearchQuery),
|
2018-09-25 09:50:13 -05:00
|
|
|
loadPlugins: jest.fn(),
|
2018-10-11 04:49:34 -05:00
|
|
|
hasFetched: false,
|
2018-09-25 09:50:13 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
Object.assign(props, propOverrides);
|
|
|
|
|
2018-10-11 04:49:34 -05:00
|
|
|
return shallow(<PluginListPage {...props} />);
|
2018-09-25 09:50:13 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
describe('Render', () => {
|
|
|
|
it('should render component', () => {
|
2018-10-11 04:49:34 -05:00
|
|
|
const wrapper = setup();
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render list', () => {
|
|
|
|
const wrapper = setup({
|
|
|
|
hasFetched: true,
|
|
|
|
});
|
2018-09-25 09:50:13 -05:00
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|