2017-08-11 16:36:59 +00:00
|
|
|
import Vue from 'vue';
|
2018-06-21 12:22:40 +00:00
|
|
|
import createStore from '~/notes/stores';
|
2017-12-08 20:24:52 +00:00
|
|
|
import noteBody from '~/notes/components/note_body.vue';
|
2017-11-30 22:44:41 +00:00
|
|
|
import { noteableDataMock, notesDataMock, note } from '../mock_data';
|
2017-08-11 16:36:59 +00:00
|
|
|
|
2017-08-04 15:51:35 +00:00
|
|
|
describe('issue_note_body component', () => {
|
2018-06-21 12:22:40 +00:00
|
|
|
let store;
|
2017-08-11 16:36:59 +00:00
|
|
|
let vm;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
const Component = Vue.extend(noteBody);
|
2017-08-04 15:51:35 +00:00
|
|
|
|
2018-06-21 12:22:40 +00:00
|
|
|
store = createStore();
|
2017-11-30 22:44:41 +00:00
|
|
|
store.dispatch('setNoteableData', noteableDataMock);
|
2017-08-11 16:36:59 +00:00
|
|
|
store.dispatch('setNotesData', notesDataMock);
|
|
|
|
|
|
|
|
vm = new Component({
|
|
|
|
store,
|
|
|
|
propsData: {
|
|
|
|
note,
|
|
|
|
canEdit: true,
|
2018-04-06 18:19:37 +00:00
|
|
|
canAwardEmoji: true,
|
2017-08-11 16:36:59 +00:00
|
|
|
},
|
|
|
|
}).$mount();
|
2017-08-04 15:51:35 +00:00
|
|
|
});
|
|
|
|
|
2017-08-11 16:36:59 +00:00
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
2017-08-04 15:51:35 +00:00
|
|
|
|
2017-08-11 16:36:59 +00:00
|
|
|
it('should render the note', () => {
|
|
|
|
expect(vm.$el.querySelector('.note-text').innerHTML).toEqual(note.note_html);
|
2017-08-04 15:51:35 +00:00
|
|
|
});
|
|
|
|
|
2018-02-28 00:10:43 +00:00
|
|
|
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();
|
|
|
|
});
|
2017-08-04 15:51:35 +00:00
|
|
|
|
2018-02-28 00:10:43 +00:00
|
|
|
describe('isEditing', () => {
|
2018-06-21 12:22:40 +00:00
|
|
|
beforeEach(done => {
|
2018-02-28 00:10:43 +00:00
|
|
|
vm.isEditing = true;
|
|
|
|
Vue.nextTick(done);
|
2017-08-11 16:36:59 +00:00
|
|
|
});
|
2017-08-04 15:51:35 +00:00
|
|
|
|
2018-02-28 00:10:43 +00:00
|
|
|
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);
|
|
|
|
});
|
2017-08-04 15:51:35 +00:00
|
|
|
});
|
2017-08-09 19:13:00 +00:00
|
|
|
});
|