summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_shared
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2019-02-12 20:55:56 +0000
committerFatih Acet <acetfatih@gmail.com>2019-02-12 20:55:56 +0000
commit7430149d4d7ed087eb756a21db77ea92d31d3c7c (patch)
tree7e444e14517ce1ec9dadbcede5e69f0b93adbef1 /spec/javascripts/vue_shared
parentd663c9269e4c2e14be071eb2bc8c2fee81160d86 (diff)
downloadgitlab-ce-7430149d4d7ed087eb756a21db77ea92d31d3c7c.tar.gz
Convert noteable_note_spec.js to Vue test utils
(cherry picked from commit 861f93e6fc72ef4adbc4ace3fd297382e07b619c)
Diffstat (limited to 'spec/javascripts/vue_shared')
-rw-r--r--spec/javascripts/vue_shared/components/user_avatar/user_avatar_link_spec.js18
1 files changed, 13 insertions, 5 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 f2472fd377c..80aa75847ae 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
@@ -1,13 +1,14 @@
import _ from 'underscore';
import Vue from 'vue';
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
+import { TEST_HOST } from 'spec/test_constants';
describe('User Avatar Link Component', function() {
beforeEach(function() {
this.propsData = {
- linkHref: 'myavatarurl.com',
+ linkHref: `${TEST_HOST}/myavatarurl.com`,
imgSize: 99,
- imgSrc: 'myavatarurl.com',
+ imgSrc: `${TEST_HOST}/myavatarurl.com`,
imgAlt: 'mydisplayname',
imgCssClasses: 'myextraavatarclass',
tooltipText: 'tooltip text',
@@ -37,11 +38,18 @@ describe('User Avatar Link Component', function() {
});
it('should render <a> as a child element', function() {
- expect(this.userAvatarLink.$el.tagName).toBe('A');
+ const link = this.userAvatarLink.$el;
+
+ expect(link.tagName).toBe('A');
+ expect(link.href).toBe(this.propsData.linkHref);
});
- it('should have <img> as a child element', function() {
- expect(this.userAvatarLink.$el.querySelector('img')).not.toBeNull();
+ it('renders imgSrc with imgSize as image', function() {
+ const { imgSrc, imgSize } = this.propsData;
+ const image = this.userAvatarLink.$el.querySelector('img');
+
+ expect(image).not.toBeNull();
+ expect(image.src).toBe(`${imgSrc}?width=${imgSize}`);
});
it('should return necessary props as defined', function() {