From 27f66ce25c1fa18509530ad808d352416bcc5cb1 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: Wed, 6 Apr 2022 16:36:00 +0300 Subject: [PATCH] Create Textarea.spec.js --- src/components/textarea/Textarea.spec.js | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/components/textarea/Textarea.spec.js diff --git a/src/components/textarea/Textarea.spec.js b/src/components/textarea/Textarea.spec.js new file mode 100644 index 000000000..f7150ef63 --- /dev/null +++ b/src/components/textarea/Textarea.spec.js @@ -0,0 +1,44 @@ +import { mount } from '@vue/test-utils'; +import Textarea from './Textarea.vue'; + +describe('Textarea.vue', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(Textarea, { + props: { + modelValue: '', + rows: 1, + cols: 1 + } + }); + }); + + it('should exist', () => { + expect(wrapper.find('.p-inputtextarea.p-component').exists()).toBe(true); + expect(wrapper.attributes().rows).toBe('1'); + expect(wrapper.attributes().cols).toBe('1'); + }); + + it('should be autoresized', async () => { + await wrapper.setProps({ autoResize: true }); + + expect(wrapper.find('.p-inputtextarea-resizable').exists()).toBe(true); + }); + + it('should input', async () => { + await wrapper.vm.onInput({ target: { value: 'primevue' } }); + + expect(wrapper.emitted()['update:modelValue'][0]).toEqual(['primevue']); + }); + + it('should resize', async () => { + const firstHeight = wrapper.attributes().style; + + await wrapper.setProps({ autoResize: true }); + + await wrapper.vm.onInput({ target: { value: 'primevue' } }); + + expect(wrapper.attributes().style).not.toEqual(firstHeight); + }); +}); \ No newline at end of file