From 08fce0821706a3c84b70fd513eb75c0ad7014c04 Mon Sep 17 00:00:00 2001 From: Henry Smith Date: Wed, 12 Apr 2017 17:16:59 +0200 Subject: [PATCH] Add unit tests for https://github.com/tootsuite/mastodon/pull/1574 (#1584) --- .../features/ui/components/column.test.jsx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/javascript/components/features/ui/components/column.test.jsx 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 index 00000000..b7e25775 --- /dev/null +++ b/spec/javascript/components/features/ui/components/column.test.jsx @@ -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('', () => { + describe(' click handler', () => { + beforeEach(() => { + global.requestAnimationFrame = sinon.spy(); + }); + + it('runs the scroll animation if the column contains scrollable content', () => { + const wrapper = mount( + +
+ + ); + 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(); + wrapper.find(ColumnHeader).simulate('click'); + expect(global.requestAnimationFrame.called).to.equal(false); + }); + }); +});