From: izayl Date: Tue, 15 Sep 2020 14:49:59 +0000 (+0800) Subject: test(reactive): add test case of mutation in original reflecting in observed value... X-Git-Tag: v3.0.0-rc.11~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=848ccf56fb55149728055ef21eed133a4503a5d9;p=thirdparty%2Fvuejs%2Fcore.git test(reactive): add test case of mutation in original reflecting in observed value (#2118) --- diff --git a/packages/reactivity/__tests__/reactive.spec.ts b/packages/reactivity/__tests__/reactive.spec.ts index a7c46451d1..f6fed0230c 100644 --- a/packages/reactivity/__tests__/reactive.spec.ts +++ b/packages/reactivity/__tests__/reactive.spec.ts @@ -113,6 +113,19 @@ describe('reactivity/reactive', () => { expect('foo' in original).toBe(false) }) + test('original value change should reflect in observed value (Object)', () => { + const original: any = { foo: 1 } + const observed = reactive(original) + // set + original.bar = 1 + expect(original.bar).toBe(1) + expect(observed.bar).toBe(1) + // delete + delete original.foo + expect('foo' in original).toBe(false) + expect('foo' in observed).toBe(false) + }) + test('setting a property with an unobserved value should wrap with reactive', () => { const observed = reactive<{ foo?: object }>({}) const raw = {}