debian-mirror-gitlab/spec/frontend/vue_mr_widget/components/mr_widget_merge_help_spec.js

71 lines
2 KiB
JavaScript
Raw Normal View History

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 mergeHelpComponent from '~/vue_merge_request_widget/components/mr_widget_merge_help.vue';
2017-08-17 22:00:37 +05:30
describe('MRWidgetMergeHelp', () => {
2018-03-17 18:26:18 +05:30
let vm;
let Component;
beforeEach(() => {
Component = Vue.extend(mergeHelpComponent);
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
2018-03-17 18:26:18 +05:30
describe('with missing branch', () => {
2017-08-17 22:00:37 +05:30
beforeEach(() => {
2018-03-17 18:26:18 +05:30
vm = mountComponent(Component, {
missingBranch: 'this-is-not-the-branch-you-are-looking-for',
});
2017-08-17 22:00:37 +05:30
});
2018-03-17 18:26:18 +05:30
it('renders missing branch information', () => {
expect(
2018-12-13 13:39:08 +05:30
vm.$el.textContent
.trim()
.replace(/[\r\n]+/g, ' ')
.replace(/\s\s+/g, ' '),
2018-03-17 18:26:18 +05:30
).toEqual(
'If the this-is-not-the-branch-you-are-looking-for branch exists in your local repository, you can merge this merge request manually using the command line',
);
2017-08-17 22:00:37 +05:30
});
2018-03-17 18:26:18 +05:30
it('renders button to open help modal', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.js-open-modal-help').getAttribute('data-target')).toEqual(
'#modal_merge_info',
);
expect(vm.$el.querySelector('.js-open-modal-help').getAttribute('data-toggle')).toEqual(
'modal',
);
2018-03-17 18:26:18 +05:30
});
});
describe('without missing branch', () => {
beforeEach(() => {
vm = mountComponent(Component);
});
it('renders information about how to merge manually', () => {
expect(
2018-12-13 13:39:08 +05:30
vm.$el.textContent
.trim()
.replace(/[\r\n]+/g, ' ')
.replace(/\s\s+/g, ' '),
).toEqual('You can merge this merge request manually using the command line');
2018-03-17 18:26:18 +05:30
});
it('renders element to open a modal', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.js-open-modal-help').getAttribute('data-target')).toEqual(
'#modal_merge_info',
);
expect(vm.$el.querySelector('.js-open-modal-help').getAttribute('data-toggle')).toEqual(
'modal',
);
2017-08-17 22:00:37 +05:30
});
});
});