grafana/public/app/features/plugins/PluginListPage.test.tsx

45 lines
1.0 KiB
TypeScript
Raw Normal View History

2018-09-25 09:50:13 -05:00
import React from 'react';
import { shallow } from 'enzyme';
import { PluginListPage, Props } from './PluginListPage';
import { NavModel, PluginMeta } from '@grafana/data';
import { mockToolkitActionCreator } from 'test/core/redux/mocks';
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: {
text: 'Configuration',
2019-01-16 09:29:07 -06:00
},
node: {
text: 'Plugins',
},
2019-01-16 09:29:07 -06:00
} as NavModel,
plugins: [] as PluginMeta[],
2018-10-03 02:43:10 -05:00
searchQuery: '',
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();
});
});