teamCreate.spec.jsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React from 'react';
  2. import {shallow} from 'enzyme';
  3. import {TeamCreate} from 'app/views/teamCreate';
  4. describe('TeamCreate', function() {
  5. describe('render()', function() {
  6. it('renders correctly', function() {
  7. const wrapper = shallow(
  8. <TeamCreate
  9. params={{
  10. orgId: 'org',
  11. }}
  12. />,
  13. {
  14. context: {router: TestStubs.router(), organization: TestStubs.Organization()},
  15. }
  16. );
  17. expect(wrapper).toMatchSnapshot();
  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. });