]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(reactive): add test case of mutation in original reflecting in observed value...
authorizayl <izayl@163.com>
Tue, 15 Sep 2020 14:49:59 +0000 (22:49 +0800)
committerGitHub <noreply@github.com>
Tue, 15 Sep 2020 14:49:59 +0000 (10:49 -0400)
packages/reactivity/__tests__/reactive.spec.ts

index a7c46451d1e3b7d9609764e568a160b86917cb62..f6fed0230c397fc52693b8f6aa7e0baf2f508ec2 100644 (file)
@@ -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 = {}