From c1e33a0b9ae7fb5da343687a7d04fcf1d5e2b239 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, 5 Apr 2022 17:45:37 +0300 Subject: [PATCH] Create SplitButton.spec.js --- .../splitbutton/SplitButton.spec.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/components/splitbutton/SplitButton.spec.js diff --git a/src/components/splitbutton/SplitButton.spec.js b/src/components/splitbutton/SplitButton.spec.js new file mode 100644 index 000000000..cbbe32b09 --- /dev/null +++ b/src/components/splitbutton/SplitButton.spec.js @@ -0,0 +1,59 @@ +import { mount } from '@vue/test-utils'; +import PrimeVue from '@/components/config/PrimeVue'; +import SplitButton from './SplitButton.vue'; + +describe('SplitButton.vue', () => { + let wrapper; + + beforeEach(async () => { + wrapper = mount(SplitButton, { + global: { + plugins: [PrimeVue], + stubs: { + teleport: true, + 'router-link': true + } + }, + props: { + label: 'Save', + model: [ + { + label: 'Update', + icon: 'pi pi-refresh' + }, + { + label: 'Delete', + icon: 'pi pi-times' + }, + { + label: 'Vue Website', + icon: 'pi pi-external-link', + command: () => { + window.location.href = 'https://vuejs.org/' + } + }, + { label: 'Upload', + icon: 'pi pi-upload', + to: '/fileupload' + } + ] + } + }); + + await wrapper.vm.onDropdownButtonClick(); + }); + + it('should exist', () => { + expect(wrapper.find('.p-splitbutton.p-component').exists()).toBe(true); + expect(wrapper.find('.p-tieredmenu.p-component').exists()).toBe(true); + expect(wrapper.findAll('li.p-menuitem').length).toBe(4); + expect(wrapper.find('.p-splitbutton-defaultbutton').exists()).toBe(true); + expect(wrapper.find('.p-button-label').text()).toBe('Save'); + }); + + it('should hide when default button is clicked', async () => { + await wrapper.vm.onDefaultButtonClick(); + + expect(wrapper.find('.p-tieredmenu.p-component').exists()).toBe(false); + }); +}); \ No newline at end of file