diff options
Diffstat (limited to 'spec/frontend/boards/mock_data.js')
-rw-r--r-- | spec/frontend/boards/mock_data.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/frontend/boards/mock_data.js b/spec/frontend/boards/mock_data.js index 05f73e0d8dc..fa4154676a2 100644 --- a/spec/frontend/boards/mock_data.js +++ b/spec/frontend/boards/mock_data.js @@ -1,3 +1,5 @@ +import boardsStore from '~/boards/stores/boards_store'; + export const boardObj = { id: 1, name: 'test', @@ -89,3 +91,54 @@ export const mockMilestone = { start_date: '2018-01-01', due_date: '2019-12-31', }; + +export const BoardsMockData = { + GET: { + '/test/-/boards/1/lists/300/issues?id=300&page=1': { + issues: [ + { + title: 'Testing', + id: 1, + iid: 1, + confidential: false, + labels: [], + assignees: [], + }, + ], + }, + '/test/issue-boards/-/milestones.json': [ + { + id: 1, + title: 'test', + }, + ], + }, + POST: { + '/test/-/boards/1/lists': listObj, + }, + PUT: { + '/test/issue-boards/-/board/1/lists{/id}': {}, + }, + DELETE: { + '/test/issue-boards/-/board/1/lists{/id}': {}, + }, +}; + +export const boardsMockInterceptor = config => { + const body = BoardsMockData[config.method.toUpperCase()][config.url]; + return [200, body]; +}; + +export const setMockEndpoints = (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'; + + boardsStore.setEndpoints({ + boardsEndpoint, + listsEndpoint, + bulkUpdatePath, + boardId, + }); +}; |