Window.location.assign instead of window.location =, so we can test it.

This commit is contained in:
elweyn 2022-01-10 13:56:25 +01:00
parent c08cd7e37c
commit d857ee02a8
2 changed files with 8 additions and 3 deletions

View File

@ -53,13 +53,17 @@ describe('NavBar', () => {
})
describe('logout', () => {
// const assignLocationSpy = jest.fn()
const windowLocationMock = jest.fn()
beforeEach(async () => {
delete window.location
window.location = {
assign: windowLocationMock,
}
await wrapper.findAll('a').at(6).trigger('click')
})
it('redirects to /logout', () => {
expect(routerPushMock).toBeCalledWith('/logout')
expect(windowLocationMock).toBeCalledWith('http://localhost/vue/login')
})
it('dispatches logout to store', () => {

View File

@ -33,7 +33,8 @@ export default {
name: 'navbar',
methods: {
logout() {
window.location = CONFIG.WALLET_URL
window.location.assign(CONFIG.WALLET_URL)
// window.location = CONFIG.WALLET_URL
this.$store.dispatch('logout')
},
wallet() {