Skip to content

Commit

Permalink
improve unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviergonz committed Sep 24, 2018
1 parent 0a133bf commit 5ed3786
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/base/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ test("should be possible to change observed state in an action called from compu
const testAction = mobx.action(() => {
mobx._allowStateChangesInsideComputed(() => {
a.set(3)
// a second level computed should throw
expect(() => c2.get()).toThrowError(
/Computed values are not allowed to cause side effects by changing observables that are already being observed/
)
})
expect(a.get()).toBe(3)
expect(() => {
Expand All @@ -196,6 +200,11 @@ test("should be possible to change observed state in an action called from compu
return a.get()
})

const c2 = mobx.computed(() => {
a.set(6)
return a.get()
})

c.get()

mobx._resetGlobalState()
Expand Down

0 comments on commit 5ed3786

Please sign in to comment.