logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

column-test.js (1107B)


  1. import React from 'react';
  2. import { mount } from 'enzyme';
  3. import Column from '../column';
  4. import ColumnHeader from '../column_header';
  5. describe('<Column />', () => {
  6. describe('<ColumnHeader /> click handler', () => {
  7. const originalRaf = global.requestAnimationFrame;
  8. beforeEach(() => {
  9. global.requestAnimationFrame = jest.fn();
  10. });
  11. afterAll(() => {
  12. global.requestAnimationFrame = originalRaf;
  13. });
  14. it('runs the scroll animation if the column contains scrollable content', () => {
  15. const wrapper = mount(
  16. <Column heading='notifications'>
  17. <div className='scrollable' />
  18. </Column>
  19. );
  20. wrapper.find(ColumnHeader).find('button').simulate('click');
  21. expect(global.requestAnimationFrame.mock.calls.length).toEqual(1);
  22. });
  23. it('does not try to scroll if there is no scrollable content', () => {
  24. const wrapper = mount(<Column heading='notifications' />);
  25. wrapper.find(ColumnHeader).find('button').simulate('click');
  26. expect(global.requestAnimationFrame.mock.calls.length).toEqual(0);
  27. });
  28. });
  29. });