Skip to content

Commit

Permalink
test: apiWatch #12967
Browse files Browse the repository at this point in the history
  • Loading branch information
shangweiwei365 committed Feb 28, 2023
1 parent 51eabb0 commit 18b05e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"build:types": "rimraf temp && tsc --declaration --emitDeclarationOnly --outDir temp && api-extractor run && api-extractor run -c packages/compiler-sfc/api-extractor.json",
"test": "npm run ts-check && npm run test:types && npm run test:unit && npm run test:e2e && npm run test:ssr && npm run test:sfc",
"test:unit": "vitest run test/unit",
"test:watch": "vitest run test/unit/features/v3/apiWatch.spec.ts",
"test:ssr": "npm run build:ssr && vitest run server-renderer",
"test:sfc": "vitest run compiler-sfc",
"test:e2e": "npm run build -- full-prod,server-renderer-basic && vitest run test/e2e",
Expand Down
11 changes: 11 additions & 0 deletions test/unit/features/v3/apiWatch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,4 +1200,15 @@ describe('api: watch', () => {
expect(parentSpy).toHaveBeenCalledTimes(1)
expect(childSpy).toHaveBeenCalledTimes(1)
})

// #12967
test('trigger when adding new property with Vue.set', 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)
})
})

0 comments on commit 18b05e4

Please sign in to comment.