]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(effect): add test for json methods (#371)
author夜宴 <1996yeyan@gmail.com>
Fri, 25 Oct 2019 14:17:31 +0000 (09:17 -0500)
committerEvan You <yyx990803@gmail.com>
Fri, 25 Oct 2019 14:17:31 +0000 (10:17 -0400)
packages/reactivity/__tests__/effect.spec.ts

index 9ddd8e059f720a6bfb5f71b2880d4d4b496fbd52..ec66c2b2c23cafa2cad44f51244bcf7cec2cc1a3 100644 (file)
@@ -515,6 +515,16 @@ describe('reactivity/effect', () => {
     expect(childSpy).toHaveBeenCalledTimes(5)
   })
 
+  it('should observe json methods', () => {
+    let dummy = <Record<string, number>>{}
+    const obj = reactive<Record<string, number>>({})
+    effect(() => {
+      dummy = JSON.parse(JSON.stringify(obj))
+    })
+    obj.a = 1
+    expect(dummy.a).toBe(1)
+  })
+
   it('should observe class method invocations', () => {
     class Model {
       count: number