From bb0a0d607cee1347856c5b023fd6c1fc66916ee2 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 11 May 2021 20:09:32 +0200 Subject: [PATCH] finish tests for sidebar --- .../components/SidebarPlugin/SideBar.spec.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/SidebarPlugin/SideBar.spec.js b/frontend/src/components/SidebarPlugin/SideBar.spec.js index f15e3ab0c..cc56b00f1 100644 --- a/frontend/src/components/SidebarPlugin/SideBar.spec.js +++ b/frontend/src/components/SidebarPlugin/SideBar.spec.js @@ -58,6 +58,22 @@ describe('SideBar', () => { it('has a navbar button', () => { expect(wrapper.find('button.navbar-toggler').exists()).toBeTruthy() }) + + it('calls showSidebar when clicked', async () => { + const spy = jest.spyOn(wrapper.vm.$sidebar, 'displaySidebar') + wrapper.find('button.navbar-toggler').trigger('click') + await wrapper.vm.$nextTick() + expect(spy).toHaveBeenCalledWith(true) + }) + }) + + describe('close siedbar', () => { + it('calls closeSidebar when clicked', async () => { + const spy = jest.spyOn(wrapper.vm.$sidebar, 'displaySidebar') + wrapper.find('#sidenav-collapse-main').find('button.navbar-toggler').trigger('click') + await wrapper.vm.$nextTick() + expect(spy).toHaveBeenCalledWith(false) + }) }) describe('static menu items', () => { @@ -90,11 +106,10 @@ describe('SideBar', () => { expect(wrapper.findAll('li').at(1).text()).toBe('logout') }) - it.skip('emits logout when logout is clicked', async () => { - const spy = jest.spyOn(wrapper.vm, 'logout') + it('emits logout when logout is clicked', async () => { wrapper.findAll('li').at(1).find('a').trigger('click') await wrapper.vm.$nextTick() - expect(spy).toHaveBeenCalled() + expect(wrapper.emitted('logout')).toEqual([[]]) }) }) })