From 36846cc11be63b0b75d88da95f9d6828add0894d 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: Thu, 17 Mar 2022 17:15:09 +0300 Subject: [PATCH] Create Menu.spec.js --- src/components/menu/Menu.spec.js | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/components/menu/Menu.spec.js diff --git a/src/components/menu/Menu.spec.js b/src/components/menu/Menu.spec.js new file mode 100644 index 000000000..758f1ae3e --- /dev/null +++ b/src/components/menu/Menu.spec.js @@ -0,0 +1,70 @@ +import { mount } from '@vue/test-utils'; +import PrimeVue from '@/components/config/PrimeVue'; +import Menu from './Menu.vue'; + +describe('Menu.vue', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(Menu, { + global: { + plugins: [PrimeVue], + stubs: { + 'router-link': true, + teleport: true + } + }, + props: { + model: [ + { + label: 'Options', + items: [{ + label: 'Update', + icon: 'pi pi-refresh', + command: () => { + this.$toast.add({severity:'success', summary:'Updated', detail:'Data Updated', life: 3000}); + } + }, + { + label: 'Delete', + icon: 'pi pi-times', + command: () => { + this.$toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000}); + } + } + ]}, + { + label: 'Navigate', + items: [{ + label: 'Vue Website', + icon: 'pi pi-external-link', + url: 'https://vuejs.org/' + }, + { + label: 'Router', + icon: 'pi pi-upload', + to: '/fileupload' + } + ]} + ] + } + }); + }); + + it('should exist', () => { + expect(wrapper.find('.p-menu.p-component').exists()).toBe(true); + expect(wrapper.findAll('.p-submenu-header').length).toBe(2); + expect(wrapper.findAll('.p-submenu-header')[0].text()).toBe('Options'); + expect(wrapper.findAll('.p-menuitem').length).toBe(4); + expect(wrapper.findAll('.p-menuitem')[0].find('span.p-menuitem-text').text()).toBe('Update'); + expect(wrapper.findAll('.p-menuitem')[2].find('a').attributes().href).toBe('https://vuejs.org/'); + }); + + it('should popup work', async () => { + await wrapper.setProps({ popup: true }); + + await wrapper.vm.toggle({}); + + expect(wrapper.find('.p-menu.p-component').exists()).toBe(true); + }); +}); \ No newline at end of file