From 5efe78c1d06a86049ed5e3cce4ef2e30ce6cf476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Tue, 22 Mar 2022 15:05:29 +0300 Subject: [PATCH] Create Sidebar.spec.js --- src/components/sidebar/Sidebar.spec.js | 54 ++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/components/sidebar/Sidebar.spec.js diff --git a/src/components/sidebar/Sidebar.spec.js b/src/components/sidebar/Sidebar.spec.js new file mode 100644 index 000000000..eda571e6f --- /dev/null +++ b/src/components/sidebar/Sidebar.spec.js @@ -0,0 +1,54 @@ +import { mount } from '@vue/test-utils'; +import PrimeVue from '@/components/config/PrimeVue'; +import Sidebar from './Sidebar.vue'; + +describe('Sidebar.vue', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(Sidebar, { + global: { + plugins: [PrimeVue], + stubs: { + teleport: true + } + }, + props: { + visible: true, + bazeZIndex: 1000 + }, + slots: { + default: `

Left Sidebar

` + } + }); + }); + + it('should exist', () => { + expect(wrapper.find('.p-sidebar.p-component').exists()).toBe(true); + expect(wrapper.find('.p-sidebar').classes()).toContain('p-sidebar-left'); + expect(wrapper.find('.p-sidebar').classes()).toContain('p-sidebar-active'); + }); + + it('should close', async () => { + await wrapper.vm.hide(); + + expect(wrapper.emitted()['update:visible'][0]).toEqual([false]); + + await wrapper.setProps({ visible: false }); + + expect(wrapper.find('.p-sidebar.p-component').exists()).toBe(false); + }); + + it('should set position', async () => { + await wrapper.setProps({ position: 'bottom' }); + + expect(wrapper.find('.p-sidebar').classes()).toContain('p-sidebar-bottom'); + }); + + it('should set position', async () => { + await wrapper.setProps({ position: 'full' }); + + expect(wrapper.vm.fullScreen).toBe(true); + expect(wrapper.find('.p-sidebar').classes()).toContain('p-sidebar-full'); + }); +}); \ No newline at end of file