PluginListPage.test.tsx 1.0 KB

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