debian-mirror-gitlab/spec/javascripts/repo/components/repo_tabs_spec.js

38 lines
889 B
JavaScript
Raw Normal View History

2017-09-10 17:25:29 +05:30
import Vue from 'vue';
2018-03-17 18:26:18 +05:30
import store from '~/ide/stores';
import repoTabs from '~/ide/components/repo_tabs.vue';
import { file, resetStore } from '../helpers';
2017-09-10 17:25:29 +05:30
describe('RepoTabs', () => {
2018-03-17 18:26:18 +05:30
const openedFiles = [file('open1'), file('open2')];
let vm;
2017-09-10 17:25:29 +05:30
function createComponent() {
const RepoTabs = Vue.extend(repoTabs);
2018-03-17 18:26:18 +05:30
return new RepoTabs({
store,
}).$mount();
2017-09-10 17:25:29 +05:30
}
2018-03-17 18:26:18 +05:30
afterEach(() => {
resetStore(vm.$store);
2017-09-10 17:25:29 +05:30
});
2018-03-17 18:26:18 +05:30
it('renders a list of tabs', (done) => {
vm = createComponent();
openedFiles[0].active = true;
vm.$store.state.openFiles = openedFiles;
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
vm.$nextTick(() => {
const tabs = [...vm.$el.querySelectorAll('.multi-file-tab')];
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
expect(tabs.length).toEqual(2);
expect(tabs[0].classList.contains('active')).toBeTruthy();
expect(tabs[1].classList.contains('active')).toBeFalsy();
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
done();
2017-09-10 17:25:29 +05:30
});
});
});