DashboardsTable.test.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { shallow } from 'enzyme';
  2. import React from 'react';
  3. import { PluginDashboard } from '../../types';
  4. import DashboardsTable, { Props } from './DashboardsTable';
  5. const setup = (propOverrides?: object) => {
  6. const props: Props = {
  7. dashboards: [] as PluginDashboard[],
  8. onImport: jest.fn(),
  9. onRemove: jest.fn(),
  10. };
  11. Object.assign(props, propOverrides);
  12. return shallow(<DashboardsTable {...props} />);
  13. };
  14. describe('Render', () => {
  15. it('should render component', () => {
  16. const wrapper = setup();
  17. expect(wrapper).toMatchSnapshot();
  18. });
  19. it('should render table', () => {
  20. const wrapper = setup({
  21. dashboards: [
  22. {
  23. dashboardId: 0,
  24. description: '',
  25. folderId: 0,
  26. imported: false,
  27. importedRevision: 0,
  28. importedUri: '',
  29. importedUrl: '',
  30. path: 'dashboards/carbon_metrics.json',
  31. pluginId: 'graphite',
  32. removed: false,
  33. revision: 1,
  34. slug: '',
  35. title: 'Graphite Carbon Metrics',
  36. },
  37. {
  38. dashboardId: 0,
  39. description: '',
  40. folderId: 0,
  41. imported: true,
  42. importedRevision: 0,
  43. importedUri: '',
  44. importedUrl: '',
  45. path: 'dashboards/carbon_metrics.json',
  46. pluginId: 'graphite',
  47. removed: false,
  48. revision: 1,
  49. slug: '',
  50. title: 'Graphite Carbon Metrics',
  51. },
  52. ],
  53. });
  54. expect(wrapper).toMatchSnapshot();
  55. });
  56. });