2018-11-08 19:23:39 +05:30
|
|
|
import Vue from 'vue';
|
2019-02-15 15:39:39 +05:30
|
|
|
import '~/behaviors/markdown/render_gfm';
|
2018-11-08 19:23:39 +05:30
|
|
|
import InlineDiffView from '~/diffs/components/inline_diff_view.vue';
|
2019-05-18 00:54:41 +05:30
|
|
|
import store from 'ee_else_ce/mr_notes/stores';
|
2018-11-08 19:23:39 +05:30
|
|
|
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
|
|
|
|
import diffFileMockData from '../mock_data/diff_file';
|
|
|
|
import discussionsMockData from '../mock_data/diff_discussions';
|
|
|
|
|
|
|
|
describe('InlineDiffView', () => {
|
|
|
|
let component;
|
|
|
|
const getDiffFileMock = () => Object.assign({}, diffFileMockData);
|
|
|
|
const getDiscussionsMockData = () => [Object.assign({}, discussionsMockData)];
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
beforeEach(done => {
|
2018-11-08 19:23:39 +05:30
|
|
|
const diffFile = getDiffFileMock();
|
|
|
|
|
|
|
|
store.dispatch('diffs/setInlineDiffViewType');
|
|
|
|
component = createComponentWithStore(Vue.extend(InlineDiffView), store, {
|
|
|
|
diffFile,
|
2019-02-15 15:39:39 +05:30
|
|
|
diffLines: diffFile.highlighted_diff_lines,
|
2018-11-08 19:23:39 +05:30
|
|
|
}).$mount();
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
Vue.nextTick(done);
|
2018-11-08 19:23:39 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('template', () => {
|
|
|
|
it('should have rendered diff lines', () => {
|
|
|
|
const el = component.$el;
|
|
|
|
|
|
|
|
expect(el.querySelectorAll('tr.line_holder').length).toEqual(6);
|
|
|
|
expect(el.querySelectorAll('tr.line_holder.new').length).toEqual(2);
|
|
|
|
expect(el.querySelectorAll('tr.line_holder.match').length).toEqual(1);
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(el.textContent.indexOf('Bad dates')).toBeGreaterThan(-1);
|
2018-11-08 19:23:39 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render discussions', done => {
|
|
|
|
const el = component.$el;
|
2019-02-15 15:39:39 +05:30
|
|
|
component.diffLines[1].discussions = getDiscussionsMockData();
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
expect(el.querySelectorAll('.notes_holder').length).toEqual(1);
|
|
|
|
expect(el.querySelectorAll('.notes_holder .note-discussion li').length).toEqual(5);
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(el.innerText.indexOf('comment 5')).toBeGreaterThan(-1);
|
2018-11-08 19:23:39 +05:30
|
|
|
component.$store.dispatch('setInitialNotes', []);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|