Skip to content

Commit a04df52

Browse files
committed
test(effect): verify cleanupEffect clears multiple dependencies
1 parent a989345 commit a04df52

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Diff for: packages/reactivity/__tests__/effect.spec.ts

+25
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,31 @@ describe('reactivity/effect', () => {
821821
expect(dummy).toBe(3)
822822
})
823823

824+
it('stop with multiple dependencies', () => {
825+
let dummy1, dummy2
826+
const obj1 = reactive({ prop: 1 })
827+
const obj2 = reactive({ prop: 1 })
828+
const runner = effect(() => {
829+
dummy1 = obj1.prop
830+
dummy2 = obj2.prop
831+
})
832+
833+
obj1.prop = 2
834+
expect(dummy1).toBe(2)
835+
836+
obj2.prop = 3
837+
expect(dummy2).toBe(3)
838+
839+
stop(runner)
840+
841+
obj1.prop = 4
842+
obj2.prop = 5
843+
844+
// Check that both dependencies have been cleared
845+
expect(dummy1).toBe(2)
846+
expect(dummy2).toBe(3)
847+
})
848+
824849
// #5707
825850
// when an effect completes its run, it should clear the tracking bits of
826851
// its tracked deps. However, if the effect stops itself, the deps list is

0 commit comments

Comments
 (0)