narrowLayout.spec.jsx 969 B

12345678910111213141516171819202122232425262728293031323334
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import NarrowLayout from 'app/components/narrowLayout';
  3. describe('NarrowLayout', function () {
  4. beforeAll(function () {
  5. jest.spyOn(window.location, 'assign').mockImplementation(() => {});
  6. });
  7. afterAll(function () {
  8. window.location.assign.mockRestore();
  9. });
  10. it('renders without logout', function () {
  11. const wrapper = mountWithTheme(<NarrowLayout />);
  12. expect(wrapper.find('a.logout')).toHaveLength(0);
  13. });
  14. it('renders with logout', function () {
  15. const wrapper = mountWithTheme(<NarrowLayout showLogout />);
  16. expect(wrapper.find('a.logout')).toHaveLength(1);
  17. });
  18. it('can logout', function () {
  19. const mock = MockApiClient.addMockResponse({
  20. url: '/auth/',
  21. method: 'DELETE',
  22. status: 204,
  23. });
  24. const wrapper = mountWithTheme(<NarrowLayout showLogout />);
  25. wrapper.find('a.logout').simulate('click');
  26. expect(mock).toHaveBeenCalled();
  27. });
  28. });