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

73 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
/* global BoardService */
2017-08-17 22:00:37 +05:30
/* eslint-disable comma-dangle, no-unused-vars, quote-props */
2018-03-17 18:26:18 +05:30
import _ from 'underscore';
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
export const listObj = {
id: 300,
2016-09-13 17:45:13 +05:30
position: 0,
title: 'Test',
list_type: 'label',
label: {
2018-03-17 18:26:18 +05:30
id: 5000,
2016-09-13 17:45:13 +05:30
title: 'Testing',
color: 'red',
description: 'testing;'
}
};
2018-03-17 18:26:18 +05:30
export const listObjDuplicate = {
2017-08-17 22:00:37 +05:30
id: listObj.id,
2016-09-13 17:45:13 +05:30
position: 1,
title: 'Test',
list_type: 'label',
label: {
2017-08-17 22:00:37 +05:30
id: listObj.label.id,
2016-09-13 17:45:13 +05:30
title: 'Testing',
color: 'red',
description: 'testing;'
}
};
2018-03-17 18:26:18 +05:30
export const BoardsMockData = {
2016-09-13 17:45:13 +05:30
'GET': {
2018-03-17 18:26:18 +05:30
'/test/-/boards/1/lists/300/issues?id=300&page=1&=': {
2016-09-29 09:46:39 +05:30
issues: [{
title: 'Testing',
2018-03-17 18:26:18 +05:30
id: 1,
2016-09-29 09:46:39 +05:30
iid: 1,
confidential: false,
2017-08-17 22:00:37 +05:30
labels: [],
assignees: [],
2016-09-29 09:46:39 +05:30
}],
}
2016-09-13 17:45:13 +05:30
},
'POST': {
2018-03-17 18:26:18 +05:30
'/test/-/boards/1/lists': listObj
2016-09-13 17:45:13 +05:30
},
'PUT': {
2016-11-03 12:29:30 +05:30
'/test/issue-boards/board/1/lists{/id}': {}
2016-09-13 17:45:13 +05:30
},
'DELETE': {
2016-11-03 12:29:30 +05:30
'/test/issue-boards/board/1/lists{/id}': {}
2016-09-13 17:45:13 +05:30
}
};
2018-03-17 18:26:18 +05:30
export const boardsMockInterceptor = (config) => {
const body = BoardsMockData[config.method.toUpperCase()][config.url];
return [200, body];
2017-08-17 22:00:37 +05:30
};
2018-03-17 18:26:18 +05:30
export const mockBoardService = (opts = {}) => {
const boardsEndpoint = opts.boardsEndpoint || '/test/issue-boards/boards.json';
const listsEndpoint = opts.listsEndpoint || '/test/-/boards/1/lists';
const bulkUpdatePath = opts.bulkUpdatePath || '';
const boardId = opts.boardId || '1';
return new BoardService({
boardsEndpoint,
listsEndpoint,
bulkUpdatePath,
boardId,
});
};