Update onError hook test to only expect err argument
This commit is contained in:
+11
-13
@@ -3,26 +3,24 @@ const choo = require('../../')
|
|||||||
const view = require('../../html')
|
const view = require('../../html')
|
||||||
|
|
||||||
test('hooks', function (t) {
|
test('hooks', function (t) {
|
||||||
t.plan(11)
|
t.plan(9)
|
||||||
|
|
||||||
const app = choo({
|
const app = choo({
|
||||||
onError: function (err, state, createSend) {
|
onError: function (err) {
|
||||||
t.equal(err.message, 'effect error', 'receives err')
|
t.equal(err.message, 'effect error', 'onError: receives err')
|
||||||
t.equal(state.clicks, 1, 'current state: 1 clicks')
|
|
||||||
t.equal(typeof createSend, 'function', 'createSend fn')
|
|
||||||
},
|
},
|
||||||
onAction: function (action, state, name, caller, createSend) {
|
onAction: function (action, state, name, caller, createSend) {
|
||||||
if (name === 'explodes') return
|
if (name === 'explodes') return
|
||||||
t.deepEqual(action, {foo: 'bar'}, 'action data')
|
t.deepEqual(action, {foo: 'bar'}, 'onAction: action data')
|
||||||
t.equal(state.clicks, 0, 'current state: 0 clicks')
|
t.equal(state.clicks, 0, 'onAction: current state: 0 clicks')
|
||||||
t.equal(name, 'click', 'action name')
|
t.equal(name, 'click', 'onAction: action name')
|
||||||
t.equal(caller, '/', 'caller name')
|
t.equal(caller, '/', 'onAction: caller name')
|
||||||
t.equal(typeof createSend, 'function', 'createSend fn')
|
t.equal(typeof createSend, 'function', 'onAction: createSend fn')
|
||||||
},
|
},
|
||||||
onState: function (action, state, prev, createSend) {
|
onState: function (action, state, prev, createSend) {
|
||||||
t.deepEqual(action, {foo: 'bar'}, 'action data')
|
t.deepEqual(action, {foo: 'bar'}, 'onState: action data')
|
||||||
t.deepEqual(state.clicks, 1, 'new state: 1 clicks')
|
t.deepEqual(state.clicks, 1, 'onState: new state: 1 clicks')
|
||||||
t.deepEqual(prev.clicks, 0, 'prev state: 0 clicks')
|
t.deepEqual(prev.clicks, 0, 'onState: prev state: 0 clicks')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user