fix(ref): should not trigger when setting value to same proxy (#3658)

This commit is contained in:
Yang Mingshan
2021-07-16 04:28:01 +08:00
committed by GitHub
parent f6a5f09a3a
commit 08f504c1b7
2 changed files with 27 additions and 3 deletions

View File

@@ -336,4 +336,24 @@ describe('reactivity/ref', () => {
_trigger!()
expect(dummy).toBe(2)
})
test('should not trigger when setting value to same proxy', () => {
const obj = reactive({ count: 0 })
const a = ref(obj)
const spy1 = jest.fn(() => a.value)
effect(spy1)
a.value = obj
expect(spy1).toBeCalledTimes(1)
const b = shallowRef(obj)
const spy2 = jest.fn(() => b.value)
effect(spy2)
b.value = obj
expect(spy2).toBeCalledTimes(1)
})
})