Skip to content

Commit

Permalink
fixup! test subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Jul 1, 2016
1 parent 892ce1e commit 319ef68
Showing 1 changed file with 63 additions and 2 deletions.
65 changes: 63 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,72 @@ tape('handlers: effects', (t) => {
send('foo')
})

t.test('should be able to propagate nested errors')
t.test('should be able to propagate nested errors', (t) => {
t.plan(7)
const store = barracks()
store.model({
effects: {
foo: (action, state, send, done) => {
t.pass('foo was called')
send('bar', (err, res) => {
t.ok(err, 'error detected')
t.pass('foo:bar effect callback was called')
done()
})
},
bar: (action, state, send, done) => {
t.pass('bar was called')
send('baz', (err, res) => {
t.ok(err, 'error detected')
t.pass('bar:baz effect callback was called')
done(err)
})
},
baz: (action, state, send, done) => {
t.pass('baz effect was called')
done(new Error('oh noooo'))
}
}
})
const createSend = store.start()
const send = createSend('tester', true)
send('foo')
})
})

tape('handlers: subscriptions', (t) => {
t.test('should be able to call')
t.test('should be able to call', (t) => {
t.plan(8)
const store = barracks()
store.model({
reducers: {
bar: () => t.pass('reducer called')
},
effects: {
foo: (action, state, send, done) => {
t.pass('foo was called')
done(new Error('oh no!'), 'hello')
}
},
subscriptions: {
mySub: (send, done) => {
t.pass('mySub was initiated')
send('foo', (err, res) => {
t.ok(err, 'error detected')
t.equal(res, 'hello', 'res was passed')
t.pass('mySub:foo effect callback was called')
send('bar', (err, res) => {
t.error(err, 'no error detected')
t.pass('mySub:bar effect callback was called')
})
})
}
}
})
store.start()
})

t.test('should be able to emit an error')
})

tape('hooks: onState')
Expand Down

0 comments on commit 319ef68

Please sign in to comment.