settingsLayout.spec.jsx 1.9 KB

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