feat(reactivity): add isShallow api

This commit is contained in:
Evan You
2022-01-18 09:17:22 +08:00
parent 0c06c748a5
commit 9fda9411ec
9 changed files with 39 additions and 15 deletions

View File

@@ -10,6 +10,7 @@ import {
} from '../src/index'
import { computed } from '@vue/runtime-dom'
import { shallowRef, unref, customRef, triggerRef } from '../src/ref'
import { isShallow } from '../src/reactive'
describe('reactivity/ref', () => {
it('should hold a value', () => {
@@ -227,6 +228,10 @@ describe('reactivity/ref', () => {
expect(dummy).toBe(2)
})
test('shallowRef isShallow', () => {
expect(isShallow(shallowRef({ a: 1 }))).toBe(true)
})
test('isRef', () => {
expect(isRef(ref(1))).toBe(true)
expect(isRef(computed(() => 1))).toBe(true)