mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
test window location assign
This commit is contained in:
parent
c1381da240
commit
599eaf495a
@ -160,25 +160,26 @@ describe('SideBar', () => {
|
||||
it('is not visible when not an admin', () => {
|
||||
expect(wrapper.findAll('li').at(1).text()).not.toBe('admin_area')
|
||||
})
|
||||
|
||||
describe('logged in as admin', () => {
|
||||
const assignLocationSpy = jest.fn()
|
||||
beforeEach(() => {
|
||||
mocks.$store.state.isAdmin = true
|
||||
mocks.$store.state.token = 'valid token'
|
||||
// const { location } = window;
|
||||
delete window.location
|
||||
window.location = {}
|
||||
Object.defineProperty(window, 'location', assignLocationSpy)
|
||||
mocks.$store.state.token = 'valid-token'
|
||||
window.location.assign = assignLocationSpy
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('is visible', () => {
|
||||
expect(wrapper.findAll('li').at(1).text()).toBe('admin_area')
|
||||
})
|
||||
it.skip('opens a new window when clicked', async () => {
|
||||
|
||||
it('opens a new window when clicked', async () => {
|
||||
wrapper.findAll('li').at(1).find('a').trigger('click')
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(assignLocationSpy).toHaveBeenCalledWith('peter')
|
||||
expect(assignLocationSpy).toHaveBeenCalledWith(
|
||||
'http://localhost/admin/authenticate?token=valid-token',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -122,7 +122,7 @@ export default {
|
||||
this.$emit('logout')
|
||||
},
|
||||
admin() {
|
||||
window.location = CONFIG.ADMIN_AUTH_URL.replace('$1', this.$store.state.token)
|
||||
window.location.assign(CONFIG.ADMIN_AUTH_URL.replace('$1', this.$store.state.token))
|
||||
this.$store.dispatch('logout') // logout without redirect
|
||||
},
|
||||
getElopageLink() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user