chore: Fix Thumbnail component specs (#5776)

This commit is contained in:
Muhsin Keloth 2022-10-28 14:19:12 +05:30 committed by GitHub
parent b20f5e5cef
commit 2073a23d5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,8 +2,8 @@ import { mount } from '@vue/test-utils';
import Avatar from './Avatar.vue'; import Avatar from './Avatar.vue';
import Thumbnail from './Thumbnail.vue'; import Thumbnail from './Thumbnail.vue';
describe(`when there are NO errors loading the thumbnail`, () => { describe('Thumbnail.vue', () => {
it(`should render the agent thumbnail`, () => { it('should render the agent thumbnail if valid image is passed', () => {
const wrapper = mount(Thumbnail, { const wrapper = mount(Thumbnail, {
propsData: { propsData: {
src: 'https://some_valid_url.com', src: 'https://some_valid_url.com',
@ -14,14 +14,12 @@ describe(`when there are NO errors loading the thumbnail`, () => {
}; };
}, },
}); });
expect(wrapper.find('#image').exists()).toBe(true); expect(wrapper.find('.user-thumbnail').exists()).toBe(true);
const avatarComponent = wrapper.findComponent(Avatar); const avatarComponent = wrapper.findComponent(Avatar);
expect(avatarComponent.exists()).toBe(false); expect(avatarComponent.exists()).toBe(false);
}); });
});
describe(`when there ARE errors loading the thumbnail`, () => { it('should render the avatar component if invalid image is passed', () => {
it(`should render the agent avatar`, () => {
const wrapper = mount(Thumbnail, { const wrapper = mount(Thumbnail, {
propsData: { propsData: {
src: 'https://some_invalid_url.com', src: 'https://some_invalid_url.com',
@ -32,19 +30,17 @@ describe(`when there ARE errors loading the thumbnail`, () => {
}; };
}, },
}); });
expect(wrapper.find('#image').exists()).toBe(false); expect(wrapper.find('.avatar-container').exists()).toBe(true);
const avatarComponent = wrapper.findComponent(Avatar); const avatarComponent = wrapper.findComponent(Avatar);
expect(avatarComponent.exists()).toBe(true); expect(avatarComponent.exists()).toBe(true);
}); });
});
describe(`when Avatar shows`, () => { it('should the initial of the name if no image is passed', () => {
it(`initials shold correspond to username`, () => {
const wrapper = mount(Avatar, { const wrapper = mount(Avatar, {
propsData: { propsData: {
username: 'Angie Rojas', username: 'Angie Rojas',
}, },
}); });
expect(wrapper.find('span').text()).toBe('AR'); expect(wrapper.find('div').text()).toBe('AR');
}); });
}); });