Commit 35425750 authored by Clement Ho's avatar Clement Ho

Merge branch 'upgrade-bootstrap-vue/system-note-tests' into 'master'

Prepare system notes spec for bv upgrade

See merge request gitlab-org/gitlab!20379
parents 1f355eab 7b34487e
import Vue from 'vue'; import { createLocalVue, mount } from '@vue/test-utils';
import issueSystemNote from '~/vue_shared/components/notes/system_note.vue'; import IssueSystemNote from '~/vue_shared/components/notes/system_note.vue';
import createStore from '~/notes/stores'; import createStore from '~/notes/stores';
import initMRPopovers from '~/mr_popover/index'; import initMRPopovers from '~/mr_popover/index';
jest.mock('~/mr_popover/index', () => jest.fn()); jest.mock('~/mr_popover/index', () => jest.fn());
const localVue = createLocalVue();
describe('system note component', () => { describe('system note component', () => {
let vm; let vm;
let props; let props;
...@@ -30,34 +32,36 @@ describe('system note component', () => { ...@@ -30,34 +32,36 @@ describe('system note component', () => {
const store = createStore(); const store = createStore();
store.dispatch('setTargetNoteHash', `note_${props.note.id}`); store.dispatch('setTargetNoteHash', `note_${props.note.id}`);
const Component = Vue.extend(issueSystemNote); vm = mount(IssueSystemNote, {
vm = new Component({
store, store,
localVue,
propsData: props, propsData: props,
}).$mount(); attachToDocument: true,
sync: false,
});
}); });
afterEach(() => { afterEach(() => {
vm.$destroy(); vm.destroy();
}); });
it('should render a list item with correct id', () => { it('should render a list item with correct id', () => {
expect(vm.$el.getAttribute('id')).toEqual(`note_${props.note.id}`); expect(vm.attributes('id')).toEqual(`note_${props.note.id}`);
}); });
it('should render target class is note is target note', () => { it('should render target class is note is target note', () => {
expect(vm.$el.classList).toContain('target'); expect(vm.classes()).toContain('target');
}); });
it('should render svg icon', () => { it('should render svg icon', () => {
expect(vm.$el.querySelector('.timeline-icon svg')).toBeDefined(); expect(vm.find('.timeline-icon svg').exists()).toBe(true);
}); });
// Redcarpet Markdown renderer wraps text in `<p>` tags // Redcarpet Markdown renderer wraps text in `<p>` tags
// we need to strip them because they break layout of commit lists in system notes: // we need to strip them because they break layout of commit lists in system notes:
// https://gitlab.com/gitlab-org/gitlab-foss/uploads/b07a10670919254f0220d3ff5c1aa110/jqzI.png // https://gitlab.com/gitlab-org/gitlab-foss/uploads/b07a10670919254f0220d3ff5c1aa110/jqzI.png
it('removes wrapping paragraph from note HTML', () => { it('removes wrapping paragraph from note HTML', () => {
expect(vm.$el.querySelector('.system-note-message').innerHTML).toContain('<span>closed</span>'); expect(vm.find('.system-note-message').html()).toContain('<span>closed</span>');
}); });
it('should initMRPopovers onMount', () => { it('should initMRPopovers onMount', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment