Skip to content

Commit

Permalink
test(errors): test onError for lazy import
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jun 1, 2021
1 parent 20f4580 commit 9dc994a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion __tests__/errors.spec.ts
Expand Up @@ -21,6 +21,7 @@ const routes: RouteRecordRaw[] = [
{ path: '/foo', component: components.Foo, name: 'Foo' },
// prevent the log of no match warnings
{ path: '/:pathMatch(.*)', component: components.Home },
{ path: '/async', component: () => Promise.reject('failed') },
]

const onError = jest.fn()
Expand Down Expand Up @@ -52,6 +53,10 @@ describe('Errors & Navigation failures', () => {
)
})

it('lazy loading reject', async () => {
await testError(true, 'failed', '/async')
})

it('Duplicated navigation triggers afterEach', async () => {
let expectedFailure = expect.objectContaining({
type: NavigationFailureType.duplicated,
Expand Down Expand Up @@ -315,7 +320,7 @@ describe('isNavigationFailure', () => {

async function testError(
nextArgument: any | NavigationGuard,
expectedError: Error | void = undefined,
expectedError: any = undefined,
to: RouteLocationRaw = '/foo'
) {
const { router } = createRouter()
Expand Down

0 comments on commit 9dc994a

Please sign in to comment.