projectUserFeedback.spec.jsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import ProjectUserFeedback from 'sentry/views/settings/project/projectUserFeedback';
  3. describe('ProjectUserFeedback', function () {
  4. const org = TestStubs.Organization();
  5. const project = TestStubs.ProjectDetails();
  6. const url = `/projects/${org.slug}/${project.slug}/`;
  7. beforeEach(function () {
  8. MockApiClient.clearMockResponses();
  9. MockApiClient.addMockResponse({
  10. url: `/projects/${org.slug}/${project.slug}/`,
  11. method: 'GET',
  12. body: TestStubs.Project(),
  13. });
  14. MockApiClient.addMockResponse({
  15. url: `/projects/${org.slug}/${project.slug}/keys/`,
  16. method: 'GET',
  17. body: [],
  18. });
  19. });
  20. it('can toggle sentry branding option', function () {
  21. const wrapper = mountWithTheme(
  22. <ProjectUserFeedback
  23. organization={org}
  24. project={project}
  25. params={{orgId: org.slug, projectId: project.slug}}
  26. />,
  27. TestStubs.routerContext()
  28. );
  29. const mock = MockApiClient.addMockResponse({
  30. url,
  31. method: 'PUT',
  32. });
  33. expect(mock).not.toHaveBeenCalled();
  34. // Click Regenerate Token
  35. wrapper.find('Switch').simulate('click');
  36. expect(mock).toHaveBeenCalledWith(
  37. url,
  38. expect.objectContaining({
  39. method: 'PUT',
  40. data: {
  41. options: {'feedback:branding': true},
  42. },
  43. })
  44. );
  45. });
  46. });