app.spec.jsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React from 'react';
  2. import {mount} from 'sentry-test/enzyme';
  3. import App from 'app/views/app';
  4. import ConfigStore from 'app/stores/configStore';
  5. jest.mock('jquery');
  6. describe('App', function() {
  7. beforeEach(function() {
  8. MockApiClient.addMockResponse({
  9. url: '/organizations/',
  10. body: [TestStubs.Organization({slug: 'billy-org', name: 'billy org'})],
  11. });
  12. MockApiClient.addMockResponse({
  13. url: '/internal/health/',
  14. body: {
  15. problems: [],
  16. },
  17. });
  18. MockApiClient.addMockResponse({
  19. url: '/assistant/',
  20. body: [],
  21. });
  22. });
  23. it('renders newsletter consent with flag', async function() {
  24. const user = ConfigStore.get('user');
  25. user.flags.newsletter_consent_prompt = true;
  26. // XXX(dcramer): shouldnt need to re-set
  27. ConfigStore.set('user', user);
  28. const wrapper = mount(
  29. <App params={{orgId: 'org-slug'}}>{<div>placeholder content</div>}</App>
  30. );
  31. expect(wrapper.find('NewsletterConsent')).toHaveLength(1);
  32. });
  33. it('does not render newsletter consent without flag', async function() {
  34. const user = ConfigStore.get('user');
  35. user.flags.newsletter_consent_prompt = false;
  36. // XXX(dcramer): shouldnt need to re-set
  37. ConfigStore.set('user', user);
  38. const wrapper = mount(
  39. <App params={{orgId: 'org-slug'}}>{<div>placeholder content</div>}</App>
  40. );
  41. expect(wrapper.find('NewsletterConsent')).toHaveLength(0);
  42. });
  43. });