primevue-mirror/components/lib/avatar/Avatar.spec.js

37 lines
1.0 KiB
JavaScript
Raw Normal View History

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';
2023-05-25 13:28:03 +00:00
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
});