Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(package): switch to Jest #2971

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b283f9b
chore(package): switch to jest
Jul 2, 2018
a540c03
chore(package): move /lib specs
Jul 2, 2018
67044e8
chore(package): move /addons specs
Jul 2, 2018
43a6f80
chore(package): move /views specs
Jul 2, 2018
9b901d2
chore(package): move /modules specs
Jul 2, 2018
d97a1ca
chore(package): move /elements specs
Jul 2, 2018
0dfce09
chore(package): move /behaviours specs
Jul 2, 2018
dcd0564
chore(package): move /collections specs
Jul 2, 2018
4ad1eea
chore(package): move /commonTests specs
Jul 2, 2018
6a2ffda
chore(package): remove karma stuff
Jul 2, 2018
9e01f3e
chore(package): restore lib tests
Jul 2, 2018
766329c
chore(package): use direct imports in lib
Jul 2, 2018
e309627
chore(package): fixes in views tests
Jul 2, 2018
9095529
chore(package): update config
Jul 2, 2018
796329b
Merge branch 'master' of https://github.com/Semantic-Org/Semantic-UI-…
Jul 13, 2018
ee474cc
fix(Feed): fix FeedLabel tests
Jul 13, 2018
065b239
fix(Item): fix Item tests
Jul 13, 2018
e6f8c41
chore(package): update jest
Jul 13, 2018
1e3177b
Merge branch 'master' of https://github.com/Semantic-Org/Semantic-UI-…
Jul 16, 2018
599ee02
fix config
Jul 16, 2018
74d7f73
fix consoleUtil
Jul 16, 2018
a3d5943
move exports tests to separate directory
Jul 16, 2018
2397694
remove runInBand
Jul 16, 2018
69f88f6
use certain workers
Jul 16, 2018
75c2fd2
use toBe()
Jul 16, 2018
bd1a2d5
use toBe()
Jul 16, 2018
b5b1683
fix Confirm tests
Jul 16, 2018
935bdad
fix Pagination tests
Jul 16, 2018
f8646d5
fix Ref & Select tests
Jul 16, 2018
58dd06d
fix TransitionablePortal & Radio tests
Jul 16, 2018
2468fde
fix Responsive tests
Jul 16, 2018
8fdf3ae
fix Textarea tests
Jul 16, 2018
5b9c1b4
fix Portal tests
Jul 16, 2018
bc0531d
fix Input and Button tests
Jul 17, 2018
a86f2da
fix elements tests
Jul 17, 2018
0a2ea2c
use jest.fn() instead of sandbox.spy()
Jul 18, 2018
f484278
fix Form tests
Jul 18, 2018
54a904f
fix collections tests
Jul 18, 2018
225b3e0
fixing modules tests
Jul 18, 2018
49d183a
fixing modules tests
Jul 19, 2018
1a9f3c3
fixing modules tests
Jul 19, 2018
4ad1ff3
fixing modules tests
Jul 19, 2018
eef5c65
fixing modules tests
Jul 19, 2018
84ccef1
fixing modules tests
Jul 19, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
]
},
"test": {
"plugins": [
["istanbul", { "include": ["src"] }]
]
"presets": [["@babel/env"], "@babel/react"]
}
}
}
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
command: yarn lint
- run:
name: Test JavaScript
command: yarn test
command: yarn test -w=4
- run:
name: Report coverage
command: bash <(curl -s https://codecov.io/bash)
6 changes: 2 additions & 4 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import path from 'path'
// ------------------------------------
const env = process.env.NODE_ENV || 'development'
const __DEV__ = env === 'development'
const __TEST__ = env === 'test'
const __PROD__ = env === 'production'

const envConfig = {
Expand Down Expand Up @@ -51,18 +50,17 @@ const config = {
// ----------------------------------
// Compiler Configuration
// ----------------------------------
compiler_devtool: (__DEV__ || __TEST__) && 'cheap-source-map',
compiler_devtool: __DEV__ && 'cheap-source-map',
compiler_globals: {
'process.env': {
NODE_ENV: JSON.stringify(env),
},
__DEV__,
__PATH_SEP__: JSON.stringify(path.sep),
__TEST__,
__PROD__,
},
compiler_hash_type: __PROD__ ? 'chunkhash' : 'hash',
compiler_fail_on_warning: __TEST__ || __PROD__,
compiler_fail_on_warning: __PROD__,
compiler_output_path: paths.base(envConfig.dir_docs_dist),
compiler_public_path: '/',
compiler_stats: {
Expand Down
1 change: 0 additions & 1 deletion docs/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"globals": {
"__DEV__": false,
"__TEST__": false,
"__PATH_SEP__": false,
"__PROD__": false
},
Expand Down
99 changes: 0 additions & 99 deletions karma.conf.babel.js

This file was deleted.

45 changes: 24 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,31 @@
"prestart": "yarn satisfied --fix yarn",
"start": "gulp --series dll docs",
"satisfied": "satisfied --skip-invalid",
"pretest": "yarn satisfied && gulp dll build:docs:docgen",
"test": "cross-env NODE_ENV=test node -r @babel/register ./node_modules/karma/bin/karma start karma.conf.babel.js",
"test:watch": "yarn test --no-single-run",
"pretest": "yarn satisfied && gulp build:docs:docgen",
"test": "cross-env NODE_ENV=test jest --coverage",
"test:watch": "yarn test --watchAll",
"tsd:lint": "tslint \"./index.d.ts\" \"./src/**/*.d.ts\" \"./src/**/*.tsx\" \"./test/**/*.d.ts\" \"./test/**/*.tsx\"",
"tsd:lint:fix": "yarn tsd:lint --fix",
"tsd:test": "gulp build:dist:commonjs:tsd && tsc -p ./ && rm test/typings.js"
},
"jest": {
"coverageDirectory": "./coverage/",
"coverageReporters": [
"json",
"lcov"
],
"moduleFileExtensions": [
"js",
"json"
],
"moduleNameMapper": {
"^docs/(.*)$": "<rootDir>/docs/$1",
"^src/(.*)$": "<rootDir>/src/$1",
"^test/(.*)$": "<rootDir>/test/$1"
},
"setupTestFrameworkScriptFile": "<rootDir>/test/setupTests.js",
"testRegex": "/test/specs/(modules)/(Accordion|Checkbox|Dimmer)/.*-test\\.js$"
},
"lint-staged": {
"**/*.{js,jsx}": [
"prettier --write",
Expand Down Expand Up @@ -86,21 +104,19 @@
"@babel/register": "^7.0.0-beta.49",
"@babel/standalone": "^7.0.0-beta.49",
"@types/react": "^16.0.0",
"babel-core": "^7.0.0-0",
"babel-eslint": "^8.2.3",
"babel-jest": "^23.4.0",
"babel-loader": "^8.0.0-beta.3",
"babel-plugin-filter-imports": "^2.0.0",
"babel-plugin-istanbul": "^4.1.6",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-transform-react-handled-props": "^1.0.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.13",
"babel-polyfill": "7.0.0-beta.3",
"chai": "^4.1.1",
"chai-enzyme": "beta",
"connect-history-api-fallback": "^1.3.0",
"copy-to-clipboard": "^3.0.8",
"cross-env": "^5.1.4",
"debug": "^3.0.1",
"dirty-chai": "^2.0.1",
"doctoc": "^1.3.0",
"doctrine": "^2.0.0",
"enzyme": "^3.3.0",
Expand All @@ -109,7 +125,6 @@
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-mocha": "^4.11.0",
"eslint-plugin-react": "^7.2.1",
"express": "^4.15.4",
"faker": "^4.1.0",
Expand All @@ -120,20 +135,11 @@
"html-webpack-plugin": "^2.30.1",
"husky": "^0.14.3",
"imports-loader": "^0.7.1",
"jest": "^23.4.0",
"js-beautify": "^1.6.14",
"json-loader": "^0.5.7",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-coverage": "^1.1.2",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.3",
"karma-webpack-with-fast-source-maps": "^1.10.2",
"leven": "^2.1.0",
"lint-staged": "^7.2.0",
"mocha": "^3.5.0",
"prettier": "^1.12.0",
"puppeteer": "1.3.0",
"raw-loader": "^0.5.1",
"react": "^16.0.0",
"react-ace": "^5.1.2",
Expand All @@ -143,14 +149,11 @@
"react-hot-loader": "^4.1.3",
"react-router": "^4.1.2",
"react-router-dom": "^4.1.2",
"react-test-renderer": "^16.0.0",
"require-dir": "^0.3.2",
"rimraf": "^2.6.1",
"satisfied": "^1.1.2",
"semantic-ui-css": "^2.3.1",
"simulant": "^0.2.2",
"sinon": "^5.0.10",
"sinon-chai": "^3.1.0",
"ta-scripts": "^2.5.2",
"through2": "^2.0.3",
"tslint": "^5.10.0",
Expand Down
4 changes: 1 addition & 3 deletions src/elements/Label/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ export default class Label extends Component {
static Group = LabelGroup

handleClick = (e) => {
const { onClick } = this.props

if (onClick) onClick(e, this.props)
_.invoke(this.props, 'onClick', e, this.props)
}

handleIconOverrides = predefinedProps => ({
Expand Down
31 changes: 12 additions & 19 deletions src/modules/Rating/RatingIcon.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import cx from 'classnames'
import keyboardKey from 'keyboard-key'
import _ from 'lodash'
import PropTypes from 'prop-types'
import React, { Component } from 'react'

Expand Down Expand Up @@ -55,32 +56,24 @@ export default class RatingIcon extends Component {
}

handleClick = (e) => {
const { onClick } = this.props

if (onClick) onClick(e, this.props)
_.invoke(this.props, 'onClick', e, this.props)
}

handleKeyUp = (e) => {
const { onClick, onKeyUp } = this.props

if (onKeyUp) onKeyUp(e, this.props)

if (onClick) {
switch (keyboardKey.getCode(e)) {
case keyboardKey.Enter:
case keyboardKey.Spacebar:
e.preventDefault()
onClick(e, this.props)
break
default:
}
_.invoke(this.props, 'onKeyUp', e, this.props)

switch (keyboardKey.getCode(e)) {
case keyboardKey.Enter:
case keyboardKey.Spacebar:
e.preventDefault()
_.invoke(this.props, 'onClick', e, this.props)
break
default:
}
}

handleMouseEnter = (e) => {
const { onMouseEnter } = this.props

if (onMouseEnter) onMouseEnter(e, this.props)
_.invoke(this.props, 'onMouseEnter', e, this.props)
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Feed/FeedLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function FeedLabel(props) {
<ElementType {...rest} className={classes}>
{content}
{Icon.create(icon, { autoGenerateKey: false })}
{createHTMLImage(image)}
{createHTMLImage(image, { autoGenerateKey: false })}
</ElementType>
)
}
Expand Down
12 changes: 3 additions & 9 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
{
"env": {
"browser": true,
"node": true,
"mocha": true
"jest": true,
"node": true
},
"globals": {
"enzyme": false,
"expect": false,
"mount": false,
"shallow": false,
"render": false
"shallow": false
},
"plugins": [
"mocha"
],
"rules": {
"jsx-a11y/alt-text": 0,
"jsx-a11y/tabindex-no-positive": 0
Expand Down
Loading