2021-06-17 11:10:03 -04:00
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
import Vuex from 'vuex';
|
2019-04-19 00:43:51 -04:00
|
|
|
|
2021-06-17 11:10:03 -04:00
|
|
|
import BoardCard from '~/boards/components/board_card.vue';
|
|
|
|
import BoardList from '~/boards/components/board_list.vue';
|
|
|
|
import BoardNewIssue from '~/boards/components/board_new_issue.vue';
|
|
|
|
import defaultState from '~/boards/stores/state';
|
|
|
|
import { mockList, mockIssuesByListId, issues } from './mock_data';
|
2019-04-19 00:43:51 -04:00
|
|
|
|
2019-11-12 10:06:26 -05:00
|
|
|
export default function createComponent({
|
|
|
|
listIssueProps = {},
|
|
|
|
componentProps = {},
|
|
|
|
listProps = {},
|
2021-06-17 11:10:03 -04:00
|
|
|
actions = {},
|
|
|
|
getters = {},
|
|
|
|
provide = {},
|
|
|
|
state = defaultState,
|
|
|
|
stubs = {
|
|
|
|
BoardNewIssue,
|
|
|
|
BoardCard,
|
|
|
|
},
|
|
|
|
} = {}) {
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
2019-04-19 00:43:51 -04:00
|
|
|
|
2021-06-17 11:10:03 -04:00
|
|
|
const store = new Vuex.Store({
|
|
|
|
state: {
|
|
|
|
boardItemsByListId: mockIssuesByListId,
|
|
|
|
boardItems: issues,
|
|
|
|
pageInfoByListId: {
|
|
|
|
'gid://gitlab/List/1': { hasNextPage: true },
|
|
|
|
'gid://gitlab/List/2': {},
|
|
|
|
},
|
|
|
|
listsFlags: {
|
|
|
|
'gid://gitlab/List/1': {},
|
|
|
|
'gid://gitlab/List/2': {},
|
|
|
|
},
|
|
|
|
selectedBoardItems: [],
|
|
|
|
...state,
|
|
|
|
},
|
|
|
|
getters: {
|
|
|
|
isGroupBoard: () => false,
|
|
|
|
isProjectBoard: () => true,
|
|
|
|
isEpicBoard: () => false,
|
|
|
|
...getters,
|
|
|
|
},
|
|
|
|
actions,
|
|
|
|
});
|
2019-04-19 00:43:51 -04:00
|
|
|
|
2021-06-17 11:10:03 -04:00
|
|
|
const list = {
|
|
|
|
...mockList,
|
|
|
|
...listProps,
|
|
|
|
};
|
|
|
|
const issue = {
|
2019-04-19 00:43:51 -04:00
|
|
|
title: 'Testing',
|
|
|
|
id: 1,
|
|
|
|
iid: 1,
|
|
|
|
confidential: false,
|
|
|
|
labels: [],
|
|
|
|
assignees: [],
|
|
|
|
...listIssueProps,
|
2021-06-17 11:10:03 -04:00
|
|
|
};
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(listProps, 'issuesCount')) {
|
|
|
|
list.issuesCount = 1;
|
2019-11-12 10:06:26 -05:00
|
|
|
}
|
2019-04-19 00:43:51 -04:00
|
|
|
|
2021-06-17 11:10:03 -04:00
|
|
|
const component = shallowMount(BoardList, {
|
|
|
|
localVue,
|
2019-10-28 11:05:58 -04:00
|
|
|
store,
|
2019-04-19 00:43:51 -04:00
|
|
|
propsData: {
|
|
|
|
disabled: false,
|
|
|
|
list,
|
2021-06-17 11:10:03 -04:00
|
|
|
boardItems: [issue],
|
|
|
|
canAdminList: true,
|
2019-04-19 00:43:51 -04:00
|
|
|
...componentProps,
|
|
|
|
},
|
2020-09-17 05:09:32 -04:00
|
|
|
provide: {
|
|
|
|
groupId: null,
|
|
|
|
rootPath: '/',
|
2021-06-17 11:10:03 -04:00
|
|
|
weightFeatureAvailable: false,
|
|
|
|
boardWeight: null,
|
|
|
|
canAdminList: true,
|
|
|
|
...provide,
|
2020-09-17 05:09:32 -04:00
|
|
|
},
|
2021-06-17 11:10:03 -04:00
|
|
|
stubs,
|
2019-04-19 00:43:51 -04:00
|
|
|
});
|
|
|
|
|
2021-06-17 11:10:03 -04:00
|
|
|
return component;
|
2019-04-19 00:43:51 -04:00
|
|
|
}
|