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 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',
|
2022-09-14 11:26:01 +00:00
|
|
|
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 });
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
]
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
{
|
|
|
|
label: 'Navigate',
|
2022-09-14 11:26:01 +00:00
|
|
|
items: [
|
|
|
|
{
|
|
|
|
label: 'Vue Website',
|
|
|
|
icon: 'pi pi-external-link',
|
|
|
|
url: 'https://vuejs.org/'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Router',
|
|
|
|
icon: 'pi pi-upload',
|
|
|
|
to: '/fileupload'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2022-09-14 11:26:01 +00:00
|
|
|
});
|