Skip to content
Snippets Groups Projects

Consolidate user avatar Vue logic

Merged username-removed-408230 requested to merge user-avatar-vue-ce into master
All threads resolved!
2 files
+ 24
45
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -12,33 +12,23 @@ fdescribe('User Avatar Image Component', function () {
tooltipText: 'tooltip text',
};
this.vueInstance = new Vue({
data: this.propsData,
components: {
'user-avatar-image': UserAvatarImage,
},
template: `
<user-avatar-image
:size="size"
:src="src"
:alt="alt"
:css-classes="cssClasses"
:tooltip-text="tooltipText"
/>
`,
const UserAvatarImageComponent = Vue.extend(UserAvatarImage);
this.userAvatarImage = new Vue({
propsData: this.propsData,
}).$mount();
this.userAvatarImage = this.vueInstance.$children[0];
this.userAvatarImage = this.userAvatarImage.$children[0];
this.imageElement = this.userAvatarImage.$refs.tooltipTarget;
});
it('should return a defined Vue component', function () {
expect(this.vueInstance).toBeDefined();
expect(this.userAvatarImage).toBeDefined();
});
it('should have user-avatar-image as child component', function () {
expect(this.userAvatarImage).toBeDefined();
expect(this.vueInstance.$options.components['user-avatar-image']).toBeDefined();
expect(this.userAvatarImage.$options.components['user-avatar-image']).toBeDefined();
});
it('should have <img> as a child element', function () {
@@ -89,7 +79,7 @@ fdescribe('User Avatar Image Component', function () {
svg: avatarSvg,
};
this.vueInstance = new Vue({
this.userAvatarImage = new Vue({
data: this.propsData,
components: {
'user-avatar-image': UserAvatarImage,
@@ -101,7 +91,7 @@ fdescribe('User Avatar Image Component', function () {
`,
}).$mount();
this.userAvatarImageComponent = this.vueInstance.$children[0];
this.userAvatarImageComponent = this.userAvatarImage.$children[0];
this.iconElement = this.userAvatarImageComponent.$el.querySelector('svg');
this.imageElement = this.userAvatarImageComponent.$el.querySelector('img');
});
@@ -125,7 +115,7 @@ fdescribe('User Avatar Image Component', function () {
this.defaultAvatarUrl = gon.default_avatar_url;
this.propsData = {};
this.vueInstance = new Vue({
this.userAvatarImage = new Vue({
data: this.propsData,
components: {
'user-avatar-image': UserAvatarImage,
@@ -135,7 +125,7 @@ fdescribe('User Avatar Image Component', function () {
`,
}).$mount();
this.userAvatarImageComponent = this.vueInstance.$children[0];
this.userAvatarImageComponent = this.userAvatarImage.$children[0];
});
it('imgSourceWithFallback returns the default avatar URL', function () {
Loading