Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
noootwo committed Nov 19, 2024
1 parent 375b0b3 commit eccd16e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/reactivity/__tests__/reactiveArray.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { type ComputedRef, computed } from '../src/computed'
import { isReactive, reactive, shallowReactive, toRaw } from '../src/reactive'
import { isRef, ref } from '../src/ref'
import { isRef, ref, toRef, triggerRef } from '../src/ref'
import { effect } from '../src/effect'
import { getDepFromReactive } from '../src/dep'

describe('reactivity/reactive/Array', () => {
test('should make Array reactive', () => {
Expand Down Expand Up @@ -281,10 +280,14 @@ describe('reactivity/reactive/Array', () => {
})

// #12427
test('get reactive array dep', () => {
test('trigger the ref that is created by toRef from a reactive Array', () => {
const array = reactive<number[]>([1])
effect(() => array[0])
expect(getDepFromReactive(toRaw(array), 0)).toBeDefined()
const first = toRef(array, 0)
const fn = vi.fn()
effect(() => fn(first.value))
expect(fn).toHaveBeenCalledTimes(1)
triggerRef(first)
expect(fn).toHaveBeenCalledTimes(2)
})

describe('Array methods w/ refs', () => {
Expand Down

0 comments on commit eccd16e

Please sign in to comment.