OrgDetailsPage.test.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { shallow } from 'enzyme';
  2. import React from 'react';
  3. import { mockToolkitActionCreator } from 'test/core/redux/mocks';
  4. import { NavModel } from '@grafana/data';
  5. import { Organization } from '../../types';
  6. import { OrgDetailsPage, Props } from './OrgDetailsPage';
  7. import { setOrganizationName } from './state/reducers';
  8. jest.mock('app/core/core', () => {
  9. return {
  10. contextSrv: {
  11. hasPermission: () => true,
  12. },
  13. };
  14. });
  15. const setup = (propOverrides?: object) => {
  16. const props: Props = {
  17. organization: {} as Organization,
  18. navModel: {
  19. main: {
  20. text: 'Configuration',
  21. },
  22. node: {
  23. text: 'Org details',
  24. },
  25. } as NavModel,
  26. loadOrganization: jest.fn(),
  27. setOrganizationName: mockToolkitActionCreator(setOrganizationName),
  28. updateOrganization: jest.fn(),
  29. };
  30. Object.assign(props, propOverrides);
  31. return shallow(<OrgDetailsPage {...props} />);
  32. };
  33. describe('Render', () => {
  34. it('should render component', () => {
  35. const wrapper = setup();
  36. expect(wrapper).toMatchSnapshot();
  37. });
  38. it('should render organization and preferences', () => {
  39. const wrapper = setup({
  40. organization: {
  41. name: 'Cool org',
  42. id: 1,
  43. },
  44. preferences: {
  45. homeDashboardId: 1,
  46. theme: 'Default',
  47. timezone: 'Default',
  48. },
  49. });
  50. expect(wrapper).toMatchSnapshot();
  51. });
  52. });