Skip to content

Commit 0376b08

Browse files
committed
chore: up vue router
1 parent c1fa625 commit 0376b08

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

__tests__/components.spec.ts

+21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { mount } from '@vue/test-utils'
2+
import { getRouter } from '../src'
3+
import { useRouter } from 'vue-router'
24

35
describe('components', () => {
46
it('stubs router link', async () => {
@@ -24,4 +26,23 @@ describe('components', () => {
2426
`"<a href=\\"/about\\" class=\\"\\">About</a>"`
2527
)
2628
})
29+
30+
it('mounts component', async () => {
31+
const wrapper = mount({
32+
template: `<button @click="navigate()">Home</button>`,
33+
setup() {
34+
const router = useRouter()
35+
function navigate() {
36+
router.push('/')
37+
}
38+
39+
return { navigate }
40+
},
41+
})
42+
43+
await wrapper.get('button').trigger('click')
44+
45+
const router = getRouter()
46+
expect(router.push).toHaveBeenCalledWith('/')
47+
})
2748
})

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"typescript": "^4.7.4",
6464
"unbuild": "^0.7.4",
6565
"vue": "^3.2.37",
66-
"vue-router": "^4.0.16",
66+
"vue-router": "^4.1.0",
6767
"yorkie": "^2.0.0"
6868
},
6969
"gitHooks": {

pnpm-lock.yaml

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/router.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export function createRouterMock(options: RouterMockOptions = {}): RouterMock {
257257
if (record && !runInComponentGuards) {
258258
record.leaveGuards.clear()
259259
record.updateGuards.clear()
260-
Object.values(record.components).forEach((component) => {
260+
Object.values(record.components || {}).forEach((component) => {
261261
// TODO: handle promises?
262262
// @ts-ignore
263263
delete component.beforeRouteUpdate

0 commit comments

Comments
 (0)