debian-mirror-gitlab/spec/frontend/notes/components/note_edited_text_spec.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-01-01 13:55:28 +05:30
import { shallowMount, createLocalVue } from '@vue/test-utils';
import NoteEditedText from '~/notes/components/note_edited_text.vue';
const localVue = createLocalVue();
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;
2018-03-17 18:26:18 +05:30
beforeEach(() => {
2020-01-01 13:55:28 +05:30
wrapper = shallowMount(NoteEditedText, {
localVue,
propsData,
sync: false,
attachToDocument: true,
});
2018-03-17 18:26:18 +05:30
});
afterEach(() => {
2020-01-01 13:55:28 +05:30
wrapper.destroy();
2018-03-17 18:26:18 +05:30
});
it('should render block with provided className', () => {
2020-01-01 13:55:28 +05:30
expect(wrapper.classes()).toContain(propsData.className);
2018-03-17 18:26:18 +05:30
});
it('should render provided actionText', () => {
2020-01-01 13:55:28 +05:30
expect(wrapper.text().trim()).toContain(propsData.actionText);
2018-03-17 18:26:18 +05:30
});
it('should render provided user information', () => {
2020-01-01 13:55:28 +05:30
const authorLink = wrapper.find('.js-user-link');
2018-03-17 18:26:18 +05:30
2020-01-01 13:55:28 +05:30
expect(authorLink.attributes('href')).toEqual(propsData.editedBy.path);
expect(authorLink.text().trim()).toEqual(propsData.editedBy.name);
2018-03-17 18:26:18 +05:30
});
});