From 0d62e097077b60c9914c2f9c425fce69c9b693eb Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 8 May 2020 21:21:57 +0200 Subject: [PATCH] Fix failing jest test (#13681) --- .../ui/components/__tests__/column-test.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/app/javascript/mastodon/features/ui/components/__tests__/column-test.js b/app/javascript/mastodon/features/ui/components/__tests__/column-test.js index 89cb2458d4..d2791ce08d 100644 --- a/app/javascript/mastodon/features/ui/components/__tests__/column-test.js +++ b/app/javascript/mastodon/features/ui/components/__tests__/column-test.js @@ -5,30 +5,21 @@ import ColumnHeader from '../column_header'; describe('', () => { describe(' 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(
, ); + const scrollToMock = jest.fn(); + wrapper.find(Column).find('.scrollable').getDOMNode().scrollTo = scrollToMock; 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', () => { const wrapper = mount(); wrapper.find(ColumnHeader).find('button').simulate('click'); - expect(global.requestAnimationFrame.mock.calls.length).toEqual(0); }); }); });