From 39ea5c0e2e9bdf2c6e3bd0797e6fb422e6117aa2 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Fri, 2 Jun 2017 00:27:15 +0900 Subject: [PATCH] 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 --- package.json | 10 ++-- .../{avatar.test.jsx => avatar.test.js} | 4 +- .../{button.test.jsx => button.test.js} | 2 +- ...lay_name.test.jsx => display_name.test.js} | 8 +-- ...wn_menu.test.jsx => dropdown_menu.test.js} | 12 ++-- .../{column.test.jsx => column.test.js} | 2 +- ...tor.test.jsx => loading_indicator.test.js} | 4 +- spec/javascript/setup.js | 5 +- yarn.lock | 55 +++++++++++-------- 9 files changed, 55 insertions(+), 47 deletions(-) rename spec/javascript/components/{avatar.test.jsx => avatar.test.js} (94%) rename spec/javascript/components/{button.test.jsx => button.test.js} (98%) rename spec/javascript/components/{display_name.test.jsx => display_name.test.js} (88%) rename spec/javascript/components/{dropdown_menu.test.jsx => dropdown_menu.test.js} (96%) rename spec/javascript/components/features/ui/components/{column.test.jsx => column.test.js} (97%) rename spec/javascript/components/{loading_indicator.test.jsx => loading_indicator.test.js} (75%) diff --git a/package.json b/package.json index c686e99e..ee65dbea 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "start": "rimraf ./tmp/streaming && babel ./streaming/index.js --out-dir ./tmp && node ./tmp/streaming/index.js", "storybook": "NODE_ENV=test start-storybook -p 9001 -c storybook", "test": "npm run test:lint && npm run test:mocha", - "test:lint": "eslint -c .eslintrc.yml --ext=js app/javascript/ config/webpack/ storyboard/ streaming/", - "test:mocha": "NODE_ENV=test mocha --require ./spec/javascript/setup.js --compilers js:babel-register ./spec/javascript/components/*.test.jsx", + "test:lint": "eslint -c .eslintrc.yml --ext=js app/javascript/ config/webpack/ spec/javascript/ storyboard/ streaming/", + "test:mocha": "NODE_ENV=test mocha --require ./spec/javascript/setup.js --compilers js:babel-register ./spec/javascript/components/*.test.js", "postinstall": "npm rebuild node-sass" }, "repository": { @@ -116,8 +116,8 @@ "devDependencies": { "@kadira/storybook": "^2.35.3", "babel-eslint": "^7.2.3", - "chai": "^3.5.0", - "chai-enzyme": "^0.6.1", + "chai": "^4.0.1", + "chai-enzyme": "^0.7.1", "enzyme": "^2.8.2", "eslint": "^3.19.0", "eslint-plugin-jsx-a11y": "^4.0.0", @@ -127,7 +127,7 @@ "mocha": "^3.4.1", "react-intl-translations-manager": "^5.0.0", "react-test-renderer": "^15.5.4", - "sinon": "^2.2.0", + "sinon": "^2.3.2", "webpack-dev-server": "^2.4.5" }, "optionalDependencies": { diff --git a/spec/javascript/components/avatar.test.jsx b/spec/javascript/components/avatar.test.js similarity index 94% rename from spec/javascript/components/avatar.test.jsx rename to spec/javascript/components/avatar.test.js index f7017388..03b71dc9 100644 --- a/spec/javascript/components/avatar.test.jsx +++ b/spec/javascript/components/avatar.test.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { render } from 'enzyme'; - -import Avatar from '../../../app/javascript/mastodon/components/avatar' +import React from 'react'; +import Avatar from '../../../app/javascript/mastodon/components/avatar'; describe('', () => { const src = '/path/to/image.jpg'; diff --git a/spec/javascript/components/button.test.jsx b/spec/javascript/components/button.test.js similarity index 98% rename from spec/javascript/components/button.test.jsx rename to spec/javascript/components/button.test.js index e08671c0..9cf8b1ee 100644 --- a/spec/javascript/components/button.test.jsx +++ b/spec/javascript/components/button.test.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { shallow } from 'enzyme'; import sinon from 'sinon'; - +import React from 'react'; import Button from '../../../app/javascript/mastodon/components/button'; describe('