Welcome to mirror list, hosted at ThFree Co, Russian Federation.

getters_spec.js « pane « modules « stores « ide « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a321571f05826c2cdb1ba2cb206883bd5c74f46c (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
import * as getters from '~/ide/stores/modules/pane/getters';
import state from '~/ide/stores/modules/pane/state';

describe('IDE pane module getters', () => {
  const TEST_VIEW = 'test-view';
  const TEST_KEEP_ALIVE_VIEWS = {
    [TEST_VIEW]: true,
  };

  describe('isAliveView', () => {
    it('returns true if given view is in keepAliveViews', () => {
      const result = getters.isAliveView({ keepAliveViews: TEST_KEEP_ALIVE_VIEWS }, {})(TEST_VIEW);

      expect(result).toBe(true);
    });

    it('returns true if given view is active view and open', () => {
      const result = getters.isAliveView({ ...state(), isOpen: true, currentView: TEST_VIEW })(
        TEST_VIEW,
      );

      expect(result).toBe(true);
    });

    it('returns false if given view is active view and closed', () => {
      const result = getters.isAliveView({ ...state(), currentView: TEST_VIEW })(TEST_VIEW);

      expect(result).toBe(false);
    });

    it('returns false if given view is not activeView', () => {
      const result = getters.isAliveView({
        ...state(),
        isOpen: true,
        currentView: `${TEST_VIEW}_other`,
      })(TEST_VIEW);

      expect(result).toBe(false);
    });
  });
});