debian-mirror-gitlab/spec/javascripts/boards/mock_data.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-09-30 21:07:59 +05:30
import boardsStore from '~/boards/stores/boards_store';
2020-01-01 13:55:28 +05:30
import { listObj } from '../../frontend/boards/mock_data';
2018-12-13 13:39:08 +05:30
2020-01-01 13:55:28 +05:30
export * from '../../frontend/boards/mock_data';
2016-09-13 17:45:13 +05:30
2018-03-17 18:26:18 +05:30
export const BoardsMockData = {
2018-05-09 12:01:36 +05:30
GET: {
2018-11-20 20:47:30 +05:30
'/test/-/boards/1/lists/300/issues?id=300&page=1': {
2018-05-09 12:01:36 +05:30
issues: [
{
title: 'Testing',
id: 1,
iid: 1,
confidential: false,
labels: [],
assignees: [],
},
],
},
2019-09-04 21:01:54 +05:30
'/test/issue-boards/-/milestones.json': [
2019-02-15 15:39:39 +05:30
{
id: 1,
title: 'test',
},
],
2018-05-09 12:01:36 +05:30
},
POST: {
'/test/-/boards/1/lists': listObj,
2016-09-13 17:45:13 +05:30
},
2018-05-09 12:01:36 +05:30
PUT: {
2019-09-04 21:01:54 +05:30
'/test/issue-boards/-/board/1/lists{/id}': {},
2016-09-13 17:45:13 +05:30
},
2018-05-09 12:01:36 +05:30
DELETE: {
2019-09-04 21:01:54 +05:30
'/test/issue-boards/-/board/1/lists{/id}': {},
2016-09-13 17:45:13 +05:30
},
};
2018-05-09 12:01:36 +05:30
export const boardsMockInterceptor = config => {
2018-03-17 18:26:18 +05:30
const body = BoardsMockData[config.method.toUpperCase()][config.url];
return [200, body];
2017-08-17 22:00:37 +05:30
};
2020-01-01 13:55:28 +05:30
export const setMockEndpoints = (opts = {}) => {
2019-09-04 21:01:54 +05:30
const boardsEndpoint = opts.boardsEndpoint || '/test/issue-boards/-/boards.json';
2018-03-17 18:26:18 +05:30
const listsEndpoint = opts.listsEndpoint || '/test/-/boards/1/lists';
const bulkUpdatePath = opts.bulkUpdatePath || '';
const boardId = opts.boardId || '1';
2019-09-30 21:07:59 +05:30
boardsStore.setEndpoints({
2018-03-17 18:26:18 +05:30
boardsEndpoint,
listsEndpoint,
bulkUpdatePath,
boardId,
});
2019-02-15 15:39:39 +05:30
};