debian-mirror-gitlab/spec/frontend/ide/components/ide_review_spec.js

72 lines
2 KiB
JavaScript
Raw Normal View History

2018-10-15 14:42:47 +05:30
import Vue from 'vue';
import IdeReview from '~/ide/components/ide_review.vue';
2020-05-24 23:13:21 +05:30
import { createStore } from '~/ide/stores';
2018-10-15 14:42:47 +05:30
import { createComponentWithStore } from '../../helpers/vue_mount_component_helper';
2019-09-04 21:01:54 +05:30
import { trimText } from '../../helpers/text_helper';
2020-10-24 23:57:45 +05:30
import { file } from '../helpers';
2018-10-15 14:42:47 +05:30
import { projectData } from '../mock_data';
describe('IDE review mode', () => {
const Component = Vue.extend(IdeReview);
let vm;
2020-05-24 23:13:21 +05:30
let store;
2018-10-15 14:42:47 +05:30
beforeEach(() => {
2020-05-24 23:13:21 +05:30
store = createStore();
2018-10-15 14:42:47 +05:30
store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master';
2020-05-24 23:13:21 +05:30
store.state.projects.abcproject = { ...projectData };
2018-10-15 14:42:47 +05:30
Vue.set(store.state.trees, 'abcproject/master', {
tree: [file('fileName')],
loading: false,
});
vm = createComponentWithStore(Component, store).$mount();
});
afterEach(() => {
vm.$destroy();
});
it('renders list of files', () => {
expect(vm.$el.textContent).toContain('fileName');
});
describe('merge request', () => {
2020-05-24 23:13:21 +05:30
beforeEach(() => {
2018-10-15 14:42:47 +05:30
store.state.currentMergeRequestId = '1';
store.state.projects.abcproject.mergeRequests['1'] = {
iid: 123,
web_url: 'testing123',
};
2020-05-24 23:13:21 +05:30
return vm.$nextTick();
2018-10-15 14:42:47 +05:30
});
it('renders edit dropdown', () => {
expect(vm.$el.querySelector('.btn')).not.toBe(null);
});
it('renders merge request link & IID', () => {
2020-05-24 23:13:21 +05:30
store.state.viewer = 'mrdiff';
2018-10-15 14:42:47 +05:30
2020-05-24 23:13:21 +05:30
return vm.$nextTick(() => {
const link = vm.$el.querySelector('.ide-review-sub-header');
expect(link.querySelector('a').getAttribute('href')).toBe('testing123');
expect(trimText(link.textContent)).toBe('Merge request (!123)');
});
2018-10-15 14:42:47 +05:30
});
2020-05-24 23:13:21 +05:30
it('changes text to latest changes when viewer is not mrdiff', () => {
2018-10-15 14:42:47 +05:30
store.state.viewer = 'diff';
2020-05-24 23:13:21 +05:30
return vm.$nextTick(() => {
2018-10-15 14:42:47 +05:30
expect(trimText(vm.$el.querySelector('.ide-review-sub-header').textContent)).toBe(
'Latest changes',
);
});
});
});
});