Skip to content

Commit

Permalink
test: update types
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jul 19, 2022
1 parent 434139c commit 9030279
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
13 changes: 0 additions & 13 deletions packages/playground/src/router.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createRouter, createWebHistory, RouterView } from 'vue-router'
import type { RouterLinkTyped } from 'vue-router'
import Home from './views/Home.vue'
import Nested from './views/Nested.vue'
import NestedWithId from './views/NestedWithId.vue'
Expand All @@ -16,13 +15,8 @@ import ComponentWithData from './views/ComponentWithData.vue'
import { globalState } from './store'
import { scrollWaiter } from './scrollWaiter'
import RepeatedParams from './views/RepeatedParams.vue'
import { h } from 'vue'
import type { FunctionalComponent } from 'vue'
let removeRoute: (() => void) | undefined

const TransparentWrapper: FunctionalComponent = () => h(RouterView)
TransparentWrapper.displayName = 'NestedView'

export const routerHistory = createWebHistory()
export const router = createRouter({
history: routerHistory,
Expand Down Expand Up @@ -159,7 +153,6 @@ export const router = createRouter({

{
path: '/admin',
component: TransparentWrapper,
children: [
{ path: '', component },
{ path: 'dashboard', component },
Expand All @@ -181,12 +174,6 @@ export const router = createRouter({
},
})

declare module 'vue-router' {
export interface Config {
Router: typeof router
}
}

// router.push({ name: 'user', params: {} })

const delay = (t: number) => new Promise(resolve => setTimeout(resolve, t))
Expand Down
12 changes: 8 additions & 4 deletions packages/router/__tests__/RouterView.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function createRoutes<T extends Record<string, RouteLocationNormalizedLoose>>(

for (let key in routes) {
nonReactiveRoutes[key] = markRaw(routes[key])
nonReactiveRoutes[key].matched.forEach(record => {
record.leaveGuards ??= new Set()
record.updateGuards ??= new Set()
})
}

return nonReactiveRoutes
Expand Down Expand Up @@ -238,7 +242,7 @@ describe('RouterView', () => {
props: any = {}
) {
const route = createMockedRoute(initialRoute)
const wrapper = mount(RouterView as any, {
const wrapper = mount(RouterView, {
props,
global: {
provide: route.provides,
Expand Down Expand Up @@ -439,7 +443,7 @@ describe('RouterView', () => {
props: any = {}
) {
const route = createMockedRoute(initialRoute)
const wrapper = await mount(RouterView as any, {
const wrapper = await mount(RouterView, {
props,
global: {
provide: route.provides,
Expand Down Expand Up @@ -470,7 +474,7 @@ describe('RouterView', () => {
props: any = {}
) {
const route = createMockedRoute(initialRoute)
const wrapper = await mount(RouterView as any, {
const wrapper = await mount(RouterView, {
props,
global: {
provide: route.provides,
Expand Down Expand Up @@ -503,7 +507,7 @@ describe('RouterView', () => {
props: any = {}
) {
const route = createMockedRoute(initialRoute)
const wrapper = await mount(RouterView as any, {
const wrapper = await mount(RouterView, {
props,
global: {
provide: route.provides,
Expand Down
1 change: 1 addition & 0 deletions packages/router/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface RouteRecordViewLoose
'path' | 'name' | 'meta' | 'beforeEnter'
> {
leaveGuards?: any
updateGuards?: any
instances: Record<string, any>
enterCallbacks: Record<string, Function[]>
props: Record<string, _RouteRecordProps>
Expand Down

0 comments on commit 9030279

Please sign in to comment.