From aa8ff8b4a9d2597b10dd54b37c05f12abe314094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Thu, 10 Mar 2022 13:20:47 +0300 Subject: [PATCH] Chips test added --- src/components/chips/Chips.spec.js | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/components/chips/Chips.spec.js diff --git a/src/components/chips/Chips.spec.js b/src/components/chips/Chips.spec.js new file mode 100644 index 000000000..719975009 --- /dev/null +++ b/src/components/chips/Chips.spec.js @@ -0,0 +1,33 @@ +import { mount } from '@vue/test-utils'; +import Chips from './Chips.vue'; + +describe('Chips.vue', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(Chips, { + props: { + modelValue: null + } + }); + }); + + it('should exist', () => { + expect(wrapper.find('.p-chips.p-component.p-inputwrapper').exists()).toBe(true); + expect(wrapper.find('ul.p-chips-multiple-container').exists()).toBe(true); + expect(wrapper.find('li.p-chips-input-token').exists()).toBe(true); + }); + + it('should add item', async() => { + const addItem = jest.spyOn(wrapper.vm, 'addItem'); + + await wrapper.vm.addItem({},'PrimeVue', false); + + await wrapper.setProps({ modelValue: ['PrimeVue'] }); + + expect(addItem).toHaveBeenCalled(); + expect(wrapper.findAll('.p-chips-token').length).toBe(1); + expect(wrapper.find('.p-chips-token-label').exists()).toBe(true); + expect(wrapper.find('.p-chips-token-label').text()).toBe('PrimeVue'); + }); +}); \ No newline at end of file