summaryrefslogtreecommitdiff
path: root/spec/frontend/cycle_analytics/total_time_component_spec.js
blob: e831bc311edd36ad08161dde5270604dd16f83aa (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
import { shallowMount } from '@vue/test-utils';
import TotalTime from '~/cycle_analytics/components/total_time_component.vue';

describe('Total time component', () => {
  let wrapper;

  const createComponent = (propsData) => {
    wrapper = shallowMount(TotalTime, {
      propsData,
    });
  };

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

  describe('With data', () => {
    it('should render information for days and hours', () => {
      createComponent({
        time: {
          days: 3,
          hours: 4,
        },
      });

      expect(wrapper.text()).toMatchInterpolatedText('3 days 4 hrs');
    });

    it('should render information for hours and minutes', () => {
      createComponent({
        time: {
          hours: 4,
          mins: 35,
        },
      });

      expect(wrapper.text()).toMatchInterpolatedText('4 hrs 35 mins');
    });

    it('should render information for seconds', () => {
      createComponent({
        time: {
          seconds: 45,
        },
      });

      expect(wrapper.text()).toMatchInterpolatedText('45 s');
    });
  });

  describe('Without data', () => {
    it('should render no information', () => {
      createComponent();

      expect(wrapper.text()).toBe('--');
    });
  });
});