debian-mirror-gitlab/spec/frontend/ide/components/panes/right_spec.js

120 lines
3 KiB
JavaScript
Raw Normal View History

2018-11-08 19:23:39 +05:30
import Vue from 'vue';
2020-03-13 15:44:24 +05:30
import Vuex from 'vuex';
import { createLocalVue, shallowMount } from '@vue/test-utils';
2018-11-08 19:23:39 +05:30
import { createStore } from '~/ide/stores';
import RightPane from '~/ide/components/panes/right.vue';
2020-03-13 15:44:24 +05:30
import CollapsibleSidebar from '~/ide/components/panes/collapsible_sidebar.vue';
2018-11-08 19:23:39 +05:30
import { rightSidebarViews } from '~/ide/constants';
2020-06-23 00:09:42 +05:30
import extendStore from '~/ide/stores/extend';
2018-11-08 19:23:39 +05:30
2020-03-13 15:44:24 +05:30
const localVue = createLocalVue();
localVue.use(Vuex);
2018-11-08 19:23:39 +05:30
2020-03-13 15:44:24 +05:30
describe('ide/components/panes/right.vue', () => {
let wrapper;
let store;
2018-11-08 19:23:39 +05:30
2020-03-13 15:44:24 +05:30
const createComponent = props => {
2020-06-23 00:09:42 +05:30
extendStore(store, document.createElement('div'));
2020-03-13 15:44:24 +05:30
wrapper = shallowMount(RightPane, {
localVue,
store,
propsData: {
...props,
},
});
};
2018-11-08 19:23:39 +05:30
2020-03-13 15:44:24 +05:30
beforeEach(() => {
store = createStore();
2018-11-08 19:23:39 +05:30
});
afterEach(() => {
2020-03-13 15:44:24 +05:30
wrapper.destroy();
wrapper = null;
2018-11-08 19:23:39 +05:30
});
2020-03-13 15:44:24 +05:30
describe('pipelines tab', () => {
it('is always shown', () => {
createComponent();
2018-11-08 19:23:39 +05:30
2020-03-13 15:44:24 +05:30
expect(wrapper.find(CollapsibleSidebar).props('extensionTabs')).toEqual(
expect.arrayContaining([
expect.objectContaining({
show: true,
title: 'Pipelines',
views: expect.arrayContaining([
expect.objectContaining({
name: rightSidebarViews.pipelines.name,
}),
expect.objectContaining({
name: rightSidebarViews.jobsDetail.name,
}),
]),
}),
]),
);
2018-11-08 19:23:39 +05:30
});
});
2018-11-18 11:00:15 +05:30
2020-03-13 15:44:24 +05:30
describe('clientside live preview tab', () => {
it('is shown if there is a packageJson and clientsidePreviewEnabled', () => {
Vue.set(store.state.entries, 'package.json', {
2020-01-01 13:55:28 +05:30
name: 'package.json',
});
2020-03-13 15:44:24 +05:30
store.state.clientsidePreviewEnabled = true;
2018-11-18 11:00:15 +05:30
2020-03-13 15:44:24 +05:30
createComponent();
2018-11-18 11:00:15 +05:30
2020-03-13 15:44:24 +05:30
expect(wrapper.find(CollapsibleSidebar).props('extensionTabs')).toEqual(
expect.arrayContaining([
expect.objectContaining({
show: true,
title: 'Live preview',
views: expect.arrayContaining([
expect.objectContaining({
name: rightSidebarViews.clientSidePreview.name,
}),
]),
}),
]),
);
2018-11-18 11:00:15 +05:30
});
});
2020-06-23 00:09:42 +05:30
describe('terminal tab', () => {
beforeEach(() => {
createComponent();
});
it('adds terminal tab', () => {
store.state.terminal.isVisible = true;
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(CollapsibleSidebar).props('extensionTabs')).toEqual(
expect.arrayContaining([
expect.objectContaining({
show: true,
title: 'Terminal',
}),
]),
);
});
});
it('hides terminal tab when not visible', () => {
store.state.terminal.isVisible = false;
expect(wrapper.find(CollapsibleSidebar).props('extensionTabs')).toEqual(
expect.arrayContaining([
expect.objectContaining({
show: false,
title: 'Terminal',
}),
]),
);
});
});
2018-11-08 19:23:39 +05:30
});