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

45 lines
1.2 KiB
JavaScript
Raw Normal View History

import Vue from 'vue';
import store from '~/notes/stores';
import issueNote from '~/notes/components/issue_note.vue';
import { issueDataMock, notesDataMock, note } from '../mock_data';
2017-08-04 11:51:35 -04:00
describe('issue_note', () => {
let vm;
beforeEach(() => {
const Component = Vue.extend(issueNote);
2017-08-04 11:51:35 -04:00
store.dispatch('setIssueData', issueDataMock);
store.dispatch('setNotesData', notesDataMock);
vm = new Component({
store,
propsData: {
note,
},
}).$mount();
2017-08-04 11:51:35 -04:00
});
afterEach(() => {
vm.$destroy();
});
2017-08-04 11:51:35 -04:00
it('should render user information', () => {
expect(vm.$el.querySelector('.user-avatar-link img').getAttribute('src')).toEqual(note.author.avatar_url);
2017-08-04 11:51:35 -04:00
});
it('should render note header content', () => {
expect(vm.$el.querySelector('.note-header .note-header-author-name').textContent.trim()).toEqual(note.author.name);
expect(vm.$el.querySelector('.note-header .note-headline-meta').textContent.trim()).toContain('commented');
});
2017-08-04 11:51:35 -04:00
it('should render note actions', () => {
expect(vm.$el.querySelector('.note-actions')).toBeDefined();
2017-08-04 11:51:35 -04:00
});
it('should render issue body', () => {
expect(vm.$el.querySelector('.note-text').innerHTML).toEqual(note.note_html);
2017-08-04 11:51:35 -04:00
});
});