Avatar unit test updated

pull/3455/head
Bahadır Sofuoğlu 2022-12-29 09:04:51 +03:00
parent f20b01257a
commit f7cd6233a3
1 changed files with 23 additions and 8 deletions

View File

@ -1,20 +1,35 @@
import { mount } from '@vue/test-utils';
import { beforeEach } from 'vitest';
import Avatar from './Avatar.vue';
let wrapper = null;
beforeEach(() => {
wrapper = mount(Avatar, {
props: {
label: 'T',
size: 'large',
shape: 'circle',
image: 'test'
}
});
});
describe('Avatar.vue', () => {
it('should exist', () => {
const wrapper = mount(Avatar, {
props: {
label: 'T',
size: 'large',
shape: 'circle'
}
});
expect(wrapper.find('.p-avatar.p-component').exists()).toBe(true);
expect(wrapper.find('.p-avatar-lg').exists()).toBe(true);
expect(wrapper.find('.p-avatar-circle').exists()).toBe(true);
expect(wrapper.find('.p-avatar-text').exists()).toBe(true);
expect(wrapper.find('.p-avatar-text').text()).toBe('T');
});
it('should exist', async () => {
await wrapper.setProps({ image: 'imageTest' });
const image = wrapper.find('.p-avatar-image');
await wrapper.vm.onError();
expect(image.exists()).toBe(true);
expect(wrapper.emitted().error.length).toBe(1);
});
});