Skip to content

Commit f6e7e82

Browse files
committed
Use Jest for testing
1 parent 8d0a0b2 commit f6e7e82

File tree

8 files changed

+839
-1053
lines changed

8 files changed

+839
-1053
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ es
22
node_modules
33
umd
44
/*.js
5-
!karma.conf.js
6-
!tests.webpack.js
75
!webpack.config.js

karma.conf.js

Lines changed: 0 additions & 123 deletions
This file was deleted.

modules/.eslintrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"parser": "babel-eslint",
3-
"env": {
4-
"browser": true,
5-
"node": true
6-
},
73
"plugins": [
84
"import",
95
"react"
106
],
7+
"env": {
8+
"browser": true,
9+
"node": true
10+
},
1111
"extends": [
1212
"eslint:recommended",
1313
"plugin:import/errors",

modules/__tests__/.eslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"plugins": [
3+
"jest"
4+
],
5+
"env": {
6+
"jest/globals": true
7+
}
8+
}

modules/__tests__/integration-test.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
/*eslint-env mocha*/
21
/*eslint react/prop-types: 0*/
32
import React from 'react'
43
import { render } from 'react-dom'
5-
import expect from 'expect'
64
import { EventEmitter } from 'events'
7-
import { Subscriber, Broadcast } from '../index'
5+
import { Broadcast, Subscriber } from '../index'
86

97
it('works', (done) => {
10-
118
const steps = []
129
const execNextStep = () => steps.shift()()
1310
const div = document.createElement('div')
@@ -16,11 +13,12 @@ it('works', (done) => {
1613
const emitter = new EventEmitter()
1714

1815
// A component has some state it wants to make available to descendants
19-
// 1. We create our Emitter and Subscriber components
20-
const CheeseEmitter = ({ cheese, children }) =>
16+
// 1. We create our Broadcast and Subscriber components
17+
const CheeseBroadcast = ({ cheese, children }) =>
2118
<Broadcast channel="cheese" value={cheese} children={children}/>
19+
2220
const CheeseSubscriber = ({ children }) =>
23-
<Subscriber channel="cheese">{(value) => children(value)}</Subscriber>
21+
<Subscriber channel="cheese" children={children}/>
2422

2523
class ComponentWithStateForDescendants extends React.Component {
2624
constructor() {
@@ -36,13 +34,13 @@ it('works', (done) => {
3634
componentDidUpdate = execNextStep
3735

3836
render() {
39-
// 2. render the Emitter in the component w/ state and pass
37+
// 2. render the Broadcast in the component w/ state and pass
4038
// it the value we want accessible through context as a prop
41-
// by the same name as when the Emitter was created
39+
// by the same name as when the Broadcast was created
4240
return (
43-
<CheeseEmitter cheese={this.state.cheese}>
41+
<CheeseBroadcast cheese={this.state.cheese}>
4442
{this.props.children}
45-
</CheeseEmitter>
43+
</CheeseBroadcast>
4644
)
4745
}
4846
}
@@ -60,7 +58,7 @@ it('works', (done) => {
6058
}
6159
)
6260

63-
// 3. Render a <Subscriber> that calls back when the Emitter
61+
// 3. Render a <Subscriber> that calls back when the Broadcast
6462
// gets a new value in its prop
6563
render((
6664
<ComponentWithStateForDescendants>
@@ -73,4 +71,3 @@ it('works', (done) => {
7371
</ComponentWithStateForDescendants>
7472
), div)
7573
})
76-

package.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"prepublish": "node ./tools/build.js",
1919
"release": "node ./tools/release.js",
2020
"lint": "eslint modules",
21-
"test": "karma start --single-run"
21+
"test": "jest"
2222
},
2323
"peerDependencies": {
2424
"react": ">=15"
@@ -38,18 +38,12 @@
3838
"babel-preset-stage-1": "^6.5.0",
3939
"eslint": "^3.3.1",
4040
"eslint-plugin-import": "^2.0.0",
41+
"eslint-plugin-jest": "^20.0.3",
4142
"eslint-plugin-react": "^6.1.2",
4243
"expect": "^1.20.1",
4344
"gzip-size": "^3.0.0",
4445
"in-publish": "^2.0.0",
45-
"karma": "^1.2.0",
46-
"karma-browserstack-launcher": "^1.0.1",
47-
"karma-chrome-launcher": "^2.0.0",
48-
"karma-mocha": "^1.0.1",
49-
"karma-mocha-reporter": "^2.0.4",
50-
"karma-sourcemap-loader": "^0.3.7",
51-
"karma-webpack": "^2.0.1",
52-
"mocha": "^3.0.2",
46+
"jest": "^20.0.4",
5347
"pretty-bytes": "^4.0.0",
5448
"react": "^15.3.0",
5549
"react-dom": "^15.3.0",

tests.webpack.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)