Welcome to mirror list, hosted at ThFree Co, Russian Federation.

time_ago_tooltip_spec.js « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 49591c3ce1ca2c36e8378e3243d6edaabbd1fbea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { shallowMount } from '@vue/test-utils';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { formatDate, getTimeago } from '~/lib/utils/datetime_utility';

describe('Time ago with tooltip component', () => {
  let vm;

  const buildVm = (propsData = {}) => {
    vm = shallowMount(TimeAgoTooltip, {
      attachToDocument: true,
      sync: false,
      propsData,
    });
  };
  const timestamp = '2017-05-08T14:57:39.781Z';

  afterEach(() => {
    vm.destroy();
  });

  it('should render timeago with a bootstrap tooltip', () => {
    buildVm({
      time: timestamp,
    });
    const timeago = getTimeago();

    expect(vm.attributes('title')).toEqual(formatDate(timestamp));
    expect(vm.text()).toEqual(timeago.format(timestamp));
  });

  it('should render provided html class', () => {
    buildVm({
      time: timestamp,
      cssClass: 'foo',
    });

    expect(vm.classes()).toContain('foo');
  });
});