summaryrefslogtreecommitdiff
path: root/spec/javascripts/pipelines/time_ago_spec.js
blob: 24581e8c67201094e8061afb7bbd19fc0a3f7c6f (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import Vue from 'vue';
import timeAgo from '~/pipelines/components/time_ago';

describe('Timeago component', () => {
  let TimeAgo;
  beforeEach(() => {
    TimeAgo = Vue.extend(timeAgo);
  });

  describe('with duration', () => {
    it('should render duration and timer svg', () => {
      const component = new TimeAgo({
        propsData: {
          duration: 10,
          finishedTime: '',
        },
      }).$mount();

      expect(component.$el.querySelector('.duration')).toBeDefined();
      expect(component.$el.querySelector('.duration svg')).toBeDefined();
    });
  });

  describe('without duration', () => {
    it('should not render duration and timer svg', () => {
      const component = new TimeAgo({
        propsData: {
          duration: 0,
          finishedTime: '',
        },
      }).$mount();

      expect(component.$el.querySelector('.duration')).toBe(null);
    });
  });

  describe('with finishedTime', () => {
    it('should render time and calendar icon', () => {
      const component = new TimeAgo({
        propsData: {
          duration: 0,
          finishedTime: '2017-04-26T12:40:23.277Z',
        },
      }).$mount();

      expect(component.$el.querySelector('.finished-at')).toBeDefined();
      expect(component.$el.querySelector('.finished-at i.fa-calendar')).toBeDefined();
      expect(component.$el.querySelector('.finished-at time')).toBeDefined();
    });
  });

  describe('without finishedTime', () => {
    it('should not render time and calendar icon', () => {
      const component = new TimeAgo({
        propsData: {
          duration: 0,
          finishedTime: '',
        },
      }).$mount();

      expect(component.$el.querySelector('.finished-at')).toBe(null);
    });
  });
});