debian-mirror-gitlab/spec/javascripts/notes/components/noteable_discussion_spec.js

59 lines
1.6 KiB
JavaScript
Raw Normal View History

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