Skip to content

Commit d2fd005

Browse files
edison1105yyx990803
authored andcommitted
chore: update test
1 parent d05ea4a commit d2fd005

File tree

2 files changed

+3
-41
lines changed

2 files changed

+3
-41
lines changed

packages/reactivity/__tests__/effectScope.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,5 +358,8 @@ describe('reactivity/effect/scope', () => {
358358
await nextTick()
359359
expect(watcherCalls).toBe(3)
360360
expect(cleanupCalls).toBe(1)
361+
362+
expect(scope.effects.length).toBe(0)
363+
expect(scope.cleanups.length).toBe(0)
361364
})
362365
})

packages/reactivity/__tests__/watch.spec.ts

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
type WatchOptions,
66
type WatchScheduler,
77
computed,
8-
effectScope,
98
onWatcherCleanup,
109
ref,
1110
watch,
@@ -278,44 +277,4 @@ describe('watch', () => {
278277

279278
expect(dummy).toEqual([1, 2, 3])
280279
})
281-
282-
test('clean up watchers during effect scope stop', async () => {
283-
const count = ref(0)
284-
const scope = effectScope()
285-
let watcherCalls = 0
286-
let cleanupCalls = 0
287-
288-
scope.run(() => {
289-
const stop1 = watch(count, () => {
290-
watcherCalls++
291-
})
292-
watch(count, (val, old, onCleanup) => {
293-
watcherCalls++
294-
onCleanup(() => {
295-
cleanupCalls++
296-
stop1()
297-
})
298-
})
299-
watch(count, () => {
300-
watcherCalls++
301-
})
302-
})
303-
304-
expect(watcherCalls).toBe(0)
305-
expect(cleanupCalls).toBe(0)
306-
307-
count.value++
308-
await nextTick()
309-
expect(watcherCalls).toBe(3)
310-
expect(cleanupCalls).toBe(0)
311-
312-
scope.stop()
313-
count.value++
314-
await nextTick()
315-
expect(watcherCalls).toBe(3)
316-
expect(cleanupCalls).toBe(1)
317-
318-
expect(scope.effects.length).toBe(0)
319-
expect(scope.cleanups.length).toBe(0)
320-
})
321280
})

0 commit comments

Comments
 (0)