diff --git a/packages/reactivity/__tests__/reactiveArray.spec.ts b/packages/reactivity/__tests__/reactiveArray.spec.ts index 34be986688f..981d971a71a 100644 --- a/packages/reactivity/__tests__/reactiveArray.spec.ts +++ b/packages/reactivity/__tests__/reactiveArray.spec.ts @@ -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', () => { @@ -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([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', () => {