|
|
@@ -1200,4 +1200,35 @@ describe('api: watch', () => {
|
|
|
expect(parentSpy).toHaveBeenCalledTimes(1)
|
|
|
expect(childSpy).toHaveBeenCalledTimes(1)
|
|
|
})
|
|
|
+
|
|
|
+ // #12967
|
|
|
+ test('trigger when adding new property with Vue.set (getter)', async () => {
|
|
|
+ const spy = vi.fn()
|
|
|
+ const r = reactive({ exist: 5 })
|
|
|
+ watch(() => r, spy, { deep: true })
|
|
|
+ set(r, 'add', 1)
|
|
|
+
|
|
|
+ await nextTick()
|
|
|
+ expect(spy).toHaveBeenCalledTimes(1)
|
|
|
+ })
|
|
|
+
|
|
|
+ test('trigger when adding new property with Vue.set (getter in array source)', async () => {
|
|
|
+ const spy = vi.fn()
|
|
|
+ const r = reactive({ exist: 5 })
|
|
|
+ watch([() => r], spy, { deep: true })
|
|
|
+ set(r, 'add', 1)
|
|
|
+
|
|
|
+ await nextTick()
|
|
|
+ expect(spy).toHaveBeenCalledTimes(1)
|
|
|
+ })
|
|
|
+
|
|
|
+ test('trigger when adding new property with Vue.set (reactive in array source)', async () => {
|
|
|
+ const spy = vi.fn()
|
|
|
+ const r = reactive({ exist: 5 })
|
|
|
+ watch([r], spy, { deep: true })
|
|
|
+ set(r, 'add', 1)
|
|
|
+
|
|
|
+ await nextTick()
|
|
|
+ expect(spy).toHaveBeenCalledTimes(1)
|
|
|
+ })
|
|
|
})
|