]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(reactivity): 100% reactivity coverage (#1299)
author蜗牛老湿 <shengxinjing@users.noreply.github.com>
Thu, 11 Jun 2020 20:55:56 +0000 (04:55 +0800)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2020 20:55:56 +0000 (16:55 -0400)
packages/reactivity/__tests__/reactive.spec.ts
packages/reactivity/__tests__/readonly.spec.ts
packages/reactivity/__tests__/ref.spec.ts

index 800171ef3bf83f09558a3ad25aa202cc56faccc0..cbc8c871cea7eb993ed0a93b974464d2b001209f 100644 (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)
+  })
 })
index 12fb6d0882e36bea40e519768012eb703a6c1021..6e99c589b52fa56eba0e81d42e8bbc54f42000db 100644 (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)
           }
index e0929e53526fb4da93b70fd444acffaf43b84353..952960ac2f65d48627260f53f2ab89a15e42d003 100644 (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