settingsLayout.spec.jsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {BreadcrumbContextProvider} from 'sentry-test/providers/breadcrumbContextProvider';
  3. import {Client} from 'sentry/api';
  4. import SettingsLayout from 'sentry/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. <BreadcrumbContextProvider>
  34. <SettingsLayout router={TestStubs.router()} route={{}} routes={[]} />
  35. </BreadcrumbContextProvider>
  36. );
  37. expect(wrapper).toSnapshot();
  38. });
  39. it('can render navigation', function () {
  40. const Navigation = () => <div>Navigation</div>;
  41. const wrapper = mountWithTheme(
  42. <BreadcrumbContextProvider>
  43. <SettingsLayout
  44. router={TestStubs.router()}
  45. route={{}}
  46. routes={[]}
  47. renderNavigation={() => <Navigation />}
  48. />
  49. </BreadcrumbContextProvider>
  50. );
  51. expect(wrapper.find('Navigation')).toHaveLength(1);
  52. });
  53. it('can toggle mobile navigation', function () {
  54. const Navigation = () => <div>Navigation</div>;
  55. const wrapper = mountWithTheme(
  56. <BreadcrumbContextProvider>
  57. <SettingsLayout
  58. router={TestStubs.router()}
  59. route={{}}
  60. routes={[]}
  61. renderNavigation={() => <Navigation />}
  62. />
  63. </BreadcrumbContextProvider>
  64. );
  65. expect(wrapper.find('NavMask').prop('isVisible')).toBeFalsy();
  66. expect(wrapper.find('SidebarWrapper').prop('isVisible')).toBeFalsy();
  67. wrapper.find('NavMenuToggle').simulate('click');
  68. expect(wrapper.find('NavMask').prop('isVisible')).toBeTruthy();
  69. expect(wrapper.find('SidebarWrapper').prop('isVisible')).toBeTruthy();
  70. });
  71. });