commit
b0ca984853
|
@ -0,0 +1,38 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import InputMask from './InputMask.vue';
|
||||
|
||||
describe('InputMask.vue', () => {
|
||||
it('should exist', async () => {
|
||||
const wrapper = mount(InputMask, {
|
||||
props: {
|
||||
modelValue: null,
|
||||
mask: '99-999999',
|
||||
placeholder: '99-999999'
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.find('.p-inputmask.p-component').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-inputmask.p-component').attributes().placeholder).toBe('99-999999');
|
||||
|
||||
const event = {'target': { 'value': '1' }};
|
||||
|
||||
await wrapper.vm.onInput(event);
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue'][0]).toEqual(['1']);
|
||||
});
|
||||
|
||||
it('keydown event', async () => {
|
||||
const wrapper = mount(InputMask, {
|
||||
props: {
|
||||
modelValue: null,
|
||||
mask: '99/99/9999'
|
||||
}
|
||||
});
|
||||
|
||||
const event = {'target': { 'value': '1' }};
|
||||
|
||||
await wrapper.vm.onKeyDown(event);
|
||||
|
||||
expect(wrapper.emitted().keydown[0]).toEqual([event]);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import InputSwitch from './InputSwitch.vue';
|
||||
|
||||
describe('InputSwitch.vue', () => {
|
||||
it('should exist', async () => {
|
||||
const wrapper = mount(InputSwitch);
|
||||
|
||||
expect(wrapper.find('.p-inputswitch.p-component').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-inputswitch-slider').exists()).toBe(true);
|
||||
|
||||
await wrapper.trigger('click');
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([true]);
|
||||
|
||||
await wrapper.setProps({ modelValue: true });
|
||||
|
||||
expect(wrapper.vm.checked).toBe(true);
|
||||
expect(wrapper.find('.p-inputswitch').classes()).toContain('p-inputswitch-checked');
|
||||
});
|
||||
});
|
|
@ -13,18 +13,22 @@ describe('InputText.vue', () => {
|
|||
|
||||
const input = wrapper.find('input');
|
||||
expect(input.element.value).toEqual('PrimeVue');
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('InputText.vue', () => {
|
||||
it('input event', async () => {
|
||||
const wrapper = mount(InputText);
|
||||
const input = wrapper.find('input');
|
||||
const event = { target: { value: 'a' } };
|
||||
|
||||
// await input.trigger('input', { keyCode: 65 });
|
||||
input.element.value = 'a';
|
||||
input.trigger('input');
|
||||
await wrapper.vm.onInput(event);
|
||||
|
||||
expect(input.element.value).toEqual('a');
|
||||
})
|
||||
expect(wrapper.emitted()['update:modelValue'][0]).toEqual(['a']);
|
||||
});
|
||||
|
||||
it('should filled work', async () => {
|
||||
const wrapper = mount(InputText);
|
||||
|
||||
await wrapper.setProps({ modelValue: 'a' });
|
||||
|
||||
expect(wrapper.vm.filled).toBe(true);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,47 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import Knob from './Knob.vue';
|
||||
|
||||
describe('Knob.vue', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = mount(Knob, {
|
||||
props: {
|
||||
modelValue: 20
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should exist', () => {
|
||||
expect(wrapper.find('.p-knob.p-component').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-knob-text').text()).toBe('20');
|
||||
});
|
||||
|
||||
it('should change with click event', async () => {
|
||||
const event = { offsetX: 100, offsetY: 100 };
|
||||
|
||||
await wrapper.vm.onClick(event);
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([95]);
|
||||
});
|
||||
|
||||
it('should min - max work', async () => {
|
||||
await wrapper.setProps({ min: -50, max: 50 });
|
||||
|
||||
const event = { offsetX: 100, offsetY: 100 };
|
||||
|
||||
await wrapper.vm.onClick(event);
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([45]);
|
||||
});
|
||||
|
||||
it('should step work', async () => {
|
||||
await wrapper.setProps({ step: 10 });
|
||||
|
||||
const event = { offsetX: 18, offsetY: 30 };
|
||||
|
||||
await wrapper.vm.onClick(event);
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([30]);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,38 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import Listbox from './Listbox.vue';
|
||||
|
||||
describe('Listbox.vue', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = mount(Listbox, {
|
||||
props: {
|
||||
modelValue: null,
|
||||
options: [
|
||||
{name: 'New York', code: 'NY'},
|
||||
{name: 'Rome', code: 'RM'},
|
||||
{name: 'London', code: 'LDN'},
|
||||
{name: 'Istanbul', code: 'IST'},
|
||||
{name: 'Paris', code: 'PRS'}
|
||||
],
|
||||
optionLabel: 'name'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should exist', () => {
|
||||
expect(wrapper.find('.p-listbox.p-component').exists()).toBe(true);
|
||||
expect(wrapper.findAll('li.p-listbox-item').length).toBe(5);
|
||||
expect(wrapper.findAll('li.p-listbox-item')[0].attributes()['aria-label']).toBe('New York');
|
||||
});
|
||||
|
||||
it('should select a list item', async () => {
|
||||
await wrapper.vm.onOptionSelect({}, wrapper.vm.options[0]);
|
||||
|
||||
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([wrapper.vm.options[0]]);
|
||||
|
||||
await wrapper.setProps({ modelValue: wrapper.vm.options[0] });
|
||||
|
||||
expect(wrapper.findAll('li.p-listbox-item')[0].classes()).toContain('p-highlight');
|
||||
});
|
||||
});
|
|
@ -0,0 +1,88 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import MegaMenu from './MegaMenu.vue';
|
||||
|
||||
describe('MegaMenu.vue', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = mount(MegaMenu, {
|
||||
global: {
|
||||
stubs: {
|
||||
'router-link': true
|
||||
}
|
||||
},
|
||||
props: {
|
||||
model: [
|
||||
{
|
||||
label: 'Videos', icon: 'pi pi-fw pi-video',
|
||||
items: [
|
||||
[
|
||||
{
|
||||
label: 'Video 1',
|
||||
items: [{label: 'Video 1.1'}, {label: 'Video 1.2'}]
|
||||
},
|
||||
{
|
||||
label: 'Video 2',
|
||||
items: [{label: 'Video 2.1'}, {label: 'Video 2.2'}]
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Users', icon: 'pi pi-fw pi-users',
|
||||
items: [
|
||||
[
|
||||
{
|
||||
label: 'User 1',
|
||||
items: [{label: 'User 1.1'}, {label: 'User 1.2'}]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
label: 'User 2',
|
||||
items: [{label: 'User 2.1'}, {label: 'User 2.2'}]
|
||||
},
|
||||
{
|
||||
label: 'User 3',
|
||||
items: [{label: 'User 3.1'}, {label: 'User 3.2'}]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should exists', () => {
|
||||
expect(wrapper.find('.p-megamenu.p-component').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-megamenu-root-list').exists()).toBe(true);
|
||||
expect(wrapper.findAll('ul.p-megamenu-submenu').length).toBe(5);
|
||||
expect(wrapper.findAll('li.p-menuitem').length).toBe(12);
|
||||
expect(wrapper.findAll('li.p-menuitem')[0].findAll('span.p-menuitem-text')[0].text()).toBe('Videos');
|
||||
expect(wrapper.findAll('li.p-megamenu-submenu-header')[0].text()).toBe('Video 1');
|
||||
expect(wrapper.findAll('li.p-menuitem')[1].findAll('span.p-menuitem-text')[0].text()).toBe('Video 1.1');
|
||||
});
|
||||
|
||||
it('should select item', async () => {
|
||||
const firstItem = wrapper.findAll('li.p-menuitem')[0];
|
||||
|
||||
await wrapper.vm.onCategoryClick({}, wrapper.vm.model[0]);
|
||||
|
||||
expect(firstItem.classes()).toContain('p-menuitem-active');
|
||||
});
|
||||
|
||||
it('should deselect item', async () => {
|
||||
const firstItem = wrapper.findAll('li.p-menuitem')[0];
|
||||
|
||||
await wrapper.vm.onCategoryClick({}, wrapper.vm.model[0].items[0][0].items[0]);
|
||||
|
||||
expect(firstItem.classes()).not.toContain('p-menuitem-active');
|
||||
});
|
||||
|
||||
it('should orientation work', async () => {
|
||||
await wrapper.setProps({ orientation: 'vertical' });
|
||||
|
||||
expect(wrapper.find('.p-megamenu-vertical').exists()).toBe(true);
|
||||
});
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,74 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import Menubar from './Menubar.vue';
|
||||
|
||||
describe('Menubar.vue', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = mount(Menubar, {
|
||||
global: {
|
||||
stubs: {
|
||||
'router-link': true
|
||||
}
|
||||
},
|
||||
props: {
|
||||
model: [
|
||||
{
|
||||
label:'File',
|
||||
icon:'pi pi-fw pi-file',
|
||||
items:[
|
||||
{
|
||||
label:'New',
|
||||
icon:'pi pi-fw pi-plus',
|
||||
items:[
|
||||
{
|
||||
label:'Bookmark',
|
||||
icon:'pi pi-fw pi-bookmark'
|
||||
},
|
||||
{
|
||||
label:'Video',
|
||||
icon:'pi pi-fw pi-video'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label:'Delete',
|
||||
icon:'pi pi-fw pi-trash'
|
||||
},
|
||||
{
|
||||
separator:true
|
||||
},
|
||||
{
|
||||
label:'Export',
|
||||
icon:'pi pi-fw pi-external-link'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label:'Quit',
|
||||
icon:'pi pi-fw pi-power-off'
|
||||
}
|
||||
]
|
||||
},
|
||||
slots: {
|
||||
start: 'Start Slot',
|
||||
end: 'End Slot'
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('should exist', () => {
|
||||
expect(wrapper.find('.p-menubar.p-component').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-menubar-root-list').exists()).toBe(true);
|
||||
expect(wrapper.findAll('ul.p-submenu-list').length).toBe(2);
|
||||
expect(wrapper.findAll('ul.p-submenu-list')[0].findAll('li.p-menuitem')[0].find('.p-menuitem-text').text()).toBe('New');
|
||||
expect(wrapper.findAll('li.p-menuitem').length).toBe(7);
|
||||
expect(wrapper.findAll('li.p-menu-separator').length).toBe(1);
|
||||
});
|
||||
|
||||
it('should slot visible', () => {
|
||||
expect(wrapper.find('.p-menubar-start').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-menubar-end').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-menubar-end').text()).toBe('End Slot');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue