debian-mirror-gitlab/spec/javascripts/pipelines/async_button_spec.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
import asyncButtonComp from '~/pipelines/components/async_button.vue';
2017-09-10 17:25:29 +05:30
import eventHub from '~/pipelines/event_hub';
2017-08-17 22:00:37 +05:30
describe('Pipelines Async Button', () => {
let component;
let AsyncButtonComponent;
beforeEach(() => {
AsyncButtonComponent = Vue.extend(asyncButtonComp);
component = new AsyncButtonComponent({
propsData: {
endpoint: '/foo',
title: 'Foo',
2018-03-17 18:26:18 +05:30
icon: 'repeat',
2017-08-17 22:00:37 +05:30
cssClass: 'bar',
2018-03-27 19:54:05 +05:30
pipelineId: 123,
type: 'explode',
2017-08-17 22:00:37 +05:30
},
}).$mount();
});
it('should render a button', () => {
expect(component.$el.tagName).toEqual('BUTTON');
});
2018-03-17 18:26:18 +05:30
it('should render svg icon', () => {
expect(component.$el.querySelector('svg')).not.toBeNull();
2017-08-17 22:00:37 +05:30
});
it('should render the provided title', () => {
2017-09-10 17:25:29 +05:30
expect(component.$el.getAttribute('data-original-title')).toContain('Foo');
2017-08-17 22:00:37 +05:30
expect(component.$el.getAttribute('aria-label')).toContain('Foo');
});
it('should render the provided cssClass', () => {
expect(component.$el.getAttribute('class')).toContain('bar');
});
describe('With confirm dialog', () => {
it('should call the service when confimation is positive', () => {
2018-03-27 19:54:05 +05:30
eventHub.$on('openConfirmationModal', (data) => {
expect(data.pipelineId).toEqual(123);
expect(data.type).toEqual('explode');
2017-09-10 17:25:29 +05:30
});
2017-08-17 22:00:37 +05:30
component = new AsyncButtonComponent({
propsData: {
endpoint: '/foo',
title: 'Foo',
icon: 'fa fa-foo',
cssClass: 'bar',
2018-03-27 19:54:05 +05:30
pipelineId: 123,
type: 'explode',
2017-08-17 22:00:37 +05:30
},
}).$mount();
component.$el.click();
});
});
});