]> cat aescling's git repositories - mastodon.git/commitdiff
Fix failing jest test (#13681)
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 8 May 2020 19:21:57 +0000 (21:21 +0200)
committerGitHub <noreply@github.com>
Fri, 8 May 2020 19:21:57 +0000 (21:21 +0200)
app/javascript/mastodon/features/ui/components/__tests__/column-test.js

index 89cb2458d42713cc92fb22c56c8aadde108957f9..d2791ce08d0ca1239ac7f9d32d413b3e693b88c5 100644 (file)
@@ -5,30 +5,21 @@ 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>,
       );
+      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(<Column heading='notifications' />);
       wrapper.find(ColumnHeader).find('button').simulate('click');
-      expect(global.requestAnimationFrame.mock.calls.length).toEqual(0);
     });
   });
 });