]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: reactive proto
authorXinPing Wang <xinping.wang@hotmail.com>
Sun, 3 May 2020 14:49:23 +0000 (22:49 +0800)
committerEvan You <yyx990803@gmail.com>
Sun, 3 May 2020 19:36:19 +0000 (15:36 -0400)
packages/reactivity/__tests__/reactive.spec.ts

index eb730ff314f3eedbd08526b73119ec512c42150b..44fc5391df1cf35efa8f655ecaf131401a507dc1 100644 (file)
@@ -26,6 +26,20 @@ describe('reactivity/reactive', () => {
     expect(Object.keys(observed)).toEqual(['foo'])
   })
 
+  test('proto', () => {
+    const obj = {}
+    const reactiveObj = reactive(obj)
+    expect(isReactive(reactiveObj)).toBe(true)
+    // read prop of reactiveObject will cause reactiveObj[prop] to be reactive
+    // @ts-ignore
+    const prototype = reactiveObj['__proto__']
+    const otherObj = { data: ['a'] }
+    expect(isReactive(otherObj)).toBe(false)
+    const reactiveOther = reactive(otherObj)
+    expect(isReactive(reactiveOther)).toBe(true)
+    expect(reactiveOther.data[0]).toBe('a')
+  })
+
   test('nested reactives', () => {
     const original = {
       nested: {