From 8bab78b648b2db2404a0cffecc268eace507a63b Mon Sep 17 00:00:00 2001 From: XinPing Wang Date: Sun, 3 May 2020 22:49:23 +0800 Subject: [PATCH] test: reactive proto --- packages/reactivity/__tests__/reactive.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/reactivity/__tests__/reactive.spec.ts b/packages/reactivity/__tests__/reactive.spec.ts index eb730ff3..44fc5391 100644 --- a/packages/reactivity/__tests__/reactive.spec.ts +++ b/packages/reactivity/__tests__/reactive.spec.ts @@ -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: {