@@ -25,10 +25,14 @@ test("json1", function () {
2525 } )
2626 . join ( ", " )
2727 } )
28-
29- todos [ 1 ] . title = "improve coverage" // prints: write blog, improve coverage
28+ mobx . _allowStateChanges ( true , ( ) => {
29+ todos [ 1 ] . title = "improve coverage" // prints: write blog, improve coverage
30+ } )
3031 expect ( output ) . toBe ( "write blog, improve coverage" )
31- todos . push ( { title : "take a nap" } ) // prints: write blog, improve coverage, take a nap
32+ mobx . _allowStateChanges ( true , ( ) => {
33+ todos . push ( { title : "take a nap" } ) // prints: write blog, improve coverage, take a nap
34+ } )
35+
3236 expect ( output ) . toBe ( "write blog, improve coverage, take a nap" )
3337} )
3438
@@ -86,10 +90,12 @@ test("json2", function () {
8690 true
8791 )
8892
89- o . todos [ 0 ] . details . url = "boe"
90- o . todos [ 1 ] . details . url = "ba"
91- o . todos [ 0 ] . tags [ 0 ] = "reactjs"
92- o . todos [ 1 ] . tags . push ( "pff" )
93+ mobx . _allowStateChanges ( true , ( ) => {
94+ o . todos [ 0 ] . details . url = "boe"
95+ o . todos [ 1 ] . details . url = "ba"
96+ o . todos [ 0 ] . tags [ 0 ] = "reactjs"
97+ o . todos [ 1 ] . tags . push ( "pff" )
98+ } )
9399
94100 expect ( mobx . toJS ( o ) ) . toEqual ( {
95101 todos : [
@@ -117,12 +123,14 @@ test("json2", function () {
117123 ab = [ ]
118124 tb = [ ]
119125
120- o . todos . push (
121- mobx . observable ( {
122- title : "test" ,
123- tags : [ "x" ]
124- } )
125- )
126+ mobx . _allowStateChanges ( true , ( ) => {
127+ o . todos . push (
128+ mobx . observable ( {
129+ title : "test" ,
130+ tags : [ "x" ]
131+ } )
132+ )
133+ } )
126134
127135 expect ( mobx . toJS ( o ) ) . toEqual ( {
128136 todos : [
@@ -151,13 +159,16 @@ test("json2", function () {
151159 ab = [ ]
152160 tb = [ ]
153161
154- o . todos [ 1 ] = mobx . observable ( {
155- title : "clean the attic" ,
156- tags : [ "needs sabbatical" ] ,
157- details : {
158- url : "booking.com"
159- }
162+ mobx . _allowStateChanges ( true , ( ) => {
163+ o . todos [ 1 ] = mobx . observable ( {
164+ title : "clean the attic" ,
165+ tags : [ "needs sabbatical" ] ,
166+ details : {
167+ url : "booking.com"
168+ }
169+ } )
160170 } )
171+
161172 expect ( JSON . parse ( JSON . stringify ( o ) ) ) . toEqual ( {
162173 todos : [
163174 {
0 commit comments