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

46 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';
2018-09-27 07:45:36 -05:00
import { NavModel, Plugin } from '../../types';
2018-09-27 07:19:36 -05:00
import { LayoutModes } from '../../core/components/LayoutSelector/LayoutSelector';
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'
},
node: {
text: 'Plugins'
}
} as NavModel,
2018-09-27 07:45:36 -05:00
plugins: [] as Plugin[],
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();
});
});