Skip to content

Commit

Permalink
test: add a test case
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jun 27, 2024
1 parent 261fb7c commit ee0e829
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 @@ -765,6 +765,21 @@ describe('reactivity/computed', () => {
expect(COMPUTED_SIDE_EFFECT_WARN).toHaveBeenWarned()
})

it('should be recompute 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')

Check failure on line 780 in packages/reactivity/__tests__/computed.spec.ts

View workflow job for this annotation

GitHub Actions / unit-test

packages/reactivity/__tests__/computed.spec.ts > reactivity/computed > should be recompute without being affected by side effects

AssertionError: expected '0,0' to be '1,0' // Object.is equality - Expected + Received - 1,0 + 0,0 ❯ packages/reactivity/__tests__/computed.spec.ts:780:22
})

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

0 comments on commit ee0e829

Please sign in to comment.