diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-10-18 09:19:29 +0200 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-10-30 10:30:15 +0100 |
commit | 667cd6257e21c4f468bf20575c70c6e159ff42c8 (patch) | |
tree | 9d7ee804188b4e0c5987457f25be179047908d59 | |
parent | 8e828bef989bf6d2af3634630efe87a5cda86b6b (diff) | |
download | gitlab-ce-667cd6257e21c4f468bf20575c70c6e159ff42c8.tar.gz |
Improved Var Caching, Line Setup, Specs
3 files changed, 20 insertions, 18 deletions
diff --git a/app/assets/javascripts/pipelines/components/graph/action_component.vue b/app/assets/javascripts/pipelines/components/graph/action_component.vue index 2ef98d1d418..0ca86d09dbd 100644 --- a/app/assets/javascripts/pipelines/components/graph/action_component.vue +++ b/app/assets/javascripts/pipelines/components/graph/action_component.vue @@ -39,7 +39,8 @@ computed: { cssClass() { - return `${gl.text.dasherize(this.actionIcon)} js-icon-${gl.text.dasherize(this.actionIcon)}`; + const actionIconDash = gl.text.dasherize(this.actionIcon) + return `${actionIconDash} js-icon-${actionIconDash}`; }, }, }; @@ -53,7 +54,6 @@ class="ci-action-icon-container ci-action-icon-wrapper" :class="cssClass" data-container="body"> - <icon - :name="actionIcon"/> + <icon :name="actionIcon"/> </a> </template> diff --git a/app/assets/javascripts/pipelines/components/graph/dropdown_action_component.vue b/app/assets/javascripts/pipelines/components/graph/dropdown_action_component.vue index 9d889b39f7e..1c0944d45fc 100644 --- a/app/assets/javascripts/pipelines/components/graph/dropdown_action_component.vue +++ b/app/assets/javascripts/pipelines/components/graph/dropdown_action_component.vue @@ -48,7 +48,6 @@ class="ci-action-icon-wrapper js-ci-status-icon" data-container="body" aria-label="Job's action"> - <icon - :name="actionIcon"/> + <icon :name="actionIcon"/> </a> </template> diff --git a/spec/javascripts/vue_shared/components/icon_spec.js b/spec/javascripts/vue_shared/components/icon_spec.js index e2922ca2ca1..104da4473ce 100644 --- a/spec/javascripts/vue_shared/components/icon_spec.js +++ b/spec/javascripts/vue_shared/components/icon_spec.js @@ -1,41 +1,44 @@ import Vue from 'vue'; import Icon from '~/vue_shared/components/icon.vue'; - -const IconComponent = Vue.extend(Icon); +import mountComponent from '../../helpers/vue_mount_component_helper'; describe('Sprite Icon Component', function () { describe('Initialization', function () { + let icon; + beforeEach(function () { - this.propsData = { + const IconComponent = Vue.extend(Icon); + + icon = mountComponent(IconComponent, { name: 'test', size: 99, cssClasses: 'extraclasses', - }; + }); + }); - this.icon = new IconComponent({ - propsData: this.propsData, - }).$mount(); + afterEach(() => { + icon.$destroy(); }); it('should return a defined Vue component', function () { - expect(this.icon).toBeDefined(); + expect(icon).toBeDefined(); }); it('should have <svg> as a child element', function () { - expect(this.icon.$el.tagName).toBe('svg'); + expect(icon.$el.tagName).toBe('svg'); }); it('should have <use> as a child element with the correct href', function () { - expect(this.icon.$el.firstChild.tagName).toBe('use'); - expect(this.icon.$el.firstChild.getAttribute('xlink:href')).toBe(`${gon.sprite_icons}#test`); + expect(icon.$el.firstChild.tagName).toBe('use'); + expect(icon.$el.firstChild.getAttribute('xlink:href')).toBe(`${gon.sprite_icons}#test`); }); it('should properly compute iconSizeClass', function () { - expect(this.icon.iconSizeClass).toBe('s99'); + expect(icon.iconSizeClass).toBe('s99'); }); it('should properly render img css', function () { - const classList = this.icon.$el.classList; + const classList = icon.$el.classList; const containsSizeClass = classList.contains('s99'); const containsCustomClass = classList.contains('extraclasses'); expect(containsSizeClass).toBe(true); |