]> cat aescling's git repositories - mastodon.git/commitdiff
Add unit tests for https://github.com/tootsuite/mastodon/pull/1574 (#1584)
authorHenry Smith <henry@henrysmith.org>
Wed, 12 Apr 2017 15:16:59 +0000 (17:16 +0200)
committerEugen <eugen@zeonfederated.com>
Wed, 12 Apr 2017 15:16:59 +0000 (17:16 +0200)
spec/javascript/components/features/ui/components/column.test.jsx [new file with mode: 0644]

diff --git a/spec/javascript/components/features/ui/components/column.test.jsx b/spec/javascript/components/features/ui/components/column.test.jsx
new file mode 100644 (file)
index 0000000..b7e2577
--- /dev/null
@@ -0,0 +1,30 @@
+import { expect } from 'chai';
+import { mount } from 'enzyme';
+import sinon from 'sinon';
+
+import Column from '../../../../../../app/assets/javascripts/components/features/ui/components/column';
+import ColumnHeader from '../../../../../../app/assets/javascripts/components/features/ui/components/column_header';
+
+describe('<Column />', () => {
+  describe('<ColumnHeader /> click handler', () => {
+    beforeEach(() => {
+      global.requestAnimationFrame = sinon.spy();
+    });
+
+    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.called).to.equal(true);
+    });
+
+    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.called).to.equal(false);
+    });
+  });
+});