debian-mirror-gitlab/spec/frontend/boards/board_list_helper.js

67 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-07-31 22:56:46 +05:30
/* global List */
/* global ListIssue */
import MockAdapter from 'axios-mock-adapter';
import Sortable from 'sortablejs';
2021-03-11 19:13:27 +05:30
import Vue from 'vue';
2021-03-08 18:12:59 +05:30
import BoardList from '~/boards/components/board_list_deprecated.vue';
2019-07-31 22:56:46 +05:30
import '~/boards/models/issue';
import '~/boards/models/list';
2019-12-26 22:10:19 +05:30
import store from '~/boards/stores';
2019-07-31 22:56:46 +05:30
import boardsStore from '~/boards/stores/boards_store';
2021-03-11 19:13:27 +05:30
import axios from '~/lib/utils/axios_utils';
import { listObj, boardsMockInterceptor } from './mock_data';
2019-07-31 22:56:46 +05:30
window.Sortable = Sortable;
2019-12-26 22:10:19 +05:30
export default function createComponent({
done,
listIssueProps = {},
componentProps = {},
listProps = {},
}) {
2019-07-31 22:56:46 +05:30
const el = document.createElement('div');
document.body.appendChild(el);
const mock = new MockAdapter(axios);
mock.onAny().reply(boardsMockInterceptor);
boardsStore.create();
const BoardListComp = Vue.extend(BoardList);
2019-12-26 22:10:19 +05:30
const list = new List({ ...listObj, ...listProps });
2019-07-31 22:56:46 +05:30
const issue = new ListIssue({
title: 'Testing',
id: 1,
iid: 1,
confidential: false,
labels: [],
assignees: [],
...listIssueProps,
});
2019-12-26 22:10:19 +05:30
if (!Object.prototype.hasOwnProperty.call(listProps, 'issuesSize')) {
list.issuesSize = 1;
}
2019-07-31 22:56:46 +05:30
list.issues.push(issue);
const component = new BoardListComp({
el,
2019-12-26 22:10:19 +05:30
store,
2019-07-31 22:56:46 +05:30
propsData: {
disabled: false,
list,
issues: list.issues,
loading: false,
...componentProps,
},
2020-11-24 15:15:51 +05:30
provide: {
groupId: null,
rootPath: '/',
},
2019-07-31 22:56:46 +05:30
}).$mount();
Vue.nextTick(() => {
done();
});
return { component, mock };
}