Skip to content

Commit

Permalink
test(reactivity): add a failed test for computed (#11243)
Browse files Browse the repository at this point in the history
to avoid regressions like in #11135
  • Loading branch information
johnsoncodehk authored Jun 28, 2024
1 parent b1d1f44 commit ad22879
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/reactivity/__tests__/computed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,22 @@ describe('reactivity/computed', () => {
expect(COMPUTED_SIDE_EFFECT_WARN).toHaveBeenWarned()
})

it('should be recomputed without being affected by side effects', () => {
const v = ref(0)
const c1 = computed(() => {
v.value = 1
return 0
})
const c2 = computed(() => {
return v.value + ',' + c1.value
})

expect(c2.value).toBe('0,0')
v.value = 1
expect(c2.value).toBe('1,0')
expect(COMPUTED_SIDE_EFFECT_WARN).toHaveBeenWarned()
})

it('debug: onTrigger (ref)', () => {
let events: DebuggerEvent[] = []
const onTrigger = vi.fn((e: DebuggerEvent) => {
Expand Down

0 comments on commit ad22879

Please sign in to comment.