diff options
author | Henry Smith <henry@henrysmith.org> | 2017-04-12 17:16:59 +0200 |
---|---|---|
committer | Eugen <eugen@zeonfederated.com> | 2017-04-12 17:16:59 +0200 |
commit | 08fce0821706a3c84b70fd513eb75c0ad7014c04 (patch) | |
tree | 699017d0f876fa0cc3ddc5b03de87ccd303dfe29 /spec/javascript | |
parent | 3064ef96a12c418281789ee43408fb608d3e9bd2 (diff) |
Add unit tests for https://github.com/tootsuite/mastodon/pull/1574 (#1584)
Diffstat (limited to 'spec/javascript')
-rw-r--r-- | spec/javascript/components/features/ui/components/column.test.jsx | 30 |
1 files changed, 30 insertions, 0 deletions
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 000000000..b7e257757 --- /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('<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); + }); + }); +}); |