test(multi-select): update unit tests

pull/6705/head
betavs 2024-11-01 17:32:38 +08:00
parent ba27cfc715
commit af34fddf3d
1 changed files with 8 additions and 8 deletions

View File

@ -34,7 +34,7 @@ describe('MultiSelect.vue', () => {
expect(wrapper.find('.p-multiselect-label.p-placeholder').text()).toBe('Select Cities'); expect(wrapper.find('.p-multiselect-label.p-placeholder').text()).toBe('Select Cities');
expect(wrapper.find('.p-multiselect-panel').exists()).toBe(false); expect(wrapper.find('.p-multiselect-panel').exists()).toBe(false);
await wrapper.vm.onContainerClick(); await wrapper.vm.$refs.container.click();
expect(wrapper.findAll('li.p-multiselect-option').length).toBe(5); expect(wrapper.findAll('li.p-multiselect-option').length).toBe(5);
expect(wrapper.findAll('li.p-multiselect-option')[0].attributes()['aria-label']).toBe('New York'); expect(wrapper.findAll('li.p-multiselect-option')[0].attributes()['aria-label']).toBe('New York');
@ -47,7 +47,7 @@ describe('MultiSelect.vue', () => {
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([[wrapper.vm.options[0]]]); 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(); await wrapper.vm.$refs.container.click();
expect(wrapper.findAll('li.p-multiselect-option')[0].attributes()['data-p-selected']).toBe('true'); expect(wrapper.findAll('li.p-multiselect-option')[0].attributes()['data-p-selected']).toBe('true');
expect(wrapper.find('.p-multiselect-label').text()).toBe('New York'); expect(wrapper.find('.p-multiselect-label').text()).toBe('New York');
@ -61,7 +61,7 @@ describe('MultiSelect.vue', () => {
expect(wrapper.emitted()['update:modelValue'][0]).toEqual([[wrapper.vm.options[0], 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(); await wrapper.vm.$refs.container.click();
expect(wrapper.findAll('li.p-multiselect-option')[0].attributes()['data-p-selected']).toBe('true'); expect(wrapper.findAll('li.p-multiselect-option')[0].attributes()['data-p-selected']).toBe('true');
expect(wrapper.findAll('li.p-multiselect-option')[1].attributes()['data-p-selected']).toBe('true'); expect(wrapper.findAll('li.p-multiselect-option')[1].attributes()['data-p-selected']).toBe('true');
@ -106,7 +106,7 @@ describe('MultiSelect.vue', () => {
filterIcon: 'pi pi-discord' filterIcon: 'pi pi-discord'
}); });
await wrapper.vm.onContainerClick(); await wrapper.vm.$refs.container.click();
const icon = wrapper.find('.p-multiselect-filter-container [data-pc-section="filtericon"]'); const icon = wrapper.find('.p-multiselect-filter-container [data-pc-section="filtericon"]');
@ -123,7 +123,7 @@ describe('MultiSelect.vue', () => {
modelValue: wrapper.vm.options modelValue: wrapper.vm.options
}); });
await wrapper.vm.onContainerClick(); await wrapper.vm.$refs.container.click();
wrapper.findAll('.p-checkbox-icon').forEach((icon) => { wrapper.findAll('.p-checkbox-icon').forEach((icon) => {
expect(icon.classes()).toContain('pi-discord'); expect(icon.classes()).toContain('pi-discord');
@ -172,7 +172,7 @@ describe('MultiSelect.vue', () => {
optionGroupChildren: 'items' optionGroupChildren: 'items'
}); });
await wrapper.vm.onContainerClick(); await wrapper.vm.$refs.container.click();
expect(wrapper.find('.p-multiselect-option-group').exists()).toBe(true); expect(wrapper.find('.p-multiselect-option-group').exists()).toBe(true);
}); });
@ -185,7 +185,7 @@ describe('MultiSelect.vue', () => {
autoFilterFocus: true autoFilterFocus: true
}); });
await wrapper.vm.onContainerClick(); await wrapper.vm.$refs.container.click();
const input = await wrapper.find('input.p-multiselect-filter'); const input = await wrapper.find('input.p-multiselect-filter');
input.setValue('Ber'); input.setValue('Ber');
@ -203,7 +203,7 @@ describe('MultiSelect.vue', () => {
autoFilterFocus: true autoFilterFocus: true
}); });
await wrapper.vm.onContainerClick(); await wrapper.vm.$refs.container.click();
const input = await wrapper.find('input.p-multiselect-filter'); const input = await wrapper.find('input.p-multiselect-filter');
input.value = 'Ber'; input.value = 'Ber';