From: XinPing Wang Date: Sun, 3 May 2020 14:49:23 +0000 (+0800) Subject: test: reactive proto X-Git-Tag: v3.0.0-beta.8~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bab78b648b2db2404a0cffecc268eace507a63b;p=thirdparty%2Fvuejs%2Fcore.git test: reactive proto --- diff --git a/packages/reactivity/__tests__/reactive.spec.ts b/packages/reactivity/__tests__/reactive.spec.ts index eb730ff314..44fc5391df 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: {