2020-06-29 11:58:07 +00:00
|
|
|
import { render, fireEvent, screen } from '@testing-library/react';
|
2017-06-01 15:27:15 +00:00
|
|
|
import React from 'react';
|
2017-10-16 07:33:08 +00:00
|
|
|
import Column from '../column';
|
2017-04-12 15:16:59 +00:00
|
|
|
|
|
|
|
describe('<Column />', () => {
|
|
|
|
describe('<ColumnHeader /> click handler', () => {
|
|
|
|
it('runs the scroll animation if the column contains scrollable content', () => {
|
2020-06-29 11:58:07 +00:00
|
|
|
const scrollToMock = jest.fn();
|
|
|
|
const { container } = render(
|
2017-06-06 01:56:36 +00:00
|
|
|
<Column heading='notifications'>
|
|
|
|
<div className='scrollable' />
|
2020-03-08 15:02:36 +00:00
|
|
|
</Column>,
|
2017-04-12 15:16:59 +00:00
|
|
|
);
|
2020-06-29 11:58:07 +00:00
|
|
|
container.querySelector('.scrollable').scrollTo = scrollToMock;
|
|
|
|
fireEvent.click(screen.getByText('notifications'));
|
2020-05-08 19:21:57 +00:00
|
|
|
expect(scrollToMock).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 });
|
2017-04-12 15:16:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not try to scroll if there is no scrollable content', () => {
|
2020-06-29 11:58:07 +00:00
|
|
|
render(<Column heading='notifications' />);
|
|
|
|
fireEvent.click(screen.getByText('notifications'));
|
2017-04-12 15:16:59 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|