createTeamModal.spec.jsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {createTeam} from 'app/actionCreators/teams';
  3. import CreateTeamModal from 'app/components/modals/createTeamModal';
  4. jest.mock('app/actionCreators/teams', () => ({
  5. createTeam: jest.fn((...args) => new Promise(resolve => resolve(...args))),
  6. }));
  7. describe('CreateTeamModal', function () {
  8. const org = TestStubs.Organization();
  9. const closeModal = jest.fn();
  10. const onClose = jest.fn();
  11. const onSuccess = jest.fn();
  12. beforeEach(function () {
  13. onClose.mockReset();
  14. onSuccess.mockReset();
  15. });
  16. afterEach(function () {});
  17. it('calls createTeam action creator on submit', async function () {
  18. const wrapper = mountWithTheme(
  19. <CreateTeamModal
  20. Body={p => p.children}
  21. Header={p => p.children}
  22. organization={org}
  23. closeModal={closeModal}
  24. onClose={onClose}
  25. onSuccess={onSuccess}
  26. />,
  27. TestStubs.routerContext()
  28. );
  29. wrapper
  30. .find('CreateTeamForm Input[name="slug"]')
  31. .simulate('change', {e: {target: {value: 'new-team'}}});
  32. wrapper.find('CreateTeamForm Form').simulate('submit');
  33. expect(createTeam).toHaveBeenCalledTimes(1);
  34. await tick();
  35. expect(onClose).toHaveBeenCalled();
  36. expect(closeModal).toHaveBeenCalled();
  37. expect(onSuccess).toHaveBeenCalledTimes(1);
  38. });
  39. });