From 39ea5c0e2e9bdf2c6e3bd0797e6fb422e6117aa2 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Fri, 2 Jun 2017 00:27:15 +0900 Subject: 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 --- .../features/ui/components/column.test.js | 30 ++++++++++++++++++++++ .../features/ui/components/column.test.jsx | 30 ---------------------- 2 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 spec/javascript/components/features/ui/components/column.test.js delete mode 100644 spec/javascript/components/features/ui/components/column.test.jsx (limited to 'spec/javascript/components/features') diff --git a/spec/javascript/components/features/ui/components/column.test.js b/spec/javascript/components/features/ui/components/column.test.js new file mode 100644 index 000000000..df0f43e60 --- /dev/null +++ b/spec/javascript/components/features/ui/components/column.test.js @@ -0,0 +1,30 @@ +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('', () => { + 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); + }); + }); +}); diff --git a/spec/javascript/components/features/ui/components/column.test.jsx b/spec/javascript/components/features/ui/components/column.test.jsx deleted file mode 100644 index 6359905e6..000000000 --- a/spec/javascript/components/features/ui/components/column.test.jsx +++ /dev/null @@ -1,30 +0,0 @@ -import { expect } from 'chai'; -import { mount } from 'enzyme'; -import sinon from 'sinon'; - -import Column from '../../../../../../app/javascript/mastodon/features/ui/components/column'; -import ColumnHeader from '../../../../../../app/javascript/mastodon/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); - }); - }); -}); -- cgit