diff options
author | Fatih Acet <acetfatih@gmail.com> | 2017-10-27 12:50:58 +0000 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2017-10-27 12:50:58 +0000 |
commit | ab9b54f977b921267f7703f170216fb3594d00a5 (patch) | |
tree | ccc4d1f5ed222b96f0190f846ec5267ddd6ee357 /spec/javascripts | |
parent | 172ebcb8bb9c0b4d3c565560880fc604cae02b5e (diff) | |
parent | 4e8010aa9d8bdb05c3999691731daa2e8e99c9d8 (diff) | |
download | gitlab-ce-ab9b54f977b921267f7703f170216fb3594d00a5.tar.gz |
Merge branch 'add-user-avatar-username-link' into 'master'
Add configurable option to display username in user avatar link component
See merge request gitlab-org/gitlab-ce!14902
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/vue_shared/components/user_avatar/user_avatar_link_spec.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/javascripts/vue_shared/components/user_avatar/user_avatar_link_spec.js b/spec/javascripts/vue_shared/components/user_avatar/user_avatar_link_spec.js index 52e450e9ba5..8450ad9dbcb 100644 --- a/spec/javascripts/vue_shared/components/user_avatar/user_avatar_link_spec.js +++ b/spec/javascripts/vue_shared/components/user_avatar/user_avatar_link_spec.js @@ -11,6 +11,7 @@ describe('User Avatar Link Component', function () { imgCssClasses: 'myextraavatarclass', tooltipText: 'tooltip text', tooltipPlacement: 'bottom', + username: 'username', }; const UserAvatarLinkComponent = Vue.extend(UserAvatarLink); @@ -47,4 +48,42 @@ describe('User Avatar Link Component', function () { expect(this.userAvatarLink[key]).toBeDefined(); }); }); + + describe('no username', function () { + beforeEach(function (done) { + this.userAvatarLink.username = ''; + + Vue.nextTick(done); + }); + + it('should only render image tag in link', function () { + const childElements = this.userAvatarLink.$el.childNodes; + expect(childElements[0].tagName).toBe('IMG'); + + // Vue will render the hidden component as <!----> + expect(childElements[1].tagName).toBeUndefined(); + }); + + it('should render avatar image tooltip', function () { + expect(this.userAvatarLink.$el.querySelector('img').dataset.originalTitle).toEqual(this.propsData.tooltipText); + }); + }); + + describe('username', function () { + it('should not render avatar image tooltip', function () { + expect(this.userAvatarLink.$el.querySelector('img').dataset.originalTitle).toEqual(''); + }); + + it('should render username prop in <span>', function () { + expect(this.userAvatarLink.$el.querySelector('span').innerText.trim()).toEqual(this.propsData.username); + }); + + it('should render text tooltip for <span>', function () { + expect(this.userAvatarLink.$el.querySelector('span').dataset.originalTitle).toEqual(this.propsData.tooltipText); + }); + + it('should render text tooltip placement for <span>', function () { + expect(this.userAvatarLink.$el.querySelector('span').getAttribute('tooltip-placement')).toEqual(this.propsData.tooltipPlacement); + }); + }); }); |