Skip to content

Commit 7bb92a5

Browse files
Fix response of /task command (#184)
* fix response and write test * Update formatTask.test.ts --------- Co-authored-by: Amit Prakash <[email protected]>
1 parent 7d09d30 commit 7bb92a5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/utils/formatTask.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export function generateTaskResponseMessage(
2121
formattedTasks: string[],
2222
status: string
2323
) {
24-
const title = `## ${formatStatusToTitleCase(status)} Tasks of ${nickName}`;
24+
const title =
25+
formattedTasks.length !== 0
26+
? `## ${formatStatusToTitleCase(status)} Tasks of ${nickName}`
27+
: `## ${nickName} doesn't have any in-progress task`;
2528
const tasks = formattedTasks.join("\n\n");
2629
const allTaskLink = `[→ All Tasks](${RDS_STATUS_SITE_URL}/tasks?q=status:all+assignee:${nickName})
2730
`;

tests/unit/utils/formatTask.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,18 @@ describe("Test generateTaskResponseMessage function", () => {
6464
const expectedResponseMessage = `${expectedMessage}\n${task1}\n\n${task2}\n${allTaskURL}\n`;
6565
expect(responseMessage).toBe(expectedResponseMessage);
6666
});
67+
68+
it("should return a string if user don't have any in-progress task", () => {
69+
const formattedTasks: [] = [];
70+
console.log("format task frm fail", formattedTasks.length);
71+
const responseMessage = generateTaskResponseMessage(
72+
"anish-pawaskar",
73+
formattedTasks,
74+
"IN_PROGRESS"
75+
);
76+
const expectedMessage = `## anish-pawaskar doesn't have any in-progress task`;
77+
const allTaskURL = `[→ All Tasks](https://status.realdevsquad.com/tasks?q=status:all+assignee:anish-pawaskar)`;
78+
const expectedResponseMessage = `${expectedMessage}\n\n${allTaskURL}\n`;
79+
expect(responseMessage).toBe(expectedResponseMessage);
80+
});
6781
});

0 commit comments

Comments
 (0)