@@ -78,40 +78,42 @@ test("debug out of action", t => {
7878return immediate ( ( ) => t . true ( data === "abcde" ) )
7979} )
8080
81- test ( "test callstack" , t => {
82- startDebug ( )
81+ test ( "test callstack" , async t => {
82+ return immediate ( async ( ) => {
83+ startDebug ( )
8384
84- @observable
85- class Store {
86- public a :any = {
87- b :{
88- c :{
89- d :{
90- e :{
91- f :"b"
85+ @observable
86+ class Store {
87+ public a :any = {
88+ b :{
89+ c :{
90+ d :{
91+ e :{
92+ f :"b"
93+ }
9294}
9395}
9496}
9597}
9698}
97- }
9899
99- const store = new Store ( )
100- let callStack :PropertyKey [ ] = [ ]
100+ const store = new Store ( )
101+ let callStack :PropertyKey [ ] = [ ]
101102
102- dobEvent . on ( "debug" , debugInfo => {
103- callStack = debugInfo . changeList [ 0 ] . callStack
104- } )
103+ dobEvent . on ( "debug" , debugInfo => {
104+ callStack = debugInfo . changeList [ 0 ] . callStack
105+ } )
105106
106- store . a . b . c . d . e . f = "d"
107+ store . a . b . c . d . e . f = "d"
107108
108- stopDebug ( )
109+ stopDebug ( )
109110
110- return immediate ( ( ) => t . true ( callStack . length === 6 ) )
111+ return immediate ( ( ) => t . true ( callStack . length === 6 ) )
112+ } , 10 )
111113} )
112114
113115test ( "test overflow callstack" , async t => {
114- return immediate ( ( ) => {
116+ return immediate ( async ( ) => {
115117startDebug ( )
116118
117119globalState . getCallstackMaxCount = 3
@@ -145,5 +147,86 @@ test("test overflow callstack", async t => {
145147globalState . getCallstackMaxCount = 50
146148
147149return immediate ( ( ) => t . true ( callStack . length === 3 ) )
148- } , 0 )
150+ } , 20 )
151+ } )
152+
153+ test ( "test action" , async t => {
154+ return immediate ( async ( ) => {
155+ startDebug ( )
156+
157+ class CustomAction {
158+ @Action public action1 ( ) {
159+ this . action2 ( )
160+ }
161+ @Action public action2 ( ) {
162+ this . action3 ( )
163+ }
164+ @Action public action3 ( ) {
165+ //
166+ }
167+ }
168+
169+ const action = new CustomAction ( )
170+
171+ dobEvent . on ( "debug" , debugInfo => {
172+ delete debugInfo . id
173+ t . deepEqual ( debugInfo , {
174+ name :"CustomAction.action1" ,
175+ changeList :[
176+ {
177+ type :"action" ,
178+ action :{
179+ name :"CustomAction.action2" ,
180+ changeList :[
181+ {
182+ type :"action" ,
183+ action :{
184+ name :"CustomAction.action3" ,
185+ changeList :[ ] ,
186+ type :"action"
187+ }
188+ }
189+ ] ,
190+ type :"action"
191+ }
192+ }
193+ ] ,
194+ type :"action"
195+ } )
196+ } )
197+
198+ action . action1 ( )
199+
200+ stopDebug ( )
201+
202+ return immediate ( ( ) => t . true ( true ) )
203+ } , 30 )
204+ } )
205+
206+ test ( "test delete" , async t => {
207+ return immediate ( async ( ) => {
208+ startDebug ( )
209+
210+ const dynamicObj = observable ( { name :"b" } )
211+
212+ dobEvent . on ( "debug" , debugInfo => {
213+ t . deepEqual ( debugInfo , {
214+ name :null ,
215+ changeList :[
216+ {
217+ type :"delete" ,
218+ callStack :[
219+ "Object"
220+ ] ,
221+ key :"name"
222+ }
223+ ] ,
224+ type :"isolated"
225+ } )
226+ } )
227+
228+ delete dynamicObj . name
229+
230+ return immediate ( ( ) => t . true ( true ) )
231+ } , 40 )
149232} )