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

describe('IDE pane module mutations', () => {
  const TEST_VIEW = 'test-view';
  let mockedState;

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

  describe('SET_OPEN', () => {
    it('sets isOpen', () => {
      mockedState.isOpen = false;

      mutations[types.SET_OPEN](mockedState, true);

      expect(mockedState.isOpen).toBe(true);
    });
  });

  describe('SET_CURRENT_VIEW', () => {
    it('sets currentView', () => {
      mockedState.currentView = null;

      mutations[types.SET_CURRENT_VIEW](mockedState, TEST_VIEW);

      expect(mockedState.currentView).toEqual(TEST_VIEW);
    });
  });

  describe('KEEP_ALIVE_VIEW', () => {
    it('adds entry to keepAliveViews', () => {
      mutations[types.KEEP_ALIVE_VIEW](mockedState, TEST_VIEW);

      expect(mockedState.keepAliveViews).toEqual({
        [TEST_VIEW]: true,
      });
    });
  });
});