narrowLayout.spec.jsx 954 B

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