2017-06-01 17:27:15 +02:00
|
|
|
import React from 'react';
|
2017-10-16 09:33:08 +02:00
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import Column from '../column';
|
|
|
|
import ColumnHeader from '../column_header';
|
2017-04-12 17:16:59 +02:00
|
|
|
|
|
|
|
describe('<Column />', () => {
|
|
|
|
describe('<ColumnHeader /> click handler', () => {
|
|
|
|
it('runs the scroll animation if the column contains scrollable content', () => {
|
|
|
|
const wrapper = mount(
|
2017-06-06 03:56:36 +02:00
|
|
|
<Column heading='notifications'>
|
|
|
|
<div className='scrollable' />
|
2020-03-08 16:02:36 +01:00
|
|
|
</Column>,
|
2017-04-12 17:16:59 +02:00
|
|
|
);
|
2020-05-08 21:21:57 +02:00
|
|
|
const scrollToMock = jest.fn();
|
|
|
|
wrapper.find(Column).find('.scrollable').getDOMNode().scrollTo = scrollToMock;
|
2018-01-24 04:03:51 +01:00
|
|
|
wrapper.find(ColumnHeader).find('button').simulate('click');
|
2020-05-08 21:21:57 +02:00
|
|
|
expect(scrollToMock).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 });
|
2017-04-12 17:16:59 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not try to scroll if there is no scrollable content', () => {
|
2017-06-06 03:56:36 +02:00
|
|
|
const wrapper = mount(<Column heading='notifications' />);
|
2018-01-24 04:03:51 +01:00
|
|
|
wrapper.find(ColumnHeader).find('button').simulate('click');
|
2017-04-12 17:16:59 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|