Compare commits

...

1 commit

Author SHA1 Message Date
Muhsin
c0779912cb Fix the thumbnail specs 2022-10-28 15:22:38 +05:30

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');
}); });
}); });