forked from AkkomaGang/admin-fe
Replace router push with the one that catches errors
This commit is contained in:
parent
5ca76701c2
commit
6722a9e34a
2 changed files with 14 additions and 0 deletions
|
@ -3,6 +3,19 @@ import Router from 'vue-router'
|
|||
|
||||
Vue.use(Router)
|
||||
|
||||
const originalPush = Router.prototype.push
|
||||
Router.prototype.push = function push(location, onResolve, onReject) {
|
||||
if (onResolve || onReject) { return originalPush.call(this, location, onResolve, onReject) }
|
||||
return originalPush.call(this, location).catch((err) => {
|
||||
if (Router.isNavigationFailure(err)) {
|
||||
// resolve err
|
||||
return err
|
||||
}
|
||||
// rethrow error
|
||||
return Promise.reject(err)
|
||||
})
|
||||
}
|
||||
|
||||
/* Layout */
|
||||
import Layout from '@/views/layout/Layout'
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ localVue.use(VueRouter)
|
|||
localVue.use(Element)
|
||||
|
||||
jest.mock('@/api/reports')
|
||||
jest.mock('@/api/settings')
|
||||
|
||||
describe('Log out', () => {
|
||||
let store
|
||||
|
|
Loading…
Reference in a new issue