]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: test initial navigation to /
authorEduardo San Martin Morote <posva13@gmail.com>
Sat, 29 Feb 2020 16:57:55 +0000 (17:57 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Sat, 29 Feb 2020 16:57:55 +0000 (17:57 +0100)
__tests__/router.spec.ts
playground/App.vue
playground/router.ts

index 1f03a15ac3a8ef0160814ce72f2311a35f248fd3..d64dde5bced1d63eb93eab85c3c0adb8c0e64be5 100644 (file)
@@ -70,6 +70,13 @@ describe('Router', () => {
     )
   })
 
+  it('can do initial navigation to /', async () => {
+    const router = createRouter({ history: createMemoryHistory(), routes: [] })
+    expect(router.currentRoute.value).toBe(START_LOCATION_NORMALIZED)
+    await router.push('/')
+    expect(router.currentRoute.value).not.toBe(START_LOCATION_NORMALIZED)
+  })
+
   it('calls history.replace with router.replace', async () => {
     const history = createMemoryHistory()
     const { router } = await newRouter({ history })
index fe0866d1785046548cbf64b0f752ddd62a310430..78823d42aac1c74a7a74d93617806edae5a3e7d4 100644 (file)
@@ -47,7 +47,7 @@
         >
       </li>
       <li>
-        <router-link :to="{ name: 'home', query: { currency: '€uro', é: 'e' } }"
+        <router-link :to="{ path: '/', query: { currency: '€uro', é: 'e' } }"
           >/currency=€uro&é=e (object)</router-link
         >
       </li>
index ee30c59524cb1b5ac2a6453221586a26354815b5..760a2cc7f0cc92e2d36116477092e8b8a4e1aff0 100644 (file)
@@ -18,7 +18,7 @@ export const routerHistory = createWebHistory()
 export const router = createRouter({
   history: routerHistory,
   routes: [
-    { path: '/', component: Home, name: 'home', alias: '/home' },
+    { path: '/', component: Home },
     { path: '/users/:id', name: 'user', component: User },
     { path: '/documents/:id', name: 'docs', component: User },
     { path: encodeURI('/n/€'), name: 'euro', component },