mastodon/spec/javascript/components/features/ui/components/column.test.js
Yamagishi Kazutoshi 39ea5c0e2e Improve tests for JavaScript (#3496)
- Upgrade dependencies
    - chai (3.5.0 -> 4.0.1)
    - chai-enzyme (0.6.1 -> 0.7.1)
    - sinon (2.2.0 -> 2.3.2)
- Change extensions from .jsx to .js
- Don't assign `React` to `global`
- Check code format using ESLint
2017-06-01 17:27:15 +02:00

31 lines
1.1 KiB
JavaScript

import { expect } from 'chai';
import { mount } from 'enzyme';
import sinon from 'sinon';
import React from 'react';
import Column from '../../../../../../app/javascript/mastodon/features/ui/components/column';
import ColumnHeader from '../../../../../../app/javascript/mastodon/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);
});
});
});