Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/dobPublic

Commit17fd60e

Browse files
committed
test
1 parent16813d8 commit17fd60e

File tree

2 files changed

+105
-22
lines changed

2 files changed

+105
-22
lines changed

‎src/observer.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ function actionDecorator(target: any, propertyKey: string, descriptor: PropertyD
307307
* 同时,在此方法中使用到的变量不会触发依赖追踪!
308308
*/
309309
functionrunInAction(fn:()=>any|Promise<any>,debugName?:string){
310-
globalState.event.emit("runInAction",{debugName})
310+
globalState.event.emit("runInAction",debugName)
311311

312312
startBatch()
313313

‎tests/debug.test.ts‎

Lines changed: 104 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,40 +78,42 @@ test("debug out of action", t => {
7878
returnimmediate(()=>t.true(data==="abcde"))
7979
})
8080

81-
test("test callstack",t=>{
82-
startDebug()
81+
test("test callstack",asynct=>{
82+
returnimmediate(async()=>{
83+
startDebug()
8384

84-
@observable
85-
classStore{
86-
publica:any={
87-
b:{
88-
c:{
89-
d:{
90-
e:{
91-
f:"b"
85+
@observable
86+
classStore{
87+
publica:any={
88+
b:{
89+
c:{
90+
d:{
91+
e:{
92+
f:"b"
93+
}
9294
}
9395
}
9496
}
9597
}
9698
}
97-
}
9899

99-
conststore=newStore()
100-
letcallStack:PropertyKey[]=[]
100+
conststore=newStore()
101+
letcallStack: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-
returnimmediate(()=>t.true(callStack.length===6))
111+
returnimmediate(()=>t.true(callStack.length===6))
112+
},10)
111113
})
112114

113115
test("test overflow callstack",asynct=>{
114-
returnimmediate(()=>{
116+
returnimmediate(async()=>{
115117
startDebug()
116118

117119
globalState.getCallstackMaxCount=3
@@ -145,5 +147,86 @@ test("test overflow callstack", async t => {
145147
globalState.getCallstackMaxCount=50
146148

147149
returnimmediate(()=>t.true(callStack.length===3))
148-
},0)
150+
},20)
151+
})
152+
153+
test("test action",asynct=>{
154+
returnimmediate(async()=>{
155+
startDebug()
156+
157+
classCustomAction{
158+
@Actionpublicaction1(){
159+
this.action2()
160+
}
161+
@Actionpublicaction2(){
162+
this.action3()
163+
}
164+
@Actionpublicaction3(){
165+
//
166+
}
167+
}
168+
169+
constaction=newCustomAction()
170+
171+
dobEvent.on("debug",debugInfo=>{
172+
deletedebugInfo.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+
returnimmediate(()=>t.true(true))
203+
},30)
204+
})
205+
206+
test("test delete",asynct=>{
207+
returnimmediate(async()=>{
208+
startDebug()
209+
210+
constdynamicObj=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+
deletedynamicObj.name
229+
230+
returnimmediate(()=>t.true(true))
231+
},40)
149232
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp