gitlab-org--gitlab-foss/spec/javascripts/vue_mr_widget/components/mr_widget_author_time_spec.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-05-09 04:15:34 +00:00
import Vue from 'vue';
import MrWidgetAuthorTime from '~/vue_merge_request_widget/components/mr_widget_author_time.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
2017-05-09 04:15:34 +00:00
describe('MrWidgetAuthorTime', () => {
let vm;
beforeEach(() => {
const Component = Vue.extend(MrWidgetAuthorTime);
vm = mountComponent(Component, {
actionText: 'Merged by',
author: {
name: 'Administrator',
username: 'root',
webUrl: 'http://localhost:3000/root',
2018-10-17 07:13:26 +00:00
avatarUrl:
'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
},
dateTitle: '2017-03-23T23:02:00.807Z',
dateReadable: '12 hours ago',
2017-05-09 04:15:34 +00:00
});
});
afterEach(() => {
vm.$destroy();
});
it('renders provided action text', () => {
expect(vm.$el.textContent).toContain('Merged by');
2017-05-09 04:15:34 +00:00
});
it('renders author', () => {
expect(vm.$el.textContent).toContain('Administrator');
});
2017-05-09 04:15:34 +00:00
it('renders provided time', () => {
2018-10-17 07:13:26 +00:00
expect(vm.$el.querySelector('time').getAttribute('data-original-title')).toEqual(
'2017-03-23T23:02:00.807Z',
);
2018-10-17 07:21:28 +00:00
expect(vm.$el.querySelector('time').textContent.trim()).toEqual('12 hours ago');
2017-05-09 04:15:34 +00:00
});
});