2017-09-06 02:49:19 -04:00
|
|
|
/* global BoardService */
|
2016-12-13 22:01:05 -05:00
|
|
|
/* eslint-disable comma-dangle, no-unused-vars, quote-props */
|
|
|
|
|
2016-08-10 08:54:04 -04:00
|
|
|
const listObj = {
|
2017-03-24 09:13:44 -04:00
|
|
|
id: _.random(10000),
|
2016-08-10 08:54:04 -04:00
|
|
|
position: 0,
|
|
|
|
title: 'Test',
|
|
|
|
list_type: 'label',
|
|
|
|
label: {
|
2017-03-24 09:13:44 -04:00
|
|
|
id: _.random(10000),
|
2016-08-10 08:54:04 -04:00
|
|
|
title: 'Testing',
|
|
|
|
color: 'red',
|
|
|
|
description: 'testing;'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const listObjDuplicate = {
|
2017-03-24 09:13:44 -04:00
|
|
|
id: listObj.id,
|
2016-08-10 08:54:04 -04:00
|
|
|
position: 1,
|
|
|
|
title: 'Test',
|
|
|
|
list_type: 'label',
|
|
|
|
label: {
|
2017-03-24 09:13:44 -04:00
|
|
|
id: listObj.label.id,
|
2016-08-10 08:54:04 -04:00
|
|
|
title: 'Testing',
|
|
|
|
color: 'red',
|
|
|
|
description: 'testing;'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const BoardsMockData = {
|
|
|
|
'GET': {
|
2017-09-06 02:49:19 -04:00
|
|
|
'/test/boards/1{/id}/issues': {
|
2016-08-19 15:23:56 -04:00
|
|
|
issues: [{
|
|
|
|
title: 'Testing',
|
2017-09-06 02:49:19 -04:00
|
|
|
id: 1,
|
2016-08-19 15:23:56 -04:00
|
|
|
iid: 1,
|
|
|
|
confidential: false,
|
2017-05-04 08:11:15 -04:00
|
|
|
labels: [],
|
|
|
|
assignees: [],
|
2016-08-19 15:23:56 -04:00
|
|
|
}],
|
|
|
|
}
|
2016-08-10 08:54:04 -04:00
|
|
|
},
|
|
|
|
'POST': {
|
2017-09-06 02:49:19 -04:00
|
|
|
'/test/boards/1{/id}': listObj
|
2016-08-10 08:54:04 -04:00
|
|
|
},
|
|
|
|
'PUT': {
|
2016-10-11 11:07:53 -04:00
|
|
|
'/test/issue-boards/board/1/lists{/id}': {}
|
2016-08-10 08:54:04 -04:00
|
|
|
},
|
|
|
|
'DELETE': {
|
2016-10-11 11:07:53 -04:00
|
|
|
'/test/issue-boards/board/1/lists{/id}': {}
|
2016-08-10 08:54:04 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-11-05 06:53:23 -04:00
|
|
|
const boardsMockInterceptor = (request, next) => {
|
2016-08-10 08:54:04 -04:00
|
|
|
const body = BoardsMockData[request.method][request.url];
|
|
|
|
|
|
|
|
next(request.respondWith(JSON.stringify(body), {
|
|
|
|
status: 200
|
|
|
|
}));
|
2016-11-05 06:53:23 -04:00
|
|
|
};
|
2017-02-02 14:17:38 -05:00
|
|
|
|
2017-09-06 02:49:19 -04:00
|
|
|
const mockBoardService = (opts = {}) => {
|
|
|
|
const boardsEndpoint = opts.boardsEndpoint || '/test/issue-boards/board';
|
|
|
|
const listsEndpoint = opts.listsEndpoint || '/test/boards/1';
|
|
|
|
const bulkUpdatePath = opts.bulkUpdatePath || '';
|
|
|
|
const boardId = opts.boardId || '1';
|
|
|
|
|
|
|
|
return new BoardService({
|
|
|
|
boardsEndpoint,
|
|
|
|
listsEndpoint,
|
|
|
|
bulkUpdatePath,
|
|
|
|
boardId,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-02-02 14:17:38 -05:00
|
|
|
window.listObj = listObj;
|
|
|
|
window.listObjDuplicate = listObjDuplicate;
|
|
|
|
window.BoardsMockData = BoardsMockData;
|
|
|
|
window.boardsMockInterceptor = boardsMockInterceptor;
|
2017-09-06 02:49:19 -04:00
|
|
|
window.mockBoardService = mockBoardService;
|