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; actionText: 'Edited',
className: 'foo-bar',
editedAt: '2017-08-04T09:52:31.062Z',
editedBy: {
avatar_url: 'path',
id: 1,
name: 'Root',
path: '/root',
state: 'active',
username: 'root',
},
};
describe('NoteEditedText', () => {
let wrapper;
beforeEach(() => { beforeEach(() => {
const Component = Vue.extend(noteEditedText); wrapper = shallowMount(NoteEditedText, {
props = { localVue,
actionText: 'Edited', propsData,
className: 'foo-bar', sync: false,
editedAt: '2017-08-04T09:52:31.062Z', attachToDocument: true,
editedBy: { });
avatar_url: 'path',
id: 1,
name: 'Root',
path: '/root',
state: 'active',
username: 'root',
},
};
vm = new Component({
propsData: props,
}).$mount();
}); });
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