test(reactivity): 100% reactivity coverage (#1299)

This commit is contained in:
蜗牛老湿 2020-06-12 04:55:56 +08:00 committed by GitHub
parent 3fafc3b3ac
commit 426803046f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -177,4 +177,13 @@ describe('reactivity/reactive', () => {
})
expect(isReactive(obj.foo)).toBe(false)
})
test('should not observe objects with __v_skip', () => {
const original = {
foo: 1,
__v_skip: true
}
const observed = reactive(original)
expect(isReactive(observed)).toBe(false)
})
})

View File

@ -214,6 +214,7 @@ describe('reactivity/readonly', () => {
const key2 = {}
const original = new Collection([[key1, {}], [key2, {}]])
const wrapped: any = readonly(original)
expect(wrapped.size).toBe(2)
for (const [key, value] of wrapped) {
expect(isReadonly(key)).toBe(true)
expect(isReadonly(value)).toBe(true)
@ -267,6 +268,7 @@ describe('reactivity/readonly', () => {
test('should retrieve readonly values on iteration', () => {
const original = new Collection([{}, {}])
const wrapped: any = readonly(original)
expect(wrapped.size).toBe(2)
for (const value of wrapped) {
expect(isReadonly(value)).toBe(true)
}

View File

@ -277,6 +277,12 @@ describe('reactivity/ref', () => {
expect(dummyY).toBe(5)
})
test('toRefs pass a reactivity object', () => {
console.warn = jest.fn()
const obj = { x: 1 }
toRefs(obj)
expect(console.warn).toBeCalled()
})
test('customRef', () => {
let value = 1
let _trigger: () => void