gitlab-org--gitlab-foss/spec/javascripts/notes/components/note_edited_text_spec.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

import Vue from 'vue';
2017-12-04 11:19:07 -05:00
import noteEditedText from '~/notes/components/note_edited_text.vue';
2017-12-04 11:19:07 -05:00
describe('note_edited_text', () => {
let vm;
let props;
2017-08-04 11:51:35 -04:00
beforeEach(() => {
2017-12-04 11:19:07 -05:00
const Component = Vue.extend(noteEditedText);
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',
},
};
2017-08-04 11:51:35 -04:00
vm = new Component({
propsData: props,
}).$mount();
});
2017-08-04 11:51:35 -04:00
afterEach(() => {
vm.$destroy();
2017-08-04 11:51:35 -04:00
});
it('should render block with provided className', () => {
expect(vm.$el.className).toEqual(props.className);
});
2017-08-04 11:51:35 -04:00
it('should render provided actionText', () => {
expect(vm.$el.textContent).toContain(props.actionText);
2017-08-04 11:51:35 -04:00
});
it('should render provided user information', () => {
const authorLink = vm.$el.querySelector('.js-vue-author');
2017-08-04 11:51:35 -04:00
expect(authorLink.getAttribute('href')).toEqual(props.editedBy.path);
expect(authorLink.textContent.trim()).toEqual(props.editedBy.name);
2017-08-04 11:51:35 -04:00
});
});