Skip to content

Commit

Permalink
test(reactivity): add tests for reactive and non-reactive objects (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny-117 authored Feb 20, 2025
1 parent 5e776ae commit 604d087
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/reactivity/__tests__/reactive.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isRef, ref } from '../src/ref'
import { isRef, ref, shallowRef } from '../src/ref'
import {
isProxy,
isReactive,
Expand Down Expand Up @@ -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)
})
})

0 comments on commit 604d087

Please sign in to comment.