Commit 8fbc6fad authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'vs-migrate-note-edited-text-to-vue-test' into 'master'

Migrate note edited text spec to vue-test-utils

See merge request gitlab-org/gitlab!20493
parents 835798f3 5cea2273
import Vue from 'vue'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import noteEditedText from '~/notes/components/note_edited_text.vue'; import NoteEditedText from '~/notes/components/note_edited_text.vue';
describe('note_edited_text', () => { const localVue = createLocalVue();
let vm; const propsData = {
let props;
beforeEach(() => {
const Component = Vue.extend(noteEditedText);
props = {
actionText: 'Edited', actionText: 'Edited',
className: 'foo-bar', className: 'foo-bar',
editedAt: '2017-08-04T09:52:31.062Z', editedAt: '2017-08-04T09:52:31.062Z',
...@@ -19,29 +14,36 @@ describe('note_edited_text', () => { ...@@ -19,29 +14,36 @@ describe('note_edited_text', () => {
state: 'active', state: 'active',
username: 'root', username: 'root',
}, },
}; };
describe('NoteEditedText', () => {
let wrapper;
vm = new Component({ beforeEach(() => {
propsData: props, wrapper = shallowMount(NoteEditedText, {
}).$mount(); localVue,
propsData,
sync: false,
attachToDocument: true,
});
}); });
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
}); });
it('should render block with provided className', () => { it('should render block with provided className', () => {
expect(vm.$el.className).toEqual(props.className); expect(wrapper.classes()).toContain(propsData.className);
}); });
it('should render provided actionText', () => { it('should render provided actionText', () => {
expect(vm.$el.textContent).toContain(props.actionText); expect(wrapper.text().trim()).toContain(propsData.actionText);
}); });
it('should render provided user information', () => { it('should render provided user information', () => {
const authorLink = vm.$el.querySelector('.js-user-link'); const authorLink = wrapper.find('.js-user-link');
expect(authorLink.getAttribute('href')).toEqual(props.editedBy.path); expect(authorLink.attributes('href')).toEqual(propsData.editedBy.path);
expect(authorLink.textContent.trim()).toEqual(props.editedBy.name); expect(authorLink.text().trim()).toEqual(propsData.editedBy.name);
}); });
}); });
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