From 848ccf56fb55149728055ef21eed133a4503a5d9 Mon Sep 17 00:00:00 2001 From: izayl Date: Tue, 15 Sep 2020 22:49:59 +0800 Subject: [PATCH] test(reactive): add test case of mutation in original reflecting in observed value (#2118) --- packages/reactivity/__tests__/reactive.spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/reactivity/__tests__/reactive.spec.ts b/packages/reactivity/__tests__/reactive.spec.ts index a7c46451d1e..f6fed0230c3 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 = {}