From: Sunny <73089592+Sunny-117@users.noreply.github.com> Date: Thu, 20 Feb 2025 09:00:31 +0000 (+0800) Subject: test(reactivity): add tests for reactive and non-reactive objects (#12576) X-Git-Tag: v3.5.14~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=604d08760ee5b01772bc33cefd89ebdca9bb1b82;p=thirdparty%2Fvuejs%2Fcore.git test(reactivity): add tests for reactive and non-reactive objects (#12576) --- diff --git a/packages/reactivity/__tests__/reactive.spec.ts b/packages/reactivity/__tests__/reactive.spec.ts index a23f2066f2..a3ba6a39c1 100644 --- a/packages/reactivity/__tests__/reactive.spec.ts +++ b/packages/reactivity/__tests__/reactive.spec.ts @@ -1,4 +1,4 @@ -import { isRef, ref } from '../src/ref' +import { isRef, ref, shallowRef } from '../src/ref' import { isProxy, isReactive, @@ -426,4 +426,17 @@ describe('reactivity/reactive', () => { map.set(void 0, 1) expect(c.value).toBe(1) }) + + test('should return true for reactive objects', () => { + expect(isReactive(reactive({}))).toBe(true) + expect(isReactive(readonly(reactive({})))).toBe(true) + expect(isReactive(ref({}).value)).toBe(true) + expect(isReactive(readonly(ref({})).value)).toBe(true) + expect(isReactive(shallowReactive({}))).toBe(true) + }) + + test('should return false for non-reactive objects', () => { + expect(isReactive(ref(true))).toBe(false) + expect(isReactive(shallowRef({}).value)).toBe(false) + }) })