TeamPages.test.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import { TeamPages, Props } from './TeamPages';
  4. import { NavModel, Team, OrganizationPreferences } from '../../types';
  5. import { getMockTeam } from './__mocks__/teamMocks';
  6. jest.mock('app/core/config', () => ({
  7. buildInfo: { isEnterprise: true },
  8. }));
  9. const setup = (propOverrides?: object) => {
  10. const props: Props = {
  11. navModel: {} as NavModel,
  12. teamId: 1,
  13. loadTeam: jest.fn(),
  14. pageName: 'members',
  15. team: {} as Team,
  16. loadStarredDashboards: jest.fn(),
  17. loadTeamPreferences: jest.fn(),
  18. preferences: {} as OrganizationPreferences,
  19. };
  20. Object.assign(props, propOverrides);
  21. const wrapper = shallow(<TeamPages {...props} />);
  22. const instance = wrapper.instance();
  23. return {
  24. wrapper,
  25. instance,
  26. };
  27. };
  28. describe('Render', () => {
  29. it('should render component', () => {
  30. const { wrapper } = setup();
  31. expect(wrapper).toMatchSnapshot();
  32. });
  33. it('should render member page if team not empty', () => {
  34. const { wrapper } = setup({
  35. team: getMockTeam(),
  36. });
  37. expect(wrapper).toMatchSnapshot();
  38. });
  39. it('should render settings and preferences page', () => {
  40. const { wrapper } = setup({
  41. team: getMockTeam(),
  42. pageName: 'settings',
  43. preferences: {
  44. homeDashboardId: 1,
  45. theme: 'Default',
  46. timezone: 'Default',
  47. },
  48. });
  49. expect(wrapper).toMatchSnapshot();
  50. });
  51. it('should render group sync page', () => {
  52. const { wrapper } = setup({
  53. team: getMockTeam(),
  54. pageName: 'groupsync',
  55. });
  56. expect(wrapper).toMatchSnapshot();
  57. });
  58. });