Components added. Build issues fixed

This commit is contained in:
Bahadir Sofuoglu 2022-09-14 14:26:01 +03:00
parent 5b66ed1093
commit 18c3721848
344 changed files with 12446 additions and 8758 deletions

View file

@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils';
import PrimeVue from '@/components/config/PrimeVue';
import { mount } from '@vue/test-utils';
import MultiSelect from './MultiSelect.vue';
describe('MultiSelect.vue', () => {
@ -16,24 +16,25 @@ describe('MultiSelect.vue', () => {
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'}
{ name: 'New York', code: 'NY' },
{ name: 'Rome', code: 'RM' },
{ name: 'London', code: 'LDN' },
{ name: 'Istanbul', code: 'IST' },
{ name: 'Paris', code: 'PRS' }
],
optionLabel: 'name',
placeholder: 'Select Cities'
}
});
await wrapper.vm.onClick({});
});
it('should exist', () => {
it('should exist', async () => {
expect(wrapper.find('.p-multiselect.p-component').exists()).toBe(true);
expect(wrapper.find('.p-multiselect-label.p-placeholder').text()).toBe('Select Cities');
expect(wrapper.find('.p-multiselect-panel').exists()).toBe(true);
expect(wrapper.find('.p-multiselect-panel').exists()).toBe(false);
await wrapper.vm.onContainerClick();
expect(wrapper.findAll('li.p-multiselect-item').length).toBe(5);
expect(wrapper.findAll('li.p-multiselect-item')[0].attributes()['aria-label']).toBe('New York');
expect(wrapper.findAll('li.p-multiselect-item')[0].findAll('span')[1].text()).toBe('New York');
@ -44,20 +45,22 @@ describe('MultiSelect.vue', () => {
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([[wrapper.vm.options[0]]]);
await wrapper.setProps({ modelValue: [wrapper.vm.options[0]]});
await wrapper.setProps({ modelValue: [wrapper.vm.options[0]] });
await wrapper.vm.onContainerClick();
expect(wrapper.findAll('li.p-multiselect-item')[0].classes()).toContain('p-highlight');
expect(wrapper.find('.p-multiselect-label').text()).toBe('New York');
});
it('should select multiple item', async () => {
await wrapper.setProps({ modelValue: [wrapper.vm.options[0]]});
await wrapper.setProps({ modelValue: [wrapper.vm.options[0]] });
await wrapper.vm.onOptionSelect({}, wrapper.vm.options[1]);
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([[wrapper.vm.options[0], wrapper.vm.options[1]]]);
await wrapper.setProps({ modelValue: [wrapper.vm.options[0], wrapper.vm.options[1]]});
await wrapper.setProps({ modelValue: [wrapper.vm.options[0], wrapper.vm.options[1]] });
await wrapper.vm.onContainerClick();
expect(wrapper.findAll('li.p-multiselect-item')[0].classes()).toContain('p-highlight');
expect(wrapper.findAll('li.p-multiselect-item')[1].classes()).toContain('p-highlight');
@ -65,14 +68,17 @@ describe('MultiSelect.vue', () => {
it('should close panel', async () => {
await wrapper.vm.onCloseClick();
expect(wrapper.find('.p-multiselect-panel').exists()).toBe(false);
});
it('should chip work', async () => {
await wrapper.setProps({ display: 'chip', modelValue: [wrapper.vm.options[0]] });
await wrapper.setProps({
display: 'chip',
modelValue: [wrapper.vm.options[0]]
});
expect(wrapper.find('.p-multiselect-token').exists()).toBe(true);
expect(wrapper.find('.p-multiselect-token-label').text()).toBe('New York');
});
});
});