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',
|
|
|
|
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, {
|
|
|
|
propsData,
|
|
|
|
});
|
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
|
|
|
});
|
|
|
|
});
|