Commit d37881b7 authored by Filipa Lacerda's avatar Filipa Lacerda

[ci skip] Adds unit tests for issue_note_header component

parent c15174c0
......@@ -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"
......
import Vue from 'vue';
import issueNoteHeader from '~/notes/components/issue_note_header.vue';
import store from '~/notes/stores';
describe('issue_note_header component', () => {
it('should render user information', () => {
let vm;
let Component;
beforeEach(() => {
Component = Vue.extend(issueNoteHeader);
});
afterEach(() => {
vm.$destroy();
});
it('should render timestamp link', () => {
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', () => {
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();
});
});
});
});
\ No newline at end of file
});
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment