debian-mirror-gitlab/spec/javascripts/vue_mr_widget/components/states/mr_widget_closed_spec.js

70 lines
2 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2018-03-27 19:54:05 +05:30
import mountComponent from 'spec/helpers/vue_mount_component_helper';
2020-01-01 13:55:28 +05:30
import closedComponent from '~/vue_merge_request_widget/components/states/mr_widget_closed.vue';
2017-08-17 22:00:37 +05:30
describe('MRWidgetClosed', () => {
2018-03-17 18:26:18 +05:30
let vm;
beforeEach(() => {
const Component = Vue.extend(closedComponent);
2018-12-13 13:39:08 +05:30
vm = mountComponent(Component, {
mr: {
metrics: {
mergedBy: {},
closedBy: {
name: 'Administrator',
username: 'root',
webUrl: 'http://localhost:3000/root',
avatarUrl:
'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
},
mergedAt: 'Jan 24, 2018 1:02pm GMT+0000',
closedAt: 'Jan 24, 2018 1:02pm GMT+0000',
readableMergedAt: '',
readableClosedAt: 'less than a minute ago',
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
targetBranchPath: '/twitter/flight/commits/so_long_jquery',
targetBranch: 'so_long_jquery',
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +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
it('renders warning icon', () => {
expect(vm.$el.querySelector('.js-ci-status-icon-warning')).not.toBeNull();
2017-08-17 22:00:37 +05:30
});
2018-03-17 18:26:18 +05:30
it('renders closed by information with author and time', () => {
expect(
2018-12-13 13:39:08 +05:30
vm.$el
.querySelector('.js-mr-widget-author')
.textContent.trim()
.replace(/\s\s+/g, ' '),
).toContain('Closed by Administrator less than a minute ago');
2017-08-17 22:00:37 +05:30
});
2018-03-17 18:26:18 +05:30
it('links to the user that closed the MR', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.author-link').getAttribute('href')).toEqual(
'http://localhost:3000/root',
);
2018-03-17 18:26:18 +05:30
});
it('renders information about the changes not being merged', () => {
expect(
2018-12-13 13:39:08 +05:30
vm.$el
.querySelector('.mr-info-list')
.textContent.trim()
.replace(/\s\s+/g, ' '),
2018-03-17 18:26:18 +05:30
).toContain('The changes were not merged into so_long_jquery');
});
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
it('renders link for target branch', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.label-branch').getAttribute('href')).toEqual(
'/twitter/flight/commits/so_long_jquery',
);
2017-08-17 22:00:37 +05:30
});
});