108 lines
2.7 KiB
JavaScript
108 lines
2.7 KiB
JavaScript
import { GlAlert } from '@gitlab/ui';
|
|
import { shallowMount } from '@vue/test-utils';
|
|
import Vue from 'vue';
|
|
import Draggable from 'vuedraggable';
|
|
import Vuex from 'vuex';
|
|
import EpicsSwimlanes from 'ee_component/boards/components/epics_swimlanes.vue';
|
|
import getters from 'ee_else_ce/boards/stores/getters';
|
|
import BoardColumn from '~/boards/components/board_column.vue';
|
|
import BoardContent from '~/boards/components/board_content.vue';
|
|
import BoardContentSidebar from '~/boards/components/board_content_sidebar.vue';
|
|
import { mockLists } from '../mock_data';
|
|
|
|
Vue.use(Vuex);
|
|
|
|
const actions = {
|
|
moveList: jest.fn(),
|
|
};
|
|
|
|
describe('BoardContent', () => {
|
|
let wrapper;
|
|
window.gon = {};
|
|
|
|
const defaultState = {
|
|
isShowingEpicsSwimlanes: false,
|
|
boardLists: mockLists,
|
|
error: undefined,
|
|
issuableType: 'issue',
|
|
};
|
|
|
|
const createStore = (state = defaultState) => {
|
|
return new Vuex.Store({
|
|
actions,
|
|
getters,
|
|
state,
|
|
});
|
|
};
|
|
|
|
const createComponent = ({ state, props = {}, canAdminList = true } = {}) => {
|
|
const store = createStore({
|
|
...defaultState,
|
|
...state,
|
|
});
|
|
wrapper = shallowMount(BoardContent, {
|
|
propsData: {
|
|
lists: mockLists,
|
|
disabled: false,
|
|
...props,
|
|
},
|
|
provide: {
|
|
canAdminList,
|
|
},
|
|
store,
|
|
});
|
|
};
|
|
|
|
afterEach(() => {
|
|
wrapper.destroy();
|
|
});
|
|
|
|
describe('default', () => {
|
|
beforeEach(() => {
|
|
createComponent();
|
|
});
|
|
|
|
it('renders a BoardColumn component per list', () => {
|
|
expect(wrapper.findAllComponents(BoardColumn)).toHaveLength(mockLists.length);
|
|
});
|
|
|
|
it('renders BoardContentSidebar', () => {
|
|
expect(wrapper.find(BoardContentSidebar).exists()).toBe(true);
|
|
});
|
|
|
|
it('does not display EpicsSwimlanes component', () => {
|
|
expect(wrapper.find(EpicsSwimlanes).exists()).toBe(false);
|
|
expect(wrapper.find(GlAlert).exists()).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('when issuableType is not issue', () => {
|
|
beforeEach(() => {
|
|
createComponent({ state: { issuableType: 'foo' } });
|
|
});
|
|
|
|
it('does not render BoardContentSidebar', () => {
|
|
expect(wrapper.find(BoardContentSidebar).exists()).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('can admin list', () => {
|
|
beforeEach(() => {
|
|
createComponent({ canAdminList: true });
|
|
});
|
|
|
|
it('renders draggable component', () => {
|
|
expect(wrapper.find(Draggable).exists()).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('can not admin list', () => {
|
|
beforeEach(() => {
|
|
createComponent({ canAdminList: false });
|
|
});
|
|
|
|
it('does not render draggable component', () => {
|
|
expect(wrapper.find(Draggable).exists()).toBe(false);
|
|
});
|
|
});
|
|
});
|