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

57 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import store from '~/notes/stores';
import noteBody from '~/notes/components/note_body.vue';
import { noteableDataMock, notesDataMock, note } from '../mock_data';
describe('issue_note_body component', () => {
let vm;
beforeEach(() => {
const Component = Vue.extend(noteBody);
store.dispatch('setNoteableData', noteableDataMock);
store.dispatch('setNotesData', notesDataMock);
vm = new Component({
store,
propsData: {
note,
canEdit: true,
2018-05-09 12:01:36 +05:30
canAwardEmoji: true,
2018-03-17 18:26:18 +05:30
},
}).$mount();
});
afterEach(() => {
vm.$destroy();
});
it('should render the note', () => {
expect(vm.$el.querySelector('.note-text').innerHTML).toEqual(note.note_html);
});
2018-03-27 19:54:05 +05:30
it('should render awards list', () => {
expect(vm.$el.querySelector('.js-awards-block button [data-name="baseball"]')).not.toBeNull();
expect(vm.$el.querySelector('.js-awards-block button [data-name="bath_tone3"]')).not.toBeNull();
});
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
describe('isEditing', () => {
beforeEach((done) => {
vm.isEditing = true;
Vue.nextTick(done);
2018-03-17 18:26:18 +05:30
});
2018-03-27 19:54:05 +05:30
it('renders edit form', () => {
expect(vm.$el.querySelector('textarea.js-task-list-field')).not.toBeNull();
});
it('adds autosave', () => {
const autosaveKey = `autosave/Note/${note.noteable_type}/${note.id}`;
expect(vm.autosave).toExist();
expect(vm.autosave.key).toEqual(autosaveKey);
});
2018-03-17 18:26:18 +05:30
});
});