customResolutionModal.spec.jsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {selectByValue} from 'sentry-test/select-new';
  3. import CustomResolutionModal from 'app/components/customResolutionModal';
  4. describe('CustomResolutionModal', function () {
  5. let releasesMock;
  6. beforeEach(function () {
  7. releasesMock = MockApiClient.addMockResponse({
  8. url: '/projects/org-slug/project-slug/releases/',
  9. body: [TestStubs.Release()],
  10. });
  11. });
  12. it('can select a version', async function () {
  13. const onSelected = jest.fn();
  14. const wrapper = mountWithTheme(
  15. <CustomResolutionModal
  16. Header={p => p.children}
  17. Body={p => p.children}
  18. Footer={p => p.children}
  19. orgSlug="org-slug"
  20. projectSlug="project-slug"
  21. onSelected={onSelected}
  22. closeModal={jest.fn()}
  23. />,
  24. TestStubs.routerContext()
  25. );
  26. expect(releasesMock).toHaveBeenCalled();
  27. await tick();
  28. wrapper.update();
  29. expect(wrapper.find('Select').prop('options')).toEqual([
  30. expect.objectContaining({
  31. value: 'sentry-android-shop@1.2.0',
  32. label: expect.anything(),
  33. }),
  34. ]);
  35. selectByValue(wrapper, 'sentry-android-shop@1.2.0', {
  36. selector: 'SelectAsyncControl[name="version"]',
  37. });
  38. wrapper.find('form').simulate('submit');
  39. expect(onSelected).toHaveBeenCalledWith({
  40. inRelease: 'sentry-android-shop@1.2.0',
  41. });
  42. });
  43. });