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

51 lines
1.4 KiB
JavaScript
Raw Normal View History

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', () => {
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')).toBeDefined();
});
2017-08-04 11:51:35 -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
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).toBeDefined();
expect(vm.isReplying).toEqual(true);
done();
2017-08-04 11:51:35 -04:00
});
});
});
});