2020-01-08 10:08:01 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2019-11-21 04:06:16 -05:00
|
|
|
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
|
|
|
|
2017-08-09 09:30:23 -04:00
|
|
|
beforeEach(() => {
|
2019-11-21 04:06:16 -05:00
|
|
|
wrapper = shallowMount(NoteEditedText, {
|
|
|
|
propsData,
|
|
|
|
});
|
2017-08-09 09:30:23 -04:00
|
|
|
});
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-09 09:30:23 -04:00
|
|
|
afterEach(() => {
|
2019-11-21 04:06:16 -05:00
|
|
|
wrapper.destroy();
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
|
2017-08-09 09:30:23 -04:00
|
|
|
it('should render block with provided className', () => {
|
2019-11-21 04:06:16 -05:00
|
|
|
expect(wrapper.classes()).toContain(propsData.className);
|
2017-08-09 09:30:23 -04:00
|
|
|
});
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2017-08-09 09:30:23 -04:00
|
|
|
it('should render provided actionText', () => {
|
2019-11-21 04:06:16 -05:00
|
|
|
expect(wrapper.text().trim()).toContain(propsData.actionText);
|
2017-08-04 11:51:35 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render provided user information', () => {
|
2019-11-21 04:06:16 -05:00
|
|
|
const authorLink = wrapper.find('.js-user-link');
|
2017-08-04 11:51:35 -04:00
|
|
|
|
2019-11-21 04:06:16 -05: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
|
|
|
});
|
2017-08-09 09:30:23 -04:00
|
|
|
});
|