2022-09-06 12:03:37 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
2022-12-29 06:04:51 +00:00
|
|
|
import { beforeEach } from 'vitest';
|
2022-09-06 12:03:37 +00:00
|
|
|
import Avatar from './Avatar.vue';
|
2022-12-29 06:04:51 +00:00
|
|
|
let wrapper = null;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper = mount(Avatar, {
|
|
|
|
props: {
|
|
|
|
label: 'T',
|
|
|
|
size: 'large',
|
|
|
|
shape: 'circle',
|
|
|
|
image: 'test'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
describe('Avatar.vue', () => {
|
|
|
|
it('should exist', () => {
|
|
|
|
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');
|
|
|
|
});
|
2022-12-29 06:04:51 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2022-09-14 11:26:01 +00:00
|
|
|
});
|