2017-08-17 22:00:37 +05:30
|
|
|
import Vue from 'vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
import mountComponent from 'helpers/vue_mount_component_helper';
|
2020-01-01 13:55:28 +05:30
|
|
|
import relatedLinksComponent from '~/vue_merge_request_widget/components/mr_widget_related_links.vue';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe('MRWidgetRelatedLinks', () => {
|
|
|
|
let vm;
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
const createComponent = data => {
|
2018-03-17 18:26:18 +05:30
|
|
|
const Component = Vue.extend(relatedLinksComponent);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
return mountComponent(Component, data);
|
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('computed', () => {
|
2017-09-10 17:25:29 +05:30
|
|
|
describe('closesText', () => {
|
2018-03-17 18:26:18 +05:30
|
|
|
it('returns Closes text for open merge request', () => {
|
|
|
|
vm = createComponent({ state: 'open', relatedLinks: {} });
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(vm.closesText).toEqual('Closes');
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it('returns correct text for closed merge request', () => {
|
2018-03-17 18:26:18 +05:30
|
|
|
vm = createComponent({ state: 'closed', relatedLinks: {} });
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(vm.closesText).toEqual('Did not close');
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it('returns correct tense for merged request', () => {
|
2018-03-17 18:26:18 +05:30
|
|
|
vm = createComponent({ state: 'merged', relatedLinks: {} });
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(vm.closesText).toEqual('Closed');
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('should have only have closing issues text', () => {
|
|
|
|
vm = createComponent({
|
|
|
|
relatedLinks: {
|
|
|
|
closing: '<a href="#">#23</a> and <a>#42</a>',
|
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim();
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(content).toContain('Closes #23 and #42');
|
|
|
|
expect(content).not.toContain('Mentions');
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('should have only have mentioned issues text', () => {
|
|
|
|
vm = createComponent({
|
|
|
|
relatedLinks: {
|
|
|
|
mentioned: '<a href="#">#7</a>',
|
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$el.innerText).toContain('Mentions #7');
|
|
|
|
expect(vm.$el.innerText).not.toContain('Closes');
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('should have closing and mentioned issues at the same time', () => {
|
|
|
|
vm = createComponent({
|
|
|
|
relatedLinks: {
|
|
|
|
closing: '<a href="#">#7</a>',
|
|
|
|
mentioned: '<a href="#">#23</a> and <a>#42</a>',
|
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
const content = vm.$el.textContent.replace(/\n(\s)+/g, ' ').trim();
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(content).toContain('Closes #7');
|
|
|
|
expect(content).toContain('Mentions #23 and #42');
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('should have assing issues link', () => {
|
|
|
|
vm = createComponent({
|
|
|
|
relatedLinks: {
|
|
|
|
assignToMe: '<a href="#">Assign yourself to these issues</a>',
|
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
expect(vm.$el.innerText).toContain('Assign yourself to these issues');
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|