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

47 lines
1.1 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';
2018-09-27 07:19:36 -05:00
import { LayoutModes } from '../../core/components/LayoutSelector/LayoutSelector';
import { NavModel } from '@grafana/data';
import { PluginMeta } from '@grafana/ui';
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: jest.fn(),
setPluginsLayoutMode: jest.fn(),
2018-09-27 07:19:36 -05:00
layoutMode: LayoutModes.Grid,
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();
});
});