gitlab-org--gitlab-foss/spec/frontend/notes/components/note_body_spec.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

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-04 11:51:35 -04:00
describe('issue_note_body component', () => {
2018-06-21 08:22:40 -04:00
let store;
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);
store.dispatch('setNotesData', notesDataMock);
vm = new Component({
store,
propsData: {
note,
canEdit: true,
canAwardEmoji: true,
},
}).$mount();
2017-08-04 11:51:35 -04:00
});
afterEach(() => {
vm.$destroy();
});
2017-08-04 11:51:35 -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
});
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
describe('isEditing', () => {
2018-06-21 08:22:40 -04:00
beforeEach(done => {
vm.isEditing = true;
Vue.nextTick(done);
});
2017-08-04 11:51:35 -04: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
});
});