mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-11 01:42:34 +00:00
Refactor #5612 - Chips / InputChips
This commit is contained in:
parent
55ae9908d1
commit
365879a41c
16 changed files with 696 additions and 574 deletions
44
components/lib/inputchips/InputChips.spec.js
Normal file
44
components/lib/inputchips/InputChips.spec.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import InputChips from './InputChips.vue';
|
||||
|
||||
describe('InputChips.vue', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = mount(InputChips, {
|
||||
props: {
|
||||
modelValue: null
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should exist', () => {
|
||||
expect(wrapper.find('.p-inputchips.p-component.p-inputwrapper').exists()).toBe(true);
|
||||
expect(wrapper.find('ul.p-inputchips-multiple-container').exists()).toBe(true);
|
||||
expect(wrapper.find('li.p-inputchips-input-token').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('should add item', async () => {
|
||||
const addItem = vi.spyOn(wrapper.vm, 'addItem');
|
||||
|
||||
await wrapper.vm.addItem({}, 'PrimeVue', false);
|
||||
|
||||
await wrapper.setProps({ modelValue: ['PrimeVue'] });
|
||||
|
||||
expect(addItem).toHaveBeenCalled();
|
||||
expect(wrapper.findAll('.p-inputchips-token').length).toBe(1);
|
||||
expect(wrapper.find('.p-inputchips-token-label').exists()).toBe(true);
|
||||
expect(wrapper.find('.p-inputchips-token-label').text()).toBe('PrimeVue');
|
||||
});
|
||||
|
||||
it('should have correct custom chip removal icon', async () => {
|
||||
await wrapper.setProps({
|
||||
modelValue: ['foo', 'bar'],
|
||||
removeTokenIcon: 'pi pi-discord'
|
||||
});
|
||||
|
||||
const icon = wrapper.find('.p-inputchips-token-icon');
|
||||
|
||||
expect(icon.classes()).toContain('pi-discord');
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue