You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
901 B

  1. import { render, fireEvent, screen } from '@testing-library/react';
  2. import React from 'react';
  3. import Column from '../column';
  4. describe('<Column />', () => {
  5. describe('<ColumnHeader /> click handler', () => {
  6. it('runs the scroll animation if the column contains scrollable content', () => {
  7. const scrollToMock = jest.fn();
  8. const { container } = render(
  9. <Column heading='notifications'>
  10. <div className='scrollable' />
  11. </Column>,
  12. );
  13. container.querySelector('.scrollable').scrollTo = scrollToMock;
  14. fireEvent.click(screen.getByText('notifications'));
  15. expect(scrollToMock).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 });
  16. });
  17. it('does not try to scroll if there is no scrollable content', () => {
  18. render(<Column heading='notifications' />);
  19. fireEvent.click(screen.getByText('notifications'));
  20. });
  21. });
  22. });