Skip to content

Commit

Permalink
fixup! add onAction test
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Jul 1, 2016
1 parent 66954ba commit 8e01352
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,36 @@ tape('hooks: onState', (t) => {
send('increment', { count: 3 })
})
})
tape('hooks: onAction')

tape('hooks: onAction', (t) => {
t.test('should be called whenever an action is emitted', (t) => {
t.plan(5)
const store = barracks({
onAction: (action, state, actionName, caller, createSend) => {
t.deepEqual(action, { count: 3 }, 'action is equal')
t.deepEqual(state, { count: 1 }, 'state is equal')
t.deepEqual(actionName, 'foo', 'actionName is equal')
t.equal(caller, 'test', 'caller is equal')
}
})

store.model({
state: { count: 1 },
effects: {
foo: (action, state, send, done) => {
t.pass('effect called')
done()
}
}
})

const createSend = store.start()
const send = createSend('test', true)
send('foo', { count: 3 })
})
})

tape('hooks: onError', (t) => {
t.test('should validate input types')
t.test('should have a default err handler')
t.test('should not call itself')
})

0 comments on commit 8e01352

Please sign in to comment.