diff options
Diffstat (limited to 'spec/javascripts/vue_shared/components/icon_spec.js')
-rw-r--r-- | spec/javascripts/vue_shared/components/icon_spec.js | 29 |
1 files changed, 16 insertions, 13 deletions
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); |