summaryrefslogtreecommitdiff
path: root/spec/frontend/contributors/store/mutations_spec.js
blob: e9e756d4a65f06e4014c192a43148f4a0e247602 (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
import state from '~/contributors/stores/state';
import mutations from '~/contributors/stores/mutations';
import * as types from '~/contributors/stores/mutation_types';

describe('Contributors mutations', () => {
  let stateCopy;

  beforeEach(() => {
    stateCopy = state();
  });

  describe('SET_LOADING_STATE', () => {
    it('should set loading flag', () => {
      const loading = true;
      mutations[types.SET_LOADING_STATE](stateCopy, loading);

      expect(stateCopy.loading).toEqual(loading);
    });
  });

  describe('SET_CHART_DATA', () => {
    const chartData = { '2017-11': 0, '2017-12': 2 };

    it('should set chart data', () => {
      mutations[types.SET_CHART_DATA](stateCopy, chartData);

      expect(stateCopy.chartData).toEqual(chartData);
    });
  });

  describe('SET_ACTIVE_BRANCH', () => {
    it('should set search query', () => {
      const branch = 'feature-branch';

      mutations[types.SET_ACTIVE_BRANCH](stateCopy, branch);

      expect(stateCopy.branch).toEqual(branch);
    });
  });
});