2022-09-06 12:03:37 +00:00
|
|
|
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', () => {
|
2024-05-22 08:11:33 +00:00
|
|
|
expect(wrapper.find('.p-textarea.p-component').exists()).toBe(true);
|
2022-09-06 12:03:37 +00:00
|
|
|
expect(wrapper.attributes().rows).toBe('1');
|
|
|
|
expect(wrapper.attributes().cols).toBe('1');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be autoresized', async () => {
|
|
|
|
await wrapper.setProps({ autoResize: true });
|
|
|
|
|
2024-05-22 08:11:33 +00:00
|
|
|
expect(wrapper.find('.p-textarea-resizable').exists()).toBe(true);
|
2022-09-06 12:03:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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;
|
2022-09-14 11:26:01 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
await wrapper.setProps({ autoResize: true });
|
|
|
|
|
|
|
|
await wrapper.vm.onInput({ target: { value: 'primevue' } });
|
|
|
|
|
|
|
|
expect(wrapper.attributes().style).not.toEqual(firstHeight);
|
|
|
|
});
|
2022-09-14 11:26:01 +00:00
|
|
|
});
|