Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 22, 2024
1 parent af9f4f6 commit 4592b57
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/reactivity/__tests__/computed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,4 +1029,19 @@ describe('reactivity/computed', () => {
state.a++
expect(p.value).toBe(3)
})

test('computed dep cleanup should not cause property dep to be deleted', () => {
const toggle = ref(true)
const state = reactive({ a: 1 })
const p = computed(() => {
return toggle.value ? state.a : 111
})
const pp = computed(() => state.a)
effect(() => p.value)

expect(pp.value).toBe(1)
toggle.value = false
state.a++
expect(pp.value).toBe(2)
})
})

1 comment on commit 4592b57

@lehni
Copy link
Contributor

@lehni lehni commented on 4592b57 Sep 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks for the test-case @yyx990803

Please sign in to comment.