gitlab-org--gitlab-foss/spec/javascripts/boards/mock_data.js

73 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-09-06 02:49:19 -04:00
/* global BoardService */
/* eslint-disable comma-dangle, no-unused-vars, quote-props */
2017-12-19 05:12:32 -05:00
import _ from 'underscore';
2017-12-15 03:31:14 -05:00
export const listObj = {
id: 300,
2016-08-10 08:54:04 -04:00
position: 0,
title: 'Test',
list_type: 'label',
label: {
2017-12-15 03:31:14 -05:00
id: 5000,
2016-08-10 08:54:04 -04:00
title: 'Testing',
color: 'red',
description: 'testing;'
}
};
2017-12-15 03:31:14 -05:00
export const listObjDuplicate = {
id: listObj.id,
2016-08-10 08:54:04 -04:00
position: 1,
title: 'Test',
list_type: 'label',
label: {
id: listObj.label.id,
2016-08-10 08:54:04 -04:00
title: 'Testing',
color: 'red',
description: 'testing;'
}
};
2017-12-15 03:31:14 -05:00
export const BoardsMockData = {
2016-08-10 08:54:04 -04:00
'GET': {
2017-12-15 03:31:14 -05:00
'/test/-/boards/1/lists/300/issues?id=300&page=1&=': {
issues: [{
title: 'Testing',
2017-09-06 02:49:19 -04:00
id: 1,
iid: 1,
confidential: false,
labels: [],
assignees: [],
}],
}
2016-08-10 08:54:04 -04:00
},
'POST': {
2017-12-15 03:31:14 -05:00
'/test/-/boards/1/lists': 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
}
};
2017-12-15 03:31:14 -05:00
export const boardsMockInterceptor = (config) => {
const body = BoardsMockData[config.method.toUpperCase()][config.url];
return [200, body];
};
2017-12-15 03:31:14 -05:00
export const mockBoardService = (opts = {}) => {
const boardsEndpoint = opts.boardsEndpoint || '/test/issue-boards/boards.json';
const listsEndpoint = opts.listsEndpoint || '/test/-/boards/1/lists';
2017-09-06 02:49:19 -04:00
const bulkUpdatePath = opts.bulkUpdatePath || '';
const boardId = opts.boardId || '1';
return new BoardService({
boardsEndpoint,
listsEndpoint,
bulkUpdatePath,
boardId,
});
};