settingsLayout.spec.jsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {Client} from 'app/api';
  3. import SettingsLayout from 'app/views/settings/components/settingsLayout';
  4. describe('SettingsLayout', function () {
  5. beforeEach(function () {
  6. Client.clearMockResponses();
  7. Client.addMockResponse({
  8. url: '/internal/health/',
  9. body: {
  10. problems: [],
  11. },
  12. });
  13. Client.addMockResponse({
  14. url: '/organizations/',
  15. body: [TestStubs.Organization()],
  16. });
  17. Client.addMockResponse({
  18. url: '/organizations/org-slug/',
  19. method: 'DELETE',
  20. statusCode: 401,
  21. body: {
  22. sudoRequired: true,
  23. },
  24. });
  25. Client.addMockResponse({
  26. url: '/authenticators/',
  27. body: [],
  28. });
  29. });
  30. it('renders', function () {
  31. const wrapper = mountWithTheme(
  32. <SettingsLayout router={TestStubs.router()} route={{}} routes={[]} />
  33. );
  34. expect(wrapper).toSnapshot();
  35. });
  36. it('can render navigation', function () {
  37. const Navigation = () => <div>Navigation</div>;
  38. const wrapper = mountWithTheme(
  39. <SettingsLayout
  40. router={TestStubs.router()}
  41. route={{}}
  42. routes={[]}
  43. renderNavigation={() => <Navigation />}
  44. />
  45. );
  46. expect(wrapper.find('Navigation')).toHaveLength(1);
  47. });
  48. it('can toggle mobile navigation', function () {
  49. const Navigation = () => <div>Navigation</div>;
  50. const wrapper = mountWithTheme(
  51. <SettingsLayout
  52. router={TestStubs.router()}
  53. route={{}}
  54. routes={[]}
  55. renderNavigation={() => <Navigation />}
  56. />
  57. );
  58. expect(wrapper.find('NavMask').prop('isVisible')).toBeFalsy();
  59. expect(wrapper.find('SidebarWrapper').prop('isVisible')).toBeFalsy();
  60. wrapper.find('NavMenuToggle').simulate('click');
  61. expect(wrapper.find('NavMask').prop('isVisible')).toBeTruthy();
  62. expect(wrapper.find('SidebarWrapper').prop('isVisible')).toBeTruthy();
  63. });
  64. });