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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1 KiB
JavaScript
Raw Normal View History

2022-04-04 11:22:00 +05:30
import { mount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
2021-03-11 19:13:27 +05:30
import Vuex from 'vuex';
2020-11-24 15:15:51 +05:30
import RepoTabs from '~/ide/components/repo_tabs.vue';
2021-03-11 19:13:27 +05:30
import { createStore } from '~/ide/stores';
2018-05-09 12:01:36 +05:30
import { file } from '../helpers';
2022-04-04 11:22:00 +05:30
Vue.use(Vuex);
2020-11-24 15:15:51 +05:30
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,
});
});
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
});
2022-04-04 11:22:00 +05:30
it('renders a list of tabs', async () => {
2020-11-24 15:15:51 +05:30
store.state.openFiles[0].active = true;
2018-05-09 12:01:36 +05:30
2022-04-04 11:22:00 +05:30
await nextTick();
const tabs = [...wrapper.vm.$el.querySelectorAll('.multi-file-tab')];
2018-05-09 12:01:36 +05:30
2022-04-04 11:22:00 +05:30
expect(tabs.length).toEqual(2);
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
});
});