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

65 lines
1.3 KiB
JavaScript
Raw Normal View History

/* eslint-disable comma-dangle, no-unused-vars, quote-props */
2016-08-10 08:54:04 -04:00
const listObj = {
id: _.random(10000),
2016-08-10 08:54:04 -04:00
position: 0,
title: 'Test',
list_type: 'label',
label: {
id: _.random(10000),
2016-08-10 08:54:04 -04:00
title: 'Testing',
color: 'red',
description: 'testing;'
}
};
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;'
}
};
const BoardsMockData = {
'GET': {
2016-10-11 11:07:53 -04:00
'/test/issue-boards/board/1/lists{/id}/issues': {
issues: [{
title: 'Testing',
iid: 1,
confidential: false,
labels: [],
assignees: [],
}],
size: 1
}
2016-08-10 08:54:04 -04:00
},
'POST': {
2016-10-11 11:07:53 -04:00
'/test/issue-boards/board/1/lists{/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
}
};
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
}));
};
window.listObj = listObj;
window.listObjDuplicate = listObjDuplicate;
window.BoardsMockData = BoardsMockData;
window.boardsMockInterceptor = boardsMockInterceptor;