Skip to content

Commit

Permalink
test: improve test case
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed Sep 5, 2024
1 parent 157569d commit cb9c0a5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/reactivity/__tests__/computed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ describe('reactivity/computed', () => {
expect(cValue.value).toBe(1)
})

it('support get previous value', () => {
it('pass oldValue to computed getter', () => {
const count = ref(0)
const preValue = ref()
const cValue = computed(pre => {
preValue.value = pre
const oldValue = ref()
const curValue = computed(pre => {
oldValue.value = pre
return count.value
})
expect(cValue.value).toBe(0)
expect(preValue.value).toBe(undefined)
expect(curValue.value).toBe(0)
expect(oldValue.value).toBe(undefined)
count.value++
expect(cValue.value).toBe(1)
expect(preValue.value).toBe(0)
expect(curValue.value).toBe(1)
expect(oldValue.value).toBe(0)
})

it('should compute lazily', () => {
Expand Down

0 comments on commit cb9c0a5

Please # to comment.