Chip unit test updates

pull/3502/head
Bahadır Sofuoğlu 2023-01-06 15:57:00 +03:00
parent 6ce4a4a13c
commit ab885948c5
1 changed files with 19 additions and 0 deletions

View File

@ -14,6 +14,10 @@ describe('Chip.vue', () => {
});
});
afterEach(() => {
vi.restoreAllMocks();
});
it('should exists', () => {
expect(wrapper.find('.p-chip.p-component').exists()).toBe(true);
expect(wrapper.find('.p-chip-icon').classes()).toContain('pi-primevue');
@ -26,4 +30,19 @@ describe('Chip.vue', () => {
expect(wrapper.find('.p-chip.p-component').exists()).toBe(false);
});
it('When removable is true and keydown triggered OnKeydown method should be called', async () => {
const closeSpy = vi.spyOn(wrapper.vm, 'onKeydown');
await wrapper.find('.p-chip-remove-icon').trigger('keydown');
expect(closeSpy).toHaveBeenCalled();
});
it('When onKeyDown method triggered close method should be called', async () => {
const closeSpy = vi.spyOn(wrapper.vm, 'close');
await wrapper.vm.onKeydown({ key: 'Enter' });
expect(closeSpy).toHaveBeenCalled();
});
});