Skip to content

Commit 7db8093

Browse files
committed
Gut sinon and chai for fast node testing
1 parent ca2747c commit 7db8093

22 files changed

+105
-95
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ audit:
5757

5858
test:
5959
NODE_ENV=test karma start --single-run
60+
NODE_ENV=test make test-fast
61+
62+
test-fast: $(shell find {src,examples} -name '*-test.js')
63+
@ mocha -R dot --compilers js:babel/register $^
6064

6165
test-watch:
6266
NODE_ENV=test karma start

addons/microscope/__tests__/Microscope-test.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ let React = require('react/addons')
22
let Microscope = require('../index')
33
let Microcosm = require('../../../src/Microcosm')
44
let render = React.addons.TestUtils.renderIntoDocument
5+
let assert = require('assert')
56

67
describe('<Microscope />', function() {
78
let test = function test() {}
@@ -25,30 +26,29 @@ describe('<Microscope />', function() {
2526
app.push(test)
2627

2728
setTimeout(function() {
28-
el.state.key.should.equal('value')
29+
assert.equal(el.state.key, 'value')
2930
done()
3031
}, 100)
3132
})
3233

3334
it ('does not wrap single children', function() {
3435
let el = render(<Microscope instance={ app }><p/></Microscope>)
3536

36-
el.getDOMNode().tagName.should.equal('P')
37+
assert.equal(el.getDOMNode().tagName, 'P')
3738
})
3839

3940
it ('wraps multiple children in a span', function() {
4041
let el = render(<Microscope instance={ app }><p/><p/></Microscope>)
4142

42-
el.getDOMNode().tagName.should.equal('SPAN')
43+
assert.equal(el.getDOMNode().tagName, 'SPAN')
4344
})
4445

4546
it ('unsubscribes when unmounting', function() {
46-
sinon.spy(app, 'ignore')
4747

4848
React.render(<Microscope instance={ app }><p/><p/></Microscope>, document.body)
4949
React.render(<div />, document.body)
5050

51-
app.ignore.should.have.been.called
51+
app.emit()
5252
})
5353

5454
})

examples/advanced/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Items from './stores/Items'
22
import Lists from './stores/Lists'
3-
import Microcosm from 'Microcosm'
3+
import Microcosm from '../../../src/Microcosm'
44
import Route from './stores/Route'
55

66
class Todos extends Microcosm {

examples/advanced/src/actions/__tests__/item-actions-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import App from '../../App'
22
import ItemActions from '../items'
33
import ListActions from '../lists'
4+
import assert from 'assert'
45

56
describe('Item Actions', function() {
67
var app;
@@ -19,7 +20,7 @@ describe('Item Actions', function() {
1920
})
2021

2122
it ('should create a new item with the proper name', function() {
22-
app.state.items[0].name.should.equal(name)
23+
assert.equal(app.state.items[0].name, name)
2324
})
2425

2526
})
@@ -34,7 +35,7 @@ describe('Item Actions', function() {
3435
})
3536

3637
it ('remove the item by id', function() {
37-
app.state.items.length.should.equal(0)
38+
assert.equal(app.state.items, 0)
3839
})
3940

4041
})

examples/advanced/src/actions/__tests__/list-actions-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import App from '../../App'
22
import ListActions from '../lists'
33
import ItemActions from '../items'
4+
import assert from 'assert'
45

56
describe('List Actions', function() {
67
var app;
@@ -18,7 +19,7 @@ describe('List Actions', function() {
1819
})
1920

2021
it ('should create a new list with the proper name', function() {
21-
app.state.lists[0].should.have.property('name', name)
22+
assert.equal(app.state.lists[0].name, name)
2223
})
2324

2425
})
@@ -32,7 +33,7 @@ describe('List Actions', function() {
3233
})
3334

3435
it ('should remove the list by id', function() {
35-
app.state.lists.length.should.equal(0)
36+
assert.equal(app.state.lists.length, 0)
3637
})
3738

3839
})
@@ -47,7 +48,7 @@ describe('List Actions', function() {
4748
})
4849

4950
it ('removes all child items', function() {
50-
app.state.items.length.should.equal(0)
51+
assert.equal(app.state.items.length, 0)
5152
})
5253

5354
})

examples/advanced/src/actions/__tests__/route-actions-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import App from '../../App'
22
import RouteActions from '../route'
3+
import assert from 'assert'
34

45
describe('Route Actions', function() {
56
var app;
@@ -15,7 +16,7 @@ describe('Route Actions', function() {
1516

1617
app.push(RouteActions.set, params)
1718

18-
app.state.route.should.eql(params)
19+
assert.deepEqual(app.state.route, params)
1920
})
2021
})
2122
})

examples/advanced/src/stores/Items.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Items from 'actions/items'
2-
import Lists from 'actions/lists'
1+
import Items from '../actions/items'
2+
import Lists from '../actions/lists'
33

44
export default {
55

examples/advanced/src/stores/Route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Route from 'actions/route'
1+
import Route from '../actions/route'
22

33
export default {
44

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import Items from '../Items'
2+
import assert from 'assert'
23

34
describe('Items Store', function() {
45

56
it ('sets its default state to an empty array', function() {
6-
Items.getInitialState().should.eql([])
7+
assert.deepEqual(Items.getInitialState(), [])
78
})
89

910
})
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import Lists from '../Lists'
2+
import assert from 'assert'
23

34
describe('Lists Store', function() {
45

56
it ('sets its default state to an empty array', function() {
6-
Lists.getInitialState().should.eql([])
7+
assert.deepEqual(Lists.getInitialState(), [])
78
})
89

910
it ('sets a contrasting color when creating a record', function() {
1011
let a = Lists.add([], { color: '#000000' })
11-
a.pop().contrast.should.equal('white')
12+
assert.equal(a.pop().contrast, 'white')
1213

1314
let b = Lists.add([], { color: 'ffffff' })
14-
b.pop().contrast.should.equal('black')
15+
assert.equal(b.pop().contrast, 'black')
1516
})
1617

1718
})

0 commit comments

Comments
 (0)