2022-09-06 12:03:37 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
2022-09-14 13:17:12 +00:00
|
|
|
import PrimeVue from '../config/PrimeVue';
|
2022-09-06 12:03:37 +00:00
|
|
|
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: () => {
|
2022-09-14 11:26:01 +00:00
|
|
|
window.location.href = 'https://vuejs.org/';
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
2022-09-14 11:26:01 +00:00
|
|
|
{ label: 'Upload', icon: 'pi pi-upload', to: '/fileupload' }
|
2022-09-06 12:03:37 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2022-09-14 11:26:01 +00:00
|
|
|
});
|