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