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 @@ ...@@ -34,6 +34,7 @@
toggleHandler: { toggleHandler: {
type: Function, type: Function,
required: false, required: false,
default: () => {},
}, },
}, },
data() { data() {
...@@ -102,7 +103,7 @@ ...@@ -102,7 +103,7 @@
class="discussion-actions"> class="discussion-actions">
<button <button
@click="handleToggle" @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"> type="button">
<i <i
:class="toggleChevronClass" :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', () => { 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', () => { 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', () => { 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', () => { ...@@ -15,6 +15,10 @@ describe('issue placeholder system note component', () => {
}).$mount(); }).$mount();
}); });
afterEach(() => {
vm.$destroy();
});
describe('user information', () => { describe('user information', () => {
it('should render user avatar with link', () => { it('should render user avatar with link', () => {
expect(vm.$el.querySelector('.user-avatar-link').getAttribute('href')).toEqual(userDataMock.path); 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