Skip to content

Commit bdfeecc

Browse files
committed
Add reactor test for dispatching after observer raises error
1 parent 0c646c8 commit bdfeecc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/reactor-tests.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,5 +1077,25 @@ describe('Reactor', () => {
10771077
}).not.toThrow(
10781078
new Error('Dispatch may not be called while a dispatch is in progress'))
10791079
})
1080+
1081+
it('should allow subsequent dispatches if an error is raised in an observer', () => {
1082+
var unWatchFn = reactor.observe([], state => {
1083+
throw new Error('observe error')
1084+
})
1085+
1086+
expect(() => {
1087+
reactor.batch(() => {
1088+
reactor.dispatch('add', 'one')
1089+
reactor.dispatch('add', 'two')
1090+
})
1091+
}).toThrow(
1092+
new Error('observe error'))
1093+
1094+
unWatchFn()
1095+
1096+
expect(() => {
1097+
reactor.dispatch('add', 'three')
1098+
}).not.toThrow()
1099+
})
10801100
})
10811101
})

0 commit comments

Comments
 (0)