gitlab-org--gitlab-foss/spec/javascripts/notes/components/noteable_discussion_spec.js

59 lines
1.6 KiB
JavaScript
Raw Normal View History

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', () => {
let vm;
2017-08-04 11:51:35 -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);
store.dispatch('setNotesData', notesDataMock);
2017-08-04 11:51:35 -04:00
vm = new Component({
store,
propsData: {
note: discussionMock,
},
}).$mount();
2017-08-04 11:51:35 -04:00
});
afterEach(() => {
vm.$destroy();
});
2017-08-04 11:51:35 -04:00
it('should render user avatar', () => {
expect(vm.$el.querySelector('.user-avatar-link')).not.toBeNull();
});
2017-08-04 11:51:35 -04:00
it('should render discussion header', () => {
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-04 11:51:35 -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
});
it('should toggle reply form', done => {
vm.$el.querySelector('.js-vue-discussion-reply').click();
Vue.nextTick(() => {
expect(vm.$refs.noteForm).not.toBeNull();
expect(vm.isReplying).toEqual(true);
done();
2017-08-04 11:51:35 -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
});
});