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

46 lines
1.1 KiB
JavaScript
Raw Normal View History

import { shallowMount } from '@vue/test-utils';
import NoteEditedText from '~/notes/components/note_edited_text.vue';
const propsData = {
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;
2017-08-04 11:51:35 -04:00
beforeEach(() => {
wrapper = shallowMount(NoteEditedText, {
propsData,
});
});
2017-08-04 11:51:35 -04:00
afterEach(() => {
wrapper.destroy();
2017-08-04 11:51:35 -04:00
});
it('should render block with provided className', () => {
expect(wrapper.classes()).toContain(propsData.className);
});
2017-08-04 11:51:35 -04:00
it('should render provided actionText', () => {
expect(wrapper.text().trim()).toContain(propsData.actionText);
2017-08-04 11:51:35 -04:00
});
it('should render provided user information', () => {
const authorLink = wrapper.find('.js-user-link');
2017-08-04 11:51:35 -04:00
expect(authorLink.attributes('href')).toEqual(propsData.editedBy.path);
expect(authorLink.text().trim()).toEqual(propsData.editedBy.name);
2017-08-04 11:51:35 -04:00
});
});