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

103 lines
2.5 KiB
JavaScript
Raw Normal View History

2018-11-08 19:23:39 +05:30
import Vue from 'vue';
2020-03-09 13:42:32 +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-09 13:42:32 +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-03-09 13:42:32 +05:30
const localVue = createLocalVue();
localVue.use(Vuex);
2018-11-08 19:23:39 +05:30
2020-03-09 13:42:32 +05:30
describe('ide/components/panes/right.vue', () => {
let wrapper;
let store;
2018-11-08 19:23:39 +05:30
2020-03-09 13:42:32 +05:30
const createComponent = props => {
wrapper = shallowMount(RightPane, {
localVue,
store,
propsData: {
...props,
},
});
};
2018-11-08 19:23:39 +05:30
2020-03-09 13:42:32 +05:30
beforeEach(() => {
store = createStore();
2018-11-08 19:23:39 +05:30
});
afterEach(() => {
2020-03-09 13:42:32 +05:30
wrapper.destroy();
wrapper = null;
2018-11-08 19:23:39 +05:30
});
2020-03-09 13:42:32 +05:30
it('allows tabs to be added via extensionTabs prop', () => {
createComponent({
extensionTabs: [
{
show: true,
title: 'FakeTab',
2018-11-08 19:23:39 +05:30
},
2020-03-09 13:42:32 +05:30
],
2018-11-08 19:23:39 +05:30
});
2020-03-09 13:42:32 +05:30
expect(wrapper.find(CollapsibleSidebar).props('extensionTabs')).toEqual(
expect.arrayContaining([
expect.objectContaining({
show: true,
title: 'FakeTab',
}),
]),
);
});
2018-11-08 19:23:39 +05:30
2020-03-09 13:42:32 +05:30
describe('pipelines tab', () => {
it('is always shown', () => {
createComponent();
2018-11-08 19:23:39 +05:30
2020-03-09 13:42:32 +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-09 13:42:32 +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-09 13:42:32 +05:30
store.state.clientsidePreviewEnabled = true;
2018-11-18 11:00:15 +05:30
2020-03-09 13:42:32 +05:30
createComponent();
2018-11-18 11:00:15 +05:30
2020-03-09 13:42:32 +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
});
});
2018-11-08 19:23:39 +05:30
});