Skip to content

Commit 4592b57

Browse files
committed
test: add test case
1 parent af9f4f6 commit 4592b57

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/reactivity/__tests__/computed.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,4 +1029,19 @@ describe('reactivity/computed', () => {
10291029
state.a++
10301030
expect(p.value).toBe(3)
10311031
})
1032+
1033+
test('computed dep cleanup should not cause property dep to be deleted', () => {
1034+
const toggle = ref(true)
1035+
const state = reactive({ a: 1 })
1036+
const p = computed(() => {
1037+
return toggle.value ? state.a : 111
1038+
})
1039+
const pp = computed(() => state.a)
1040+
effect(() => p.value)
1041+
1042+
expect(pp.value).toBe(1)
1043+
toggle.value = false
1044+
state.a++
1045+
expect(pp.value).toBe(2)
1046+
})
10321047
})

0 commit comments

Comments
 (0)