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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-05-27 22:25:52 +05:30
import { GlSprintf, GlLink } from '@gitlab/ui';
2020-03-13 15:44:24 +05:30
import { shallowMount } from '@vue/test-utils';
2020-01-01 13:55:28 +05:30
import NoteEditedText from '~/notes/components/note_edited_text.vue';
const propsData = {
actionText: 'Edited',
className: 'foo-bar',
editedAt: '2017-08-04T09:52:31.062Z',
2023-05-27 22:25:52 +05:30
editedBy: null,
2020-01-01 13:55:28 +05:30
};
describe('NoteEditedText', () => {
let wrapper;
2018-03-17 18:26:18 +05:30
2023-05-27 22:25:52 +05:30
const createWrapper = (props = {}) => {
2020-01-01 13:55:28 +05:30
wrapper = shallowMount(NoteEditedText, {
2023-05-27 22:25:52 +05:30
propsData: {
...propsData,
...props,
},
stubs: {
GlSprintf,
},
2020-01-01 13:55:28 +05:30
});
2023-05-27 22:25:52 +05:30
};
2018-03-17 18:26:18 +05:30
2023-05-27 22:25:52 +05:30
const findUserElement = () => wrapper.findComponent(GlLink);
2018-03-17 18:26:18 +05:30
2023-05-27 22:25:52 +05:30
describe('default', () => {
beforeEach(() => {
createWrapper();
});
2018-03-17 18:26:18 +05:30
2023-05-27 22:25:52 +05:30
it('should render block with provided className', () => {
expect(wrapper.classes()).toContain(propsData.className);
});
it('should render provided actionText', () => {
expect(wrapper.text().trim()).toContain(propsData.actionText);
});
it('should not render user information', () => {
expect(findUserElement().exists()).toBe(false);
});
2018-03-17 18:26:18 +05:30
});
2023-05-27 22:25:52 +05:30
describe('edited note', () => {
const editedBy = {
avatar_url: 'path',
id: 1,
name: 'Root',
path: '/root',
state: 'active',
username: 'root',
};
beforeEach(() => {
createWrapper({ editedBy });
});
it('should render user information', () => {
const authorLink = findUserElement();
2018-03-17 18:26:18 +05:30
2023-05-27 22:25:52 +05:30
expect(authorLink.attributes('href')).toEqual(editedBy.path);
expect(authorLink.text().trim()).toEqual(editedBy.name);
});
2018-03-17 18:26:18 +05:30
});
});