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

right_spec.js « panes « components « ide « javascripts « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c75975d2af65353956c1035eef9a3417dab47192 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
import Vue from 'vue';
import '~/behaviors/markdown/render_gfm';
import { createStore } from '~/ide/stores';
import RightPane from '~/ide/components/panes/right.vue';
import { rightSidebarViews } from '~/ide/constants';
import { createComponentWithStore } from '../../../helpers/vue_mount_component_helper';

describe('IDE right pane', () => {
  let Component;
  let vm;

  beforeAll(() => {
    Component = Vue.extend(RightPane);
  });

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

    vm = createComponentWithStore(Component, store).$mount();
  });

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

  describe('active', () => {
    it('renders merge request button as active', done => {
      vm.$store.state.rightPane = rightSidebarViews.mergeRequestInfo;
      vm.$store.state.currentMergeRequestId = '123';
      vm.$store.state.currentProjectId = 'gitlab-ce';
      vm.$store.state.currentMergeRequestId = 1;
      vm.$store.state.projects['gitlab-ce'] = {
        mergeRequests: {
          1: {
            iid: 1,
            title: 'Testing',
            title_html: '<span class="title-html">Testing</span>',
            description: 'Description',
            description_html: '<p class="description-html">Description HTML</p>',
          },
        },
      };

      vm.$nextTick(() => {
        expect(vm.$el.querySelector('.ide-sidebar-link.active')).not.toBe(null);
        expect(
          vm.$el.querySelector('.ide-sidebar-link.active').getAttribute('data-original-title'),
        ).toBe('Merge Request');

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

  describe('click', () => {
    beforeEach(() => {
      spyOn(vm, 'setRightPane');
    });

    it('sets view to merge request', done => {
      vm.$store.state.currentMergeRequestId = '123';

      vm.$nextTick(() => {
        vm.$el.querySelector('.ide-sidebar-link').click();

        expect(vm.setRightPane).toHaveBeenCalledWith(rightSidebarViews.mergeRequestInfo);

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

  describe('live preview', () => {
    it('renders live preview button', done => {
      Vue.set(vm.$store.state.entries, 'package.json', { name: 'package.json' });
      vm.$store.state.clientsidePreviewEnabled = true;

      vm.$nextTick(() => {
        expect(vm.$el.querySelector('button[aria-label="Live preview"]')).not.toBeNull();

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