2019-10-29 18:06:21 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import Avatar from './Avatar.vue';
|
|
|
|
import Thumbnail from './Thumbnail.vue';
|
|
|
|
|
2022-10-28 08:49:12 +00:00
|
|
|
describe('Thumbnail.vue', () => {
|
|
|
|
it('should render the agent thumbnail if valid image is passed', () => {
|
2019-10-29 18:06:21 +00:00
|
|
|
const wrapper = mount(Thumbnail, {
|
|
|
|
propsData: {
|
|
|
|
src: 'https://some_valid_url.com',
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-11-09 05:05:13 +00:00
|
|
|
hasImageLoaded: true,
|
2019-10-29 18:06:21 +00:00
|
|
|
imgError: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2022-10-28 08:49:12 +00:00
|
|
|
expect(wrapper.find('.user-thumbnail').exists()).toBe(true);
|
2021-05-25 08:30:21 +00:00
|
|
|
const avatarComponent = wrapper.findComponent(Avatar);
|
2022-11-09 05:05:13 +00:00
|
|
|
expect(avatarComponent.isVisible()).toBe(false);
|
2019-10-29 18:06:21 +00:00
|
|
|
});
|
|
|
|
|
2022-10-28 08:49:12 +00:00
|
|
|
it('should render the avatar component if invalid image is passed', () => {
|
2019-10-29 18:06:21 +00:00
|
|
|
const wrapper = mount(Thumbnail, {
|
|
|
|
propsData: {
|
|
|
|
src: 'https://some_invalid_url.com',
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-11-09 05:05:13 +00:00
|
|
|
hasImageLoaded: true,
|
2019-10-29 18:06:21 +00:00
|
|
|
imgError: true,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2022-11-09 05:05:13 +00:00
|
|
|
expect(wrapper.find('#image').exists()).toBe(false);
|
2021-05-25 08:30:21 +00:00
|
|
|
const avatarComponent = wrapper.findComponent(Avatar);
|
2022-11-09 05:05:13 +00:00
|
|
|
expect(avatarComponent.isVisible()).toBe(true);
|
2019-10-29 18:06:21 +00:00
|
|
|
});
|
|
|
|
|
2022-10-28 08:49:12 +00:00
|
|
|
it('should the initial of the name if no image is passed', () => {
|
2019-10-29 18:06:21 +00:00
|
|
|
const wrapper = mount(Avatar, {
|
|
|
|
propsData: {
|
|
|
|
username: 'Angie Rojas',
|
|
|
|
},
|
|
|
|
});
|
2022-10-28 08:49:12 +00:00
|
|
|
expect(wrapper.find('div').text()).toBe('AR');
|
2019-10-29 18:06:21 +00:00
|
|
|
});
|
|
|
|
});
|