teamCreate.spec.jsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {mountWithTheme, shallow} from 'sentry-test/enzyme';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {TeamCreate} from 'sentry/views/teamCreate';
  4. describe('TeamCreate', function () {
  5. describe('render()', function () {
  6. it('renders correctly', function () {
  7. const {organization, routerContext} = initializeOrg();
  8. const wrapper = mountWithTheme(
  9. <TeamCreate
  10. organization={organization}
  11. params={{
  12. orgId: 'org',
  13. }}
  14. />,
  15. routerContext
  16. );
  17. expect(wrapper).toSnapshot();
  18. });
  19. });
  20. describe('handleSubmitSuccess()', function () {
  21. let wrapper;
  22. const redirectMock = jest.fn();
  23. beforeEach(function () {
  24. redirectMock.mockReset();
  25. wrapper = shallow(
  26. <TeamCreate
  27. router={{
  28. push: redirectMock,
  29. }}
  30. params={{
  31. orgId: 'org',
  32. }}
  33. />,
  34. {
  35. context: {
  36. router: TestStubs.router(),
  37. organization: {
  38. id: '1337',
  39. },
  40. },
  41. }
  42. );
  43. });
  44. it('redirects to team settings', function () {
  45. wrapper.setContext({
  46. organization: {
  47. id: '1337',
  48. },
  49. });
  50. wrapper.instance().handleSubmitSuccess({
  51. slug: 'new-team',
  52. });
  53. expect(redirectMock).toHaveBeenCalledWith('/settings/org/teams/new-team/');
  54. });
  55. });
  56. });