feat(reactivity): add isShallow api
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { isReactive, reactive, shallowReactive } from '../src/reactive'
|
||||
import {
|
||||
isReactive,
|
||||
isShallow,
|
||||
reactive,
|
||||
shallowReactive,
|
||||
shallowReadonly
|
||||
} from '../src/reactive'
|
||||
|
||||
import { effect } from '../src/effect'
|
||||
|
||||
@@ -24,6 +30,11 @@ describe('shallowReactive', () => {
|
||||
expect(isReactive(reactiveProxy.foo)).toBe(true)
|
||||
})
|
||||
|
||||
test('isShallow', () => {
|
||||
expect(isShallow(shallowReactive({}))).toBe(true)
|
||||
expect(isShallow(shallowReadonly({}))).toBe(true)
|
||||
})
|
||||
|
||||
describe('collections', () => {
|
||||
test('should be reactive', () => {
|
||||
const shallowSet = shallowReactive(new Set())
|
||||
|
||||
Reference in New Issue
Block a user