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

repo_tabs_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: 06ad162d398dd1a92ad216b933ae7bd7c805c400 (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
import { mount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import Vuex from 'vuex';
import RepoTabs from '~/ide/components/repo_tabs.vue';
import { createStore } from '~/ide/stores';
import { file } from '../helpers';

Vue.use(Vuex);

describe('RepoTabs', () => {
  let wrapper;
  let store;

  beforeEach(() => {
    store = createStore();
    store.state.openFiles = [file('open1'), file('open2')];

    wrapper = mount(RepoTabs, {
      propsData: {
        files: store.state.openFiles,
        viewer: 'editor',
        activeFile: file('activeFile'),
      },
      store,
    });
  });

  it('renders a list of tabs', async () => {
    store.state.openFiles[0].active = true;

    await nextTick();
    const tabs = [...wrapper.vm.$el.querySelectorAll('.multi-file-tab')];

    expect(tabs.length).toEqual(2);
    expect(tabs[0].parentNode.classList.contains('active')).toEqual(true);
    expect(tabs[1].parentNode.classList.contains('active')).toEqual(false);
  });
});