Update onError hook test to only expect err argument

This commit is contained in:
Ben Drucker
2016-07-04 16:19:17 -07:00
parent e0783320f7
commit 30a228b3e0
+11 -13
View File
@@ -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')
} }
}) })