Skip to content

Commit 4b49a49

Browse files
committed
add test and refactor
1 parent 90d3888 commit 4b49a49

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

services/contributions.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const getUserContributions = async (username) => {
1212
const { data } = await githubService.fetchPRsByUser(username);
1313
const allUserTasks = await tasks.fetchUserTasks(username);
1414
const noteworthy = [];
15-
const collapsed = [];
1615
const all = [];
1716

1817
if (data.total_count) {
@@ -27,11 +26,9 @@ const getUserContributions = async (username) => {
2726

2827
for (const task of allUserTasks) {
2928
const noteworthyObject = {};
30-
const collapsedTaskObject = {};
3129
const participantsDetails = [];
3230

3331
noteworthyObject.task = extractTaskdetails(task);
34-
collapsedTaskObject.task = extractTaskdetails(task);
3532

3633
if (Array.isArray(task.participants)) {
3734
for (const userId of task.participants) {
@@ -48,7 +45,6 @@ const getUserContributions = async (username) => {
4845
}
4946

5047
noteworthyObject.task.participants = participantsDetails;
51-
collapsedTaskObject.task.participants = participantsDetails;
5248
const prList = [];
5349

5450
task.links?.forEach((link) => {
@@ -66,10 +62,6 @@ const getUserContributions = async (username) => {
6662
} else {
6763
all.push(noteworthyObject);
6864
}
69-
70-
collapsedTaskObject.prList = prList;
71-
72-
task.isCollapsed ? collapsed.push(collapsedTaskObject) : all.push(collapsedTaskObject);
7365
}
7466

7567
for (const prDetails of prMaps.values()) {
@@ -81,7 +73,6 @@ const getUserContributions = async (username) => {
8173
}
8274
}
8375
contributions.noteworthy = noteworthy;
84-
contributions.collapsed = collapsed;
8576
contributions.all = all;
8677
return contributions;
8778
};

test/integration/tasks.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,23 @@ describe("Tasks", function () {
290290
return done();
291291
});
292292
});
293+
it("Should update the task status collapsed for the given taskid", function (done) {
294+
chai
295+
.request(app)
296+
.patch("/tasks/" + taskId1)
297+
.set("cookie", `${cookieName}=${jwt}`)
298+
.send({
299+
isCollapsed: true,
300+
})
301+
.end((err, res) => {
302+
if (err) {
303+
return done(err);
304+
}
305+
expect(res).to.have.status(204);
306+
307+
return done();
308+
});
309+
});
293310
it("Should return fail response if task data has a non-acceptable status value to update the task for the given taskid", function (done) {
294311
chai
295312
.request(app)

0 commit comments

Comments
 (0)