about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/ui/components/__tests__/column-test.js
blob: d2791ce08d0ca1239ac7f9d32d413b3e693b88c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import React from 'react';
import { mount } from 'enzyme';
import Column from '../column';
import ColumnHeader from '../column_header';

describe('<Column />', () => {
  describe('<ColumnHeader /> click handler', () => {
    it('runs the scroll animation if the column contains scrollable content', () => {
      const wrapper = mount(
        <Column heading='notifications'>
          <div className='scrollable' />
        </Column>,
      );
      const scrollToMock = jest.fn();
      wrapper.find(Column).find('.scrollable').getDOMNode().scrollTo = scrollToMock;
      wrapper.find(ColumnHeader).find('button').simulate('click');
      expect(scrollToMock).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 });
    });

    it('does not try to scroll if there is no scrollable content', () => {
      const wrapper = mount(<Column heading='notifications' />);
      wrapper.find(ColumnHeader).find('button').simulate('click');
    });
  });
});