debian-mirror-gitlab/spec/javascripts/pipelines/graph/action_component_spec.js

64 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
import actionComponent from '~/pipelines/components/graph/action_component.vue';
2018-10-15 14:42:47 +05:30
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
2018-05-09 12:01:36 +05:30
import mountComponent from '../../helpers/vue_mount_component_helper';
2017-08-17 22:00:37 +05:30
describe('pipeline graph action component', () => {
let component;
2018-10-15 14:42:47 +05:30
let mock;
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
beforeEach(done => {
2017-08-17 22:00:37 +05:30
const ActionComponent = Vue.extend(actionComponent);
2018-10-15 14:42:47 +05:30
mock = new MockAdapter(axios);
mock.onPost('foo.json').reply(200);
2018-05-09 12:01:36 +05:30
component = mountComponent(ActionComponent, {
tooltipText: 'bar',
link: 'foo',
actionIcon: 'cancel',
});
2017-09-10 17:25:29 +05:30
Vue.nextTick(done);
2017-08-17 22:00:37 +05:30
});
2018-05-09 12:01:36 +05:30
afterEach(() => {
2018-10-15 14:42:47 +05:30
mock.restore();
2018-05-09 12:01:36 +05:30
component.$destroy();
});
2017-08-17 22:00:37 +05:30
it('should render the provided title as a bootstrap tooltip', () => {
expect(component.$el.getAttribute('data-original-title')).toEqual('bar');
});
2018-10-15 14:42:47 +05:30
it('should update bootstrap tooltip when title changes', done => {
2017-08-17 22:00:37 +05:30
component.tooltipText = 'changed';
2018-10-15 14:42:47 +05:30
component.$nextTick()
.then(() => {
expect(component.$el.getAttribute('data-original-title')).toBe('changed');
})
.then(done)
.catch(done.fail);
2017-08-17 22:00:37 +05:30
});
it('should render an svg', () => {
expect(component.$el.querySelector('.ci-action-icon-wrapper')).toBeDefined();
expect(component.$el.querySelector('svg')).toBeDefined();
});
2018-10-15 14:42:47 +05:30
describe('on click', () => {
it('emits `pipelineActionRequestComplete` after a successfull request', done => {
spyOn(component, '$emit');
component.$el.click();
component.$nextTick()
.then(() => {
expect(component.$emit).toHaveBeenCalledWith('pipelineActionRequestComplete');
})
.then(done)
.catch(done.fail);
});
});
2017-08-17 22:00:37 +05:30
});