PluginListPage.test.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import { PluginListPage, Props } from './PluginListPage';
  4. import { LayoutModes } from '../../core/components/LayoutSelector/LayoutSelector';
  5. import { NavModel } from '@grafana/data';
  6. import { PluginMeta } from '@grafana/ui';
  7. const setup = (propOverrides?: object) => {
  8. const props: Props = {
  9. navModel: {
  10. main: {
  11. text: 'Configuration',
  12. },
  13. node: {
  14. text: 'Plugins',
  15. },
  16. } as NavModel,
  17. plugins: [] as PluginMeta[],
  18. searchQuery: '',
  19. setPluginsSearchQuery: jest.fn(),
  20. setPluginsLayoutMode: jest.fn(),
  21. layoutMode: LayoutModes.Grid,
  22. loadPlugins: jest.fn(),
  23. hasFetched: false,
  24. };
  25. Object.assign(props, propOverrides);
  26. return shallow(<PluginListPage {...props} />);
  27. };
  28. describe('Render', () => {
  29. it('should render component', () => {
  30. const wrapper = setup();
  31. expect(wrapper).toMatchSnapshot();
  32. });
  33. it('should render list', () => {
  34. const wrapper = setup({
  35. hasFetched: true,
  36. });
  37. expect(wrapper).toMatchSnapshot();
  38. });
  39. });