2020-01-09 09:07:51 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2019-11-22 15:06:39 +00:00
|
|
|
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 vm;
|
|
|
|
|
2019-11-22 15:06:39 +00:00
|
|
|
const buildVm = (propsData = {}) => {
|
|
|
|
vm = shallowMount(TimeAgoTooltip, {
|
|
|
|
propsData,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
const timestamp = '2017-05-08T14:57:39.781Z';
|
2017-05-26 17:31:16 +00:00
|
|
|
|
|
|
|
afterEach(() => {
|
2019-11-22 15:06:39 +00:00
|
|
|
vm.destroy();
|
2017-05-26 17:31:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render timeago with a bootstrap tooltip', () => {
|
2019-11-22 15:06:39 +00:00
|
|
|
buildVm({
|
|
|
|
time: timestamp,
|
|
|
|
});
|
2017-12-07 11:09:17 +00:00
|
|
|
const timeago = getTimeago();
|
2017-05-26 17:31:16 +00:00
|
|
|
|
2019-12-20 18:07:53 +00:00
|
|
|
expect(vm.attributes('title')).toEqual(formatDate(timestamp));
|
2019-11-22 15:06:39 +00:00
|
|
|
expect(vm.text()).toEqual(timeago.format(timestamp));
|
2017-05-26 17:31:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render provided html class', () => {
|
2019-11-22 15:06:39 +00:00
|
|
|
buildVm({
|
|
|
|
time: timestamp,
|
|
|
|
cssClass: 'foo',
|
|
|
|
});
|
2017-05-26 17:31:16 +00:00
|
|
|
|
2019-11-22 15:06:39 +00:00
|
|
|
expect(vm.classes()).toContain('foo');
|
2017-05-26 17:31:16 +00:00
|
|
|
});
|
|
|
|
});
|