fix tests

This commit is contained in:
Ulf Gebhardt 2021-11-20 17:01:28 +01:00
parent b6400d3c8d
commit 573d998533
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
3 changed files with 18 additions and 7 deletions

View File

@ -30,7 +30,7 @@ describe('navigation guards', () => {
}) })
describe('authorization', () => { describe('authorization', () => {
const navGuard = router.beforeHooks[0] const navGuard = router.beforeHooks[2]
const next = jest.fn() const next = jest.fn()
it('redirects to login when not authorized', () => { it('redirects to login when not authorized', () => {

View File

@ -49,8 +49,8 @@ describe('router', () => {
expect(routes.find((r) => r.path === '/').redirect()).toEqual({ path: '/login' }) expect(routes.find((r) => r.path === '/').redirect()).toEqual({ path: '/login' })
}) })
it('has fourteen routes defined', () => { it('has fifteen routes defined', () => {
expect(routes).toHaveLength(14) expect(routes).toHaveLength(15)
}) })
describe('overview', () => { describe('overview', () => {

View File

@ -148,11 +148,12 @@ describe('Vuex store', () => {
}, },
hasElopage: false, hasElopage: false,
publisherId: 1234, publisherId: 1234,
isAdmin: true,
} }
it('calls ten commits', () => { it('calls eleven commits', () => {
login({ commit, state }, commitedData) login({ commit, state }, commitedData)
expect(commit).toHaveBeenCalledTimes(10) expect(commit).toHaveBeenCalledTimes(11)
}) })
it('commits email', () => { it('commits email', () => {
@ -204,15 +205,20 @@ describe('Vuex store', () => {
login({ commit, state }, commitedData) login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(10, 'publisherId', 1234) expect(commit).toHaveBeenNthCalledWith(10, 'publisherId', 1234)
}) })
it('commits isAdmin', () => {
login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(11, 'isAdmin', true)
})
}) })
describe('logout', () => { describe('logout', () => {
const commit = jest.fn() const commit = jest.fn()
const state = {} const state = {}
it('calls ten commits', () => { it('calls eleven commits', () => {
logout({ commit, state }) logout({ commit, state })
expect(commit).toHaveBeenCalledTimes(10) expect(commit).toHaveBeenCalledTimes(11)
}) })
it('commits token', () => { it('commits token', () => {
@ -265,6 +271,11 @@ describe('Vuex store', () => {
expect(commit).toHaveBeenNthCalledWith(10, 'publisherId', null) expect(commit).toHaveBeenNthCalledWith(10, 'publisherId', null)
}) })
it('commits isAdmin', () => {
logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(11, 'isAdmin', false)
})
// how to get this working? // how to get this working?
it.skip('calls localStorage.clear()', () => { it.skip('calls localStorage.clear()', () => {
const clearStorageMock = jest.fn() const clearStorageMock = jest.fn()