about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/ui/components/__tests__/column-test.js
blob: 1e5e1d8dc5c43a3b2abd9a26f64cc0c7112a23aa (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
26
27
28
29
30
31
32
33
34
import React from 'react';
import { mount } from 'enzyme';
import Column from '../column';
import ColumnHeader from '../column_header';

describe('<Column />', () => {
  describe('<ColumnHeader /> click handler', () => {
    const originalRaf = global.requestAnimationFrame;

    beforeEach(() => {
      global.requestAnimationFrame = jest.fn();
    });

    afterAll(() => {
      global.requestAnimationFrame = originalRaf;
    });

    it('runs the scroll animation if the column contains scrollable content', () => {
      const wrapper = mount(
        <Column heading='notifications'>
          <div className='scrollable' />
        </Column>
      );
      wrapper.find(ColumnHeader).simulate('click');
      expect(global.requestAnimationFrame.mock.calls.length).toEqual(1);
    });

    it('does not try to scroll if there is no scrollable content', () => {
      const wrapper = mount(<Column heading='notifications' />);
      wrapper.find(ColumnHeader).simulate('click');
      expect(global.requestAnimationFrame.mock.calls.length).toEqual(0);
    });
  });
});