2017-08-11 11:52:29 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import store from '~/notes/stores';
|
2017-12-08 15:24:52 -05:00
|
|
|
import issueDiscussion from '~/notes/components/noteable_discussion.vue';
|
2017-11-30 17:44:41 -05:00
|
|
|
import { noteableDataMock, discussionMock, notesDataMock } from '../mock_data';
|
2017-08-10 13:36:39 -04:00
|
|
|
|
2017-08-04 11:51:35 -04:00
|
|
|
describe('issue_discussion component', () => {
|
2017-08-11 11:52:29 -04:00
|
|
|
let vm;
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:52:29 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
const Component = Vue.extend(issueDiscussion);
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-11-30 17:44:41 -05:00
|
|
|
store.dispatch('setNoteableData', noteableDataMock);
|
2017-08-11 11:52:29 -04:00
|
|
|
store.dispatch('setNotesData', notesDataMock);
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:52:29 -04:00
|
|
|
vm = new Component({
|
|
|
|
store,
|
|
|
|
propsData: {
|
|
|
|
note: discussionMock,
|
|
|
|
},
|
|
|
|
}).$mount();
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
|
2017-08-11 11:52:29 -04:00
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:52:29 -04:00
|
|
|
it('should render user avatar', () => {
|
2018-03-28 01:11:06 -04:00
|
|
|
expect(vm.$el.querySelector('.user-avatar-link')).not.toBeNull();
|
2017-08-11 11:52:29 -04:00
|
|
|
});
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:52:29 -04:00
|
|
|
it('should render discussion header', () => {
|
2018-03-28 01:11:06 -04:00
|
|
|
expect(vm.$el.querySelector('.discussion-header')).not.toBeNull();
|
2017-12-08 15:24:52 -05:00
|
|
|
expect(vm.$el.querySelector('.notes').children.length).toEqual(discussionMock.notes.length);
|
2017-08-11 11:52:29 -04:00
|
|
|
});
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:52:29 -04:00
|
|
|
describe('actions', () => {
|
|
|
|
it('should render reply button', () => {
|
2018-03-28 01:11:06 -04:00
|
|
|
expect(vm.$el.querySelector('.js-vue-discussion-reply').textContent.trim()).toEqual(
|
|
|
|
'Reply...',
|
|
|
|
);
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
|
2018-03-28 01:11:06 -04:00
|
|
|
it('should toggle reply form', done => {
|
2017-08-11 11:52:29 -04:00
|
|
|
vm.$el.querySelector('.js-vue-discussion-reply').click();
|
|
|
|
Vue.nextTick(() => {
|
2018-03-28 01:11:06 -04:00
|
|
|
expect(vm.$refs.noteForm).not.toBeNull();
|
2017-08-11 11:52:29 -04:00
|
|
|
expect(vm.isReplying).toEqual(true);
|
|
|
|
done();
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
});
|
2018-03-28 01:11:06 -04:00
|
|
|
|
|
|
|
it('does not render jump to discussion button', () => {
|
|
|
|
expect(
|
|
|
|
vm.$el.querySelector('*[data-original-title="Jump to next unresolved discussion"]'),
|
|
|
|
).toBeNull();
|
|
|
|
});
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
2017-08-09 15:13:00 -04:00
|
|
|
});
|