From 5ed37861c3dfb34ded5fb2796b50ae002a909031 Mon Sep 17 00:00:00 2001 From: Javier Gonzalez Date: Mon, 24 Sep 2018 19:54:57 +0200 Subject: [PATCH] improve unit test --- test/base/action.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/base/action.js b/test/base/action.js index 0e96f07a5..ae8a748f5 100644 --- a/test/base/action.js +++ b/test/base/action.js @@ -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(() => { @@ -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()