2018-03-20 14:12:48 +00:00
|
|
|
import Vue from 'vue';
|
2018-03-20 14:16:38 +00:00
|
|
|
import repoTabs from '~/ide/components/repo_tabs.vue';
|
2018-03-20 14:12:48 +00:00
|
|
|
import createComponent from '../../helpers/vue_mount_component_helper';
|
|
|
|
import { file } from '../helpers';
|
|
|
|
|
|
|
|
describe('RepoTabs', () => {
|
|
|
|
const openedFiles = [file('open1'), file('open2')];
|
|
|
|
const RepoTabs = Vue.extend(repoTabs);
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders a list of tabs', done => {
|
|
|
|
vm = createComponent(RepoTabs, {
|
|
|
|
files: openedFiles,
|
|
|
|
viewer: 'editor',
|
|
|
|
hasChanges: false,
|
2018-03-23 15:59:09 +00:00
|
|
|
activeFile: file('activeFile'),
|
2018-03-25 20:13:55 +00:00
|
|
|
hasMergeRequest: false,
|
2018-03-20 14:12:48 +00:00
|
|
|
});
|
|
|
|
openedFiles[0].active = true;
|
|
|
|
|
|
|
|
vm.$nextTick(() => {
|
|
|
|
const tabs = [...vm.$el.querySelectorAll('.multi-file-tab')];
|
|
|
|
|
|
|
|
expect(tabs.length).toEqual(2);
|
2018-04-20 13:35:46 +00:00
|
|
|
expect(tabs[0].parentNode.classList.contains('active')).toEqual(true);
|
|
|
|
expect(tabs[1].parentNode.classList.contains('active')).toEqual(false);
|
2018-03-20 14:12:48 +00:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|