)
})
- it('triggers erros caused by new navigations of a next(redirect) trigered by history', async () => {
+ it('triggers errors caused by new navigations of a next(redirect) triggered by history', async () => {
const { router, history } = createRouter()
await router.push('/p/0')
await router.push('/p/other')
-import { RouterOptions, createRouter as newRouter } from '../../src/router'
import fakePromise from 'faked-promise'
-import { createDom, noGuard } from '../utils'
+import { createDom, noGuard, newRouter as createRouter } from '../utils'
import { RouteRecordRaw, NavigationGuard } from '../../src/types'
-import { createWebHistory } from '../../src'
-
-function createRouter(
- options: Partial<RouterOptions> & { routes: RouteRecordRaw[] }
-) {
- return newRouter({
- history: createWebHistory(),
- ...options,
- })
-}
const Home = { template: `<div>Home</div>` }
const Foo = { template: `<div>Foo</div>` }
-import { RouterOptions, createRouter as newRouter } from '../../src/router'
-import { createDom, noGuard } from '../utils'
+import { createDom, noGuard, newRouter as createRouter } from '../utils'
import { RouteRecordRaw } from '../../src/types'
-import { createWebHistory } from '../../src'
-
-// TODO: refactor in utils
-function createRouter(
- options: Partial<RouterOptions> & { routes: RouteRecordRaw[] }
-) {
- return newRouter({
- history: createWebHistory(),
- ...options,
- })
-}
const Home = { template: `<div>Home</div>` }
const Foo = { template: `<div>Foo</div>` }
import fakePromise from 'faked-promise'
-import { createDom, noGuard } from '../utils'
-import { createRouter as newRouter, createWebHistory } from '../../src'
+import { createDom, noGuard, newRouter as createRouter } from '../utils'
import { RouteRecordRaw } from '../../src/types'
-function createRouter(
- options: Partial<import('../../src/router').RouterOptions> & {
- routes: import('../../src/types').RouteRecordRaw[]
- }
-) {
- return newRouter({
- history: createWebHistory(),
- ...options,
- })
-}
-
const Home = { template: `<div>Home</div>` }
const Foo = { template: `<div>Foo</div>` }
-import { createDom } from '../utils'
-import { createWebHistory, createRouter as newRouter } from '../../src'
+import { createDom, newRouter as createRouter } from '../utils'
import { RouteRecordRaw } from 'src/types'
-function createRouter(
- options: Partial<import('../../src/router').RouterOptions> & {
- routes: import('../../src/types').RouteRecordRaw[]
- }
-) {
- return newRouter({
- history: createWebHistory(),
- ...options,
- })
-}
-
const Home = { template: `<div>Home</div>` }
const Foo = { template: `<div>Foo</div>` }
const Nested = { template: `<div>Nested<router-view/></div>` }
-import { RouterOptions } from '../../src/router'
import fakePromise from 'faked-promise'
-import { createDom, tick, noGuard } from '../utils'
+import { createDom, tick, noGuard, newRouter as createRouter } from '../utils'
import { RouteRecordRaw, RouteLocationRaw } from '../../src/types'
-import { createWebHistory, createRouter as newRouter } from '../../src'
-
-function createRouter(
- options: Partial<RouterOptions> & { routes: RouteRecordRaw[] }
-) {
- return newRouter({
- history: createWebHistory(),
- ...options,
- })
-}
const Home = { template: `<div>Home</div>` }
const Foo = { template: `<div>Foo</div>` }
-import { RouterOptions, createRouter as newRouter } from '../../src/router'
import fakePromise from 'faked-promise'
-import { createDom, noGuard, tick } from '../utils'
+import { createDom, noGuard, tick, newRouter as createRouter } from '../utils'
import { RouteRecordRaw } from '../../src/types'
-import { createWebHistory } from '../../src'
-
-function createRouter(
- options: Partial<RouterOptions> & { routes: RouteRecordRaw[] }
-) {
- return newRouter({
- history: createWebHistory(),
- ...options,
- })
-}
const Home = { template: `<div>Home</div>` }
const Foo = { template: `<div>Foo</div>` }
expect(spy).toHaveBeenCalledWith(START, normaliezedLoc, {
direction: 'back',
distance: -1,
- // TODO: should be something else
type: 'pop',
})
history.forward()
expect(spy).toHaveBeenLastCalledWith(normaliezedLoc, START, {
direction: 'forward',
distance: 1,
- // TODO: should be something else
type: 'pop',
})
})
matchParams('/a/:a(?:b-([^/]+\\)?)', '/a/b-one', {
a: 'one',
})
+ matchParams('/a/:a(?:b-([^/]+\\)?)', '/a/b-', {
+ a: '',
+ })
+ matchParams('/a/:a(?:b-([^/]+\\))', '/a/b-one', {
+ a: 'one',
+ })
})
it('catch all', () => {
props: false,
})
})
-
- // TODO: move to router
- it.todo('beforeEnter is called with the string redirect')
-
- it.todo('beforeEnter is called with object redirect')
-
- it.todo('function redirect is invoked by beforeEnter')
})
RouteLocationNormalized,
_RouteRecordBase,
RouteComponent,
+ RouteRecordRaw,
} from '../src/types'
import { h, resolveComponent, ComponentOptions } from 'vue'
+import { RouterOptions, createWebHistory, createRouter } from '../src'
export const tick = (time?: number) =>
new Promise(resolve => {
},
} as RouteComponent,
}
+
+export function newRouter(
+ options: Partial<RouterOptions> & { routes: RouteRecordRaw[] }
+) {
+ return createRouter({
+ history: options.history || createWebHistory(),
+ ...options,
+ })
+}