diff --git a/frontend/src/routes/guards.test.js b/frontend/src/routes/guards.test.js index cf366eac8..f271c5427 100644 --- a/frontend/src/routes/guards.test.js +++ b/frontend/src/routes/guards.test.js @@ -30,7 +30,7 @@ describe('navigation guards', () => { }) describe('authorization', () => { - const navGuard = router.beforeHooks[0] + const navGuard = router.beforeHooks[2] const next = jest.fn() it('redirects to login when not authorized', () => { diff --git a/frontend/src/routes/router.test.js b/frontend/src/routes/router.test.js index df4f9c229..cd26b6f6b 100644 --- a/frontend/src/routes/router.test.js +++ b/frontend/src/routes/router.test.js @@ -49,8 +49,8 @@ describe('router', () => { expect(routes.find((r) => r.path === '/').redirect()).toEqual({ path: '/login' }) }) - it('has fourteen routes defined', () => { - expect(routes).toHaveLength(14) + it('has fifteen routes defined', () => { + expect(routes).toHaveLength(15) }) describe('overview', () => { diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js index bdb98d03b..829678b44 100644 --- a/frontend/src/store/store.test.js +++ b/frontend/src/store/store.test.js @@ -148,11 +148,12 @@ describe('Vuex store', () => { }, hasElopage: false, publisherId: 1234, + isAdmin: true, } - it('calls ten commits', () => { + it('calls eleven commits', () => { login({ commit, state }, commitedData) - expect(commit).toHaveBeenCalledTimes(10) + expect(commit).toHaveBeenCalledTimes(11) }) it('commits email', () => { @@ -204,15 +205,20 @@ describe('Vuex store', () => { login({ commit, state }, commitedData) expect(commit).toHaveBeenNthCalledWith(10, 'publisherId', 1234) }) + + it('commits isAdmin', () => { + login({ commit, state }, commitedData) + expect(commit).toHaveBeenNthCalledWith(11, 'isAdmin', true) + }) }) describe('logout', () => { const commit = jest.fn() const state = {} - it('calls ten commits', () => { + it('calls eleven commits', () => { logout({ commit, state }) - expect(commit).toHaveBeenCalledTimes(10) + expect(commit).toHaveBeenCalledTimes(11) }) it('commits token', () => { @@ -265,6 +271,11 @@ describe('Vuex store', () => { expect(commit).toHaveBeenNthCalledWith(10, 'publisherId', null) }) + it('commits isAdmin', () => { + logout({ commit, state }) + expect(commit).toHaveBeenNthCalledWith(11, 'isAdmin', false) + }) + // how to get this working? it.skip('calls localStorage.clear()', () => { const clearStorageMock = jest.fn()