debian-mirror-gitlab/spec/frontend/ide/components/repo_tabs_spec.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-11-24 15:15:51 +05:30
import Vuex from 'vuex';
import { mount, createLocalVue } from '@vue/test-utils';
import { createStore } from '~/ide/stores';
import RepoTabs from '~/ide/components/repo_tabs.vue';
2018-05-09 12:01:36 +05:30
import { file } from '../helpers';
2020-11-24 15:15:51 +05:30
const localVue = createLocalVue();
localVue.use(Vuex);
2018-05-09 12:01:36 +05:30
describe('RepoTabs', () => {
2020-11-24 15:15:51 +05:30
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,
localVue,
});
});
2018-05-09 12:01:36 +05:30
afterEach(() => {
2020-11-24 15:15:51 +05:30
wrapper.destroy();
2018-05-09 12:01:36 +05:30
});
it('renders a list of tabs', done => {
2020-11-24 15:15:51 +05:30
store.state.openFiles[0].active = true;
2018-05-09 12:01:36 +05:30
2020-11-24 15:15:51 +05:30
wrapper.vm.$nextTick(() => {
const tabs = [...wrapper.vm.$el.querySelectorAll('.multi-file-tab')];
2018-05-09 12:01:36 +05:30
expect(tabs.length).toEqual(2);
2018-10-15 14:42:47 +05:30
expect(tabs[0].parentNode.classList.contains('active')).toEqual(true);
expect(tabs[1].parentNode.classList.contains('active')).toEqual(false);
2018-05-09 12:01:36 +05:30
done();
});
});
});