]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: fix after change
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 26 Mar 2020 16:49:20 +0000 (17:49 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 26 Mar 2020 16:49:20 +0000 (17:49 +0100)
__tests__/mount.ts

index ac99e772113d29aa98f0bad1f34084c2abc3f3d9..af591679e343bb5c7f99f7cf2f88881cfe320e2b 100644 (file)
@@ -1,7 +1,14 @@
-import { Component, createApp, nextTick } from 'vue'
+import {
+  Component,
+  createApp,
+  nextTick,
+  ComputedRef,
+  reactive,
+  computed,
+} from 'vue'
 import * as runtimeDom from '@vue/runtime-dom'
 import { compile } from '@vue/compiler-dom'
-import { Router } from '../src'
+import { Router, RouteLocationNormalizedResolved } from '../src'
 import { routerKey, routeLocationKey } from '../src/utils/injectionSymbols'
 
 export function mount(
@@ -15,8 +22,19 @@ export function mount(
   const { template, components, ...ComponentWithoutTemplate } = Component
 
   const app = createApp(ComponentWithoutTemplate as any, rootProps)
+
+  const reactiveRoute = {} as {
+    [k in keyof RouteLocationNormalizedResolved]: ComputedRef<
+      RouteLocationNormalizedResolved[k]
+    >
+  }
+  for (let key in router.currentRoute.value) {
+    // @ts-ignore: the key matches
+    reactiveRoute[key] = computed(() => router.currentRoute.value[key])
+  }
+
   app.provide(routerKey, router)
-  app.provide(routeLocationKey, router.currentRoute)
+  app.provide(routeLocationKey, reactive(reactiveRoute))
 
   for (const componentName in components) {
     app.component(componentName, components[componentName])