debian-mirror-gitlab/spec/frontend/ide/components/new_dropdown/button_spec.js

66 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-11-18 11:00:15 +05:30
import Vue from 'vue';
2020-05-24 23:13:21 +05:30
import mountComponent from 'helpers/vue_mount_component_helper';
2018-11-18 11:00:15 +05:30
import Button from '~/ide/components/new_dropdown/button.vue';
describe('IDE new entry dropdown button component', () => {
let Component;
let vm;
beforeAll(() => {
Component = Vue.extend(Button);
});
beforeEach(() => {
vm = mountComponent(Component, {
label: 'Testing',
icon: 'doc-new',
});
2020-05-24 23:13:21 +05:30
jest.spyOn(vm, '$emit').mockImplementation(() => {});
2018-11-18 11:00:15 +05:30
});
afterEach(() => {
vm.$destroy();
});
it('renders button with label', () => {
expect(vm.$el.textContent).toContain('Testing');
});
it('renders icon', () => {
2020-11-24 15:15:51 +05:30
expect(vm.$el.querySelector('[data-testid="doc-new-icon"]')).not.toBe(null);
2018-11-18 11:00:15 +05:30
});
it('emits click event', () => {
vm.$el.click();
expect(vm.$emit).toHaveBeenCalledWith('click');
});
it('hides label if showLabel is false', done => {
vm.showLabel = false;
vm.$nextTick(() => {
expect(vm.$el.textContent).not.toContain('Testing');
done();
});
});
2018-11-20 20:47:30 +05:30
describe('tooltipTitle', () => {
it('returns empty string when showLabel is true', () => {
expect(vm.tooltipTitle).toBe('');
});
it('returns label', done => {
vm.showLabel = false;
vm.$nextTick(() => {
expect(vm.tooltipTitle).toBe('Testing');
done();
});
});
});
2018-11-18 11:00:15 +05:30
});