Remove all the "should" grammar from tests

This commit is contained in:
Ben Drucker
2016-07-04 08:07:54 -07:00
parent 57030b4e0e
commit 180ea8ae10
2 changed files with 59 additions and 61 deletions
+50 -52
View File
@@ -1,61 +1,59 @@
const tape = require('tape')
const test = require('tape')
const choo = require('../../')
const view = require('../../html')
tape('should render on the client', function (t) {
t.test('state should not be mutable', function (t) {
t.plan(4)
test('state is immutable', function (t) {
t.plan(4)
const app = choo()
const state = {
foo: 'baz',
beep: 'boop'
}
const app = choo()
const state = {
foo: 'baz',
beep: 'boop'
}
app.model({
state: state,
namespace: 'test',
reducers: {
'no-reducer-mutate': (action, state) => {
return {}
},
'mutate-on-return': (action, state) => {
delete action.type
return action
}
app.model({
state: state,
namespace: 'test',
reducers: {
'no-reducer-mutate': (action, state) => {
return {}
},
effects: {
'triggers-reducers': (action, state, send, done) => {
send('test:mutate-on-return', {beep: 'barp'}, done)
}
'mutate-on-return': (action, state) => {
delete action.type
return action
}
})
let loop = -1
const asserts = [
(state) => t.deepEqual(state, {foo: 'baz', beep: 'boop'}, 'intial state'),
(state) => t.deepEqual(state, {foo: 'baz', beep: 'boop'}, 'no change in state'),
(state) => t.deepEqual(state, {foo: 'oof', beep: 'boop'}, 'change in state from reducer'),
(state) => t.deepEqual(state, {foo: 'oof', beep: 'barp'}, 'change in state from effect')
]
const triggers = [
(send) => send('test:no-reducer-mutate'),
(send) => send('test:mutate-on-return', {foo: 'oof'}),
(send) => send('test:triggers-reducers')
]
app.router((route) => [
route('/', function (state, prev, send) {
++loop
asserts[loop] && asserts[loop](state.test)
setTimeout(() => triggers[loop] && triggers[loop](send), 5)
return view`<div><span class="test">${state.foo}:${state.beep}</span></div>`
})
])
const tree = app.start()
document.body.appendChild(tree)
},
effects: {
'triggers-reducers': (action, state, send, done) => {
send('test:mutate-on-return', {beep: 'barp'}, done)
}
}
})
let loop = -1
const asserts = [
(state) => t.deepEqual(state, {foo: 'baz', beep: 'boop'}, 'intial state'),
(state) => t.deepEqual(state, {foo: 'baz', beep: 'boop'}, 'no change in state'),
(state) => t.deepEqual(state, {foo: 'oof', beep: 'boop'}, 'change in state from reducer'),
(state) => t.deepEqual(state, {foo: 'oof', beep: 'barp'}, 'change in state from effect')
]
const triggers = [
(send) => send('test:no-reducer-mutate'),
(send) => send('test:mutate-on-return', {foo: 'oof'}),
(send) => send('test:triggers-reducers')
]
app.router((route) => [
route('/', function (state, prev, send) {
++loop
asserts[loop] && asserts[loop](state.test)
setTimeout(() => triggers[loop] && triggers[loop](send), 5)
return view`<div><span class="test">${state.foo}:${state.beep}</span></div>`
})
])
const tree = app.start()
document.body.appendChild(tree)
})