forked from treehouse/mastodon
Fix failing jest test (#13681)
parent
f1e0fa80f6
commit
0d62e09707
|
@ -5,30 +5,21 @@ import ColumnHeader from '../column_header';
|
||||||
|
|
||||||
describe('<Column />', () => {
|
describe('<Column />', () => {
|
||||||
describe('<ColumnHeader /> click handler', () => {
|
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', () => {
|
it('runs the scroll animation if the column contains scrollable content', () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<Column heading='notifications'>
|
<Column heading='notifications'>
|
||||||
<div className='scrollable' />
|
<div className='scrollable' />
|
||||||
</Column>,
|
</Column>,
|
||||||
);
|
);
|
||||||
|
const scrollToMock = jest.fn();
|
||||||
|
wrapper.find(Column).find('.scrollable').getDOMNode().scrollTo = scrollToMock;
|
||||||
wrapper.find(ColumnHeader).find('button').simulate('click');
|
wrapper.find(ColumnHeader).find('button').simulate('click');
|
||||||
expect(global.requestAnimationFrame.mock.calls.length).toEqual(1);
|
expect(scrollToMock).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not try to scroll if there is no scrollable content', () => {
|
it('does not try to scroll if there is no scrollable content', () => {
|
||||||
const wrapper = mount(<Column heading='notifications' />);
|
const wrapper = mount(<Column heading='notifications' />);
|
||||||
wrapper.find(ColumnHeader).find('button').simulate('click');
|
wrapper.find(ColumnHeader).find('button').simulate('click');
|
||||||
expect(global.requestAnimationFrame.mock.calls.length).toEqual(0);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue