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

69 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 Vue from 'vue';
import Sortable from 'sortablejs';
2020-01-01 13:55:28 +05:30
import axios from '~/lib/utils/axios_utils';
2019-07-31 22:56:46 +05:30
import BoardList from '~/boards/components/board_list.vue';
import '~/boards/models/issue';
import '~/boards/models/list';
2020-01-01 13:55:28 +05:30
import { listObj, boardsMockInterceptor } from './mock_data';
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';
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 };
}