about summary refs log tree commit diff
path: root/spec/javascript/components/features/ui/components/column.test.jsx
blob: 6359905e650cf486f790bd8a2491941d446aa292 (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
import { expect } from 'chai';
import { mount } from 'enzyme';
import sinon from 'sinon';

import Column from '../../../../../../app/javascript/mastodon/features/ui/components/column';
import ColumnHeader from '../../../../../../app/javascript/mastodon/features/ui/components/column_header';

describe('<Column />', () => {
  describe('<ColumnHeader /> click handler', () => {
    beforeEach(() => {
      global.requestAnimationFrame = sinon.spy();
    });

    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.called).to.equal(true);
    });

    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.called).to.equal(false);
    });
  });
});