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

describe('TotalTimeComponent', () => {
  let wrapper = null;

  const createComponent = (propsData) => {
    return mount(TotalTimeComponent, {
      propsData,
    });
  };

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

  describe('with a valid time object', () => {
    it.each`
      time
      ${{ seconds: 35 }}
      ${{ mins: 47, seconds: 3 }}
      ${{ days: 3, mins: 47, seconds: 3 }}
      ${{ hours: 23, mins: 10 }}
      ${{ hours: 7, mins: 20, seconds: 10 }}
    `('with $time', ({ time }) => {
      wrapper = createComponent({
        time,
      });

      expect(wrapper.html()).toMatchSnapshot();
    });
  });

  describe('with a blank object', () => {
    beforeEach(() => {
      wrapper = createComponent({
        time: {},
      });
    });

    it('should render --', () => {
      expect(wrapper.html()).toMatchSnapshot();
    });
  });
});