ButtonRow.test.tsx 855 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { shallow } from 'enzyme';
  2. import React from 'react';
  3. import ButtonRow, { Props } from './ButtonRow';
  4. jest.mock('app/core/core', () => {
  5. return {
  6. contextSrv: {
  7. hasPermission: () => true,
  8. },
  9. };
  10. });
  11. const setup = (propOverrides?: object) => {
  12. const props: Props = {
  13. canSave: false,
  14. canDelete: false,
  15. onSubmit: jest.fn(),
  16. onDelete: jest.fn(),
  17. onTest: jest.fn(),
  18. exploreUrl: '/explore',
  19. };
  20. Object.assign(props, propOverrides);
  21. return shallow(<ButtonRow {...props} />);
  22. };
  23. describe('Render', () => {
  24. it('should render component', () => {
  25. const wrapper = setup();
  26. expect(wrapper).toMatchSnapshot();
  27. });
  28. it('should render with buttons enabled', () => {
  29. const wrapper = setup({
  30. canSave: true,
  31. canDelete: true,
  32. });
  33. expect(wrapper).toMatchSnapshot();
  34. });
  35. });