From d857ee02a8a0db7ab3fc7c20b0ea981d4d5aba9d Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 10 Jan 2022 13:56:25 +0100 Subject: [PATCH] Window.location.assign instead of window.location =, so we can test it. --- admin/src/components/NavBar.spec.js | 8 ++++++-- admin/src/components/NavBar.vue | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/admin/src/components/NavBar.spec.js b/admin/src/components/NavBar.spec.js index 6871cb4f7..621ba0eb9 100644 --- a/admin/src/components/NavBar.spec.js +++ b/admin/src/components/NavBar.spec.js @@ -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', () => { diff --git a/admin/src/components/NavBar.vue b/admin/src/components/NavBar.vue index 11e9153a3..c1c315755 100644 --- a/admin/src/components/NavBar.vue +++ b/admin/src/components/NavBar.vue @@ -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() {