2018-02-27 19:10:43 -05:00
|
|
|
import Vue from 'vue';
|
|
|
|
import DiffWithNote from '~/notes/components/diff_with_note.vue';
|
2018-10-18 03:50:38 -04:00
|
|
|
import { createStore } from '~/mr_notes/stores';
|
2018-06-21 08:22:40 -04:00
|
|
|
import { mountComponentWithStore } from 'spec/helpers';
|
2018-02-27 19:10:43 -05:00
|
|
|
|
|
|
|
const discussionFixture = 'merge_requests/diff_discussion.json';
|
|
|
|
const imageDiscussionFixture = 'merge_requests/image_diff_discussion.json';
|
|
|
|
|
|
|
|
describe('diff_with_note', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
let store;
|
2018-02-27 19:10:43 -05:00
|
|
|
let vm;
|
|
|
|
const diffDiscussionMock = getJSONFixture(discussionFixture)[0];
|
2018-11-09 14:48:41 -05:00
|
|
|
const diffDiscussion = diffDiscussionMock;
|
2018-02-27 19:10:43 -05:00
|
|
|
const Component = Vue.extend(DiffWithNote);
|
|
|
|
const props = {
|
|
|
|
discussion: diffDiscussion,
|
|
|
|
};
|
|
|
|
const selectors = {
|
|
|
|
get container() {
|
2018-11-09 04:44:07 -05:00
|
|
|
return vm.$el;
|
2018-02-27 19:10:43 -05:00
|
|
|
},
|
|
|
|
get diffTable() {
|
|
|
|
return this.container.querySelector('.diff-content table');
|
|
|
|
},
|
|
|
|
get diffRows() {
|
|
|
|
return this.container.querySelectorAll('.diff-content .line_holder');
|
|
|
|
},
|
|
|
|
get noteRow() {
|
|
|
|
return this.container.querySelector('.diff-content .notes_holder');
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-06-21 08:22:40 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
store = createStore();
|
|
|
|
store.replaceState({
|
|
|
|
...store.state,
|
|
|
|
notes: {
|
|
|
|
noteableData: {
|
|
|
|
current_user: {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-02-27 19:10:43 -05:00
|
|
|
describe('text diff', () => {
|
|
|
|
beforeEach(() => {
|
2018-06-21 08:22:40 -04:00
|
|
|
vm = mountComponentWithStore(Component, { props, store });
|
2018-02-27 19:10:43 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('shows text diff', () => {
|
|
|
|
expect(selectors.container).toHaveClass('text-file');
|
|
|
|
expect(selectors.diffTable).toExist();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows diff lines', () => {
|
|
|
|
expect(selectors.diffRows.length).toBe(12);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows notes row', () => {
|
|
|
|
expect(selectors.noteRow).toExist();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('image diff', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
const imageDiffDiscussionMock = getJSONFixture(imageDiscussionFixture)[0];
|
2018-11-09 14:48:41 -05:00
|
|
|
props.discussion = imageDiffDiscussionMock;
|
2018-02-27 19:10:43 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('shows image diff', () => {
|
2018-06-21 08:22:40 -04:00
|
|
|
vm = mountComponentWithStore(Component, { props, store });
|
2018-02-27 19:10:43 -05:00
|
|
|
|
|
|
|
expect(selectors.diffTable).not.toExist();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|