[ci skip] Adds unit tests for issue_note_header component
This commit is contained in:
parent
c15174c086
commit
d37881b75f
|
|
@ -34,6 +34,7 @@
|
|||
toggleHandler: {
|
||||
type: Function,
|
||||
required: false,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
|
|
@ -102,7 +103,7 @@
|
|||
class="discussion-actions">
|
||||
<button
|
||||
@click="handleToggle"
|
||||
class="note-action-button discussion-toggle-button js-toggle-button"
|
||||
class="note-action-button discussion-toggle-button js-vue-toggle-button"
|
||||
type="button">
|
||||
<i
|
||||
:class="toggleChevronClass"
|
||||
|
|
|
|||
|
|
@ -1,15 +1,94 @@
|
|||
describe('issue_note_header component', () => {
|
||||
it('should render user information', () => {
|
||||
import Vue from 'vue';
|
||||
import issueNoteHeader from '~/notes/components/issue_note_header.vue';
|
||||
import store from '~/notes/stores';
|
||||
|
||||
describe('issue_note_header component', () => {
|
||||
let vm;
|
||||
let Component;
|
||||
|
||||
beforeEach(() => {
|
||||
Component = Vue.extend(issueNoteHeader);
|
||||
});
|
||||
|
||||
it('should render timestamp link', () => {
|
||||
afterEach(() => {
|
||||
vm.$destroy();
|
||||
});
|
||||
|
||||
describe('individual note', () => {
|
||||
beforeEach(() => {
|
||||
vm = new Component({
|
||||
store,
|
||||
propsData: {
|
||||
actionText: 'commented',
|
||||
actionTextHtml: '',
|
||||
author: {
|
||||
avatar_url: null,
|
||||
id: 1,
|
||||
name: 'Root',
|
||||
path: '/root',
|
||||
state: 'active',
|
||||
username: 'root',
|
||||
},
|
||||
createdAt: '2017-08-02T10:51:58.559Z',
|
||||
includeToggle: false,
|
||||
noteId: 1394,
|
||||
},
|
||||
}).$mount();
|
||||
});
|
||||
|
||||
it('should render user information', () => {
|
||||
expect(
|
||||
vm.$el.querySelector('.note-header-author-name').textContent.trim(),
|
||||
).toEqual('Root');
|
||||
expect(
|
||||
vm.$el.querySelector('.note-header-info a').getAttribute('href'),
|
||||
).toEqual('/root');
|
||||
});
|
||||
|
||||
it('should render timestamp link', () => {
|
||||
expect(vm.$el.querySelector('a[href="#note_1394"]')).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('discussion', () => {
|
||||
it('should render toggle button', () => {
|
||||
beforeEach(() => {
|
||||
vm = new Component({
|
||||
store,
|
||||
propsData: {
|
||||
actionText: 'started a discussion',
|
||||
actionTextHtml: '',
|
||||
author: {
|
||||
avatar_url: null,
|
||||
id: 1,
|
||||
name: 'Root',
|
||||
path: '/root',
|
||||
state: 'active',
|
||||
username: 'root',
|
||||
},
|
||||
createdAt: '2017-08-02T10:51:58.559Z',
|
||||
includeToggle: true,
|
||||
noteId: 1395,
|
||||
},
|
||||
}).$mount();
|
||||
});
|
||||
|
||||
it('should render toggle button', () => {
|
||||
expect(vm.$el.querySelector('.js-vue-toggle-button')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should toggle the disucssion icon', (done) => {
|
||||
expect(
|
||||
vm.$el.querySelector('.js-vue-toggle-button i').classList.contains('fa-chevron-up'),
|
||||
).toEqual(true);
|
||||
|
||||
vm.$el.querySelector('.js-vue-toggle-button').click();
|
||||
|
||||
Vue.nextTick(() => {
|
||||
expect(
|
||||
vm.$el.querySelector('.js-vue-toggle-button i').classList.contains('fa-chevron-down'),
|
||||
).toEqual(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -15,6 +15,10 @@ describe('issue placeholder system note component', () => {
|
|||
}).$mount();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vm.$destroy();
|
||||
});
|
||||
|
||||
describe('user information', () => {
|
||||
it('should render user avatar with link', () => {
|
||||
expect(vm.$el.querySelector('.user-avatar-link').getAttribute('href')).toEqual(userDataMock.path);
|
||||
|
|
|
|||
Loading…
Reference in New Issue