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