about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/ui/components/__tests__/column-test.js
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-10-16 16:33:08 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-10-16 09:33:08 +0200
commitd5b767c3747b9e7f9afcbcecffb662843ca2a346 (patch)
treebb88336c5bdce5b09358eefc310f9b098e81bfde /app/javascript/mastodon/features/ui/components/__tests__/column-test.js
parent93b54b8d4b51f87c6e9cf642d5f57f557e9cd555 (diff)
Replace JavaScript Testing Framework from Mocha to Jest (#5412)
Diffstat (limited to 'app/javascript/mastodon/features/ui/components/__tests__/column-test.js')
-rw-r--r--app/javascript/mastodon/features/ui/components/__tests__/column-test.js34
1 files changed, 34 insertions, 0 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
new file mode 100644
index 000000000..1e5e1d8dc
--- /dev/null
+++ b/app/javascript/mastodon/features/ui/components/__tests__/column-test.js
@@ -0,0 +1,34 @@
+import React from 'react';
+import { mount } from 'enzyme';
+import Column from '../column';
+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>
+      );
+      wrapper.find(ColumnHeader).simulate('click');
+      expect(global.requestAnimationFrame.mock.calls.length).toEqual(1);
+    });
+
+    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.mock.calls.length).toEqual(0);
+    });
+  });
+});