2017-05-26 17:31:16 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import timeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
|
2017-12-07 11:09:17 +00:00
|
|
|
import { formatDate, getTimeago } from '~/lib/utils/datetime_utility';
|
2017-05-26 17:31:16 +00:00
|
|
|
|
|
|
|
describe('Time ago with tooltip component', () => {
|
|
|
|
let TimeagoTooltip;
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
TimeagoTooltip = Vue.extend(timeagoTooltip);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render timeago with a bootstrap tooltip', () => {
|
|
|
|
vm = new TimeagoTooltip({
|
|
|
|
propsData: {
|
|
|
|
time: '2017-05-08T14:57:39.781Z',
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
expect(vm.$el.tagName).toEqual('TIME');
|
2018-10-17 07:13:26 +00:00
|
|
|
expect(vm.$el.getAttribute('data-original-title')).toEqual(
|
|
|
|
formatDate('2017-05-08T14:57:39.781Z'),
|
|
|
|
);
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2017-12-07 11:09:17 +00:00
|
|
|
const timeago = getTimeago();
|
2017-05-26 17:31:16 +00:00
|
|
|
|
|
|
|
expect(vm.$el.textContent.trim()).toEqual(timeago.format('2017-05-08T14:57:39.781Z'));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render provided html class', () => {
|
|
|
|
vm = new TimeagoTooltip({
|
|
|
|
propsData: {
|
|
|
|
time: '2017-05-08T14:57:39.781Z',
|
|
|
|
cssClass: 'foo',
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
expect(vm.$el.classList.contains('foo')).toEqual(true);
|
|
|
|
});
|
|
|
|
});
|