diff --git a/frontend/src/components/SidebarPlugin/SideBar.spec.js b/frontend/src/components/SidebarPlugin/SideBar.spec.js index 8204eb604..0a3b0ec1a 100644 --- a/frontend/src/components/SidebarPlugin/SideBar.spec.js +++ b/frontend/src/components/SidebarPlugin/SideBar.spec.js @@ -24,6 +24,7 @@ describe('SideBar', () => { hasElopage: false, }, commit: jest.fn(), + dispatch: jest.fn(), }, $i18n: { locale: 'en', @@ -154,6 +155,33 @@ describe('SideBar', () => { expect(wrapper.emitted('logout')).toEqual([[]]) }) }) + + describe('admin-area', () => { + 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) + wrapper = Wrapper() + }) + + it('is visible', () => { + expect(wrapper.findAll('li').at(1).text()).toBe('admin_area') + }) + it.skip('opens a new window when clicked', async () => { + wrapper.findAll('li').at(1).find('a').trigger('click') + await wrapper.vm.$nextTick() + expect(assignLocationSpy).toHaveBeenCalledWith('peter') + }) + }) + }) }) }) }) diff --git a/frontend/src/components/SidebarPlugin/SideBar.vue b/frontend/src/components/SidebarPlugin/SideBar.vue index 8277b17eb..9cf6b6185 100755 --- a/frontend/src/components/SidebarPlugin/SideBar.vue +++ b/frontend/src/components/SidebarPlugin/SideBar.vue @@ -50,14 +50,14 @@