TeamPages.test.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import { TeamPages, Props } from './TeamPages';
  4. import { NavModel, Team } 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. };
  17. Object.assign(props, propOverrides);
  18. const wrapper = shallow(<TeamPages {...props} />);
  19. const instance = wrapper.instance();
  20. return {
  21. wrapper,
  22. instance,
  23. };
  24. };
  25. describe('Render', () => {
  26. it('should render component', () => {
  27. const { wrapper } = setup();
  28. expect(wrapper).toMatchSnapshot();
  29. });
  30. it('should render member page if team not empty', () => {
  31. const { wrapper } = setup({
  32. team: getMockTeam(),
  33. });
  34. expect(wrapper).toMatchSnapshot();
  35. });
  36. it('should render settings page', () => {
  37. const { wrapper } = setup({
  38. team: getMockTeam(),
  39. pageName: 'settings',
  40. });
  41. expect(wrapper).toMatchSnapshot();
  42. });
  43. it('should render group sync page', () => {
  44. const { wrapper } = setup({
  45. team: getMockTeam(),
  46. pageName: 'groupsync',
  47. });
  48. expect(wrapper).toMatchSnapshot();
  49. });
  50. });