2017-08-11 11:52:29 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import store from '~/notes/stores';
|
|
|
|
import issueDiscussion from '~/notes/components/issue_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', () => {
|
|
|
|
expect(vm.$el.querySelector('.user-avatar-link')).toBeDefined();
|
|
|
|
});
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:52:29 -04:00
|
|
|
it('should render discussion header', () => {
|
|
|
|
expect(vm.$el.querySelector('.discussion-header')).toBeDefined();
|
|
|
|
expect(vm.$el.querySelectorAll('.notes li').length).toEqual(discussionMock.notes.length);
|
|
|
|
});
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-11 11:52:29 -04:00
|
|
|
describe('actions', () => {
|
|
|
|
it('should render reply button', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-vue-discussion-reply').textContent.trim()).toEqual('Reply...');
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
|
2017-08-11 11:52:29 -04:00
|
|
|
it('should toggle reply form', (done) => {
|
|
|
|
vm.$el.querySelector('.js-vue-discussion-reply').click();
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
expect(vm.$refs.noteForm).toBeDefined();
|
|
|
|
expect(vm.isReplying).toEqual(true);
|
|
|
|
done();
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-08-09 15:13:00 -04:00
|
|
|
});
|