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

activity_bar_spec.js « components « ide « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 762f3c5dad10f06782edd8b6121f02e46302bf53 (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
64
65
66
67
68
69
70
71
72
import Vue from 'vue';
import { createStore } from '~/ide/stores';
import { leftSidebarViews } from '~/ide/constants';
import ActivityBar from '~/ide/components/activity_bar.vue';
import { createComponentWithStore } from '../../helpers/vue_mount_component_helper';

describe('IDE activity bar', () => {
  const Component = Vue.extend(ActivityBar);
  let vm;
  let store;

  beforeEach(() => {
    store = createStore();

    Vue.set(store.state.projects, 'abcproject', {
      web_url: 'testing',
    });
    Vue.set(store.state, 'currentProjectId', 'abcproject');

    vm = createComponentWithStore(Component, store);
  });

  afterEach(() => {
    vm.$destroy();
  });

  describe('updateActivityBarView', () => {
    beforeEach(() => {
      jest.spyOn(vm, 'updateActivityBarView').mockImplementation(() => {});

      vm.$mount();
    });

    it('calls updateActivityBarView with edit value on click', () => {
      vm.$el.querySelector('.js-ide-edit-mode').click();

      expect(vm.updateActivityBarView).toHaveBeenCalledWith(leftSidebarViews.edit.name);
    });

    it('calls updateActivityBarView with commit value on click', () => {
      vm.$el.querySelector('.js-ide-commit-mode').click();

      expect(vm.updateActivityBarView).toHaveBeenCalledWith(leftSidebarViews.commit.name);
    });

    it('calls updateActivityBarView with review value on click', () => {
      vm.$el.querySelector('.js-ide-review-mode').click();

      expect(vm.updateActivityBarView).toHaveBeenCalledWith(leftSidebarViews.review.name);
    });
  });

  describe('active item', () => {
    beforeEach(() => {
      vm.$mount();
    });

    it('sets edit item active', () => {
      expect(vm.$el.querySelector('.js-ide-edit-mode').classList).toContain('active');
    });

    it('sets commit item active', done => {
      vm.$store.state.currentActivityView = leftSidebarViews.commit.name;

      vm.$nextTick(() => {
        expect(vm.$el.querySelector('.js-ide-commit-mode').classList).toContain('active');

        done();
      });
    });
  });
});