narrowLayout.spec.jsx 949 B

12345678910111213141516171819202122232425262728293031323334
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import NarrowLayout from 'sentry/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. render(<NarrowLayout />);
  12. expect(screen.queryByText('Sign out')).not.toBeInTheDocument();
  13. });
  14. it('renders with logout', function () {
  15. render(<NarrowLayout showLogout />);
  16. expect(screen.getByText('Sign out')).toBeInTheDocument();
  17. });
  18. it('can logout', function () {
  19. const mock = MockApiClient.addMockResponse({
  20. url: '/auth/',
  21. method: 'DELETE',
  22. status: 204,
  23. });
  24. render(<NarrowLayout showLogout />);
  25. userEvent.click(screen.getByText('Sign out'));
  26. expect(mock).toHaveBeenCalled();
  27. });
  28. });