summaryrefslogtreecommitdiff
path: root/spec/frontend/boards/components/sidebar/board_sidebar_time_tracker_spec.js
blob: 74441e147cf0c33305d818f2bfc0704ce5dbe2c0 (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
/*
    To avoid duplicating tests in time_tracker.spec,
    this spec only contains a simple test to check rendering.

    A detailed feature spec is used to test time tracking feature
    in swimlanes sidebar.
*/

import { shallowMount } from '@vue/test-utils';
import BoardSidebarTimeTracker from '~/boards/components/sidebar/board_sidebar_time_tracker.vue';
import { createStore } from '~/boards/stores';
import IssuableTimeTracker from '~/sidebar/components/time_tracking/time_tracker.vue';

describe('BoardSidebarTimeTracker', () => {
  let wrapper;
  let store;

  const createComponent = (options) => {
    wrapper = shallowMount(BoardSidebarTimeTracker, {
      store,
      ...options,
    });
  };

  beforeEach(() => {
    store = createStore();
    store.state.boardItems = {
      1: {
        iid: 1,
        timeEstimate: 3600,
        totalTimeSpent: 1800,
        humanTimeEstimate: '1h',
        humanTotalTimeSpent: '30min',
      },
    };
    store.state.activeId = '1';
  });

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

  it.each([[true], [false]])(
    'renders IssuableTimeTracker with correct spent and estimated time (timeTrackingLimitToHours=%s)',
    (timeTrackingLimitToHours) => {
      createComponent({ provide: { timeTrackingLimitToHours } });

      expect(wrapper.find(IssuableTimeTracker).props()).toEqual({
        limitToHours: timeTrackingLimitToHours,
        showCollapsed: false,
        issuableIid: '1',
        fullPath: '',
        initialTimeTracking: {
          timeEstimate: 3600,
          totalTimeSpent: 1800,
          humanTimeEstimate: '1h',
          humanTotalTimeSpent: '30min',
        },
      });
    },
  );
});