Skip to content

Commit

Permalink
ONLY if original message was in a thread
Browse files Browse the repository at this point in the history
  • Loading branch information
mgwalker committed May 24, 2024
1 parent b470ea5 commit 9d5e142
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/scripts/federal-holidays.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ module.exports = (app) => {
app.message(
directMention(),
/next (federal )?holiday/i,
({ event: { thread_ts: thread, ts }, say }) => {
say({ text: getHolidayText(), thread_ts: thread ?? ts });
({ event: { thread_ts: thread }, say }) => {
say({ text: getHolidayText(), thread_ts: thread });
incrementStats("next federal holiday request");
},
);
Expand Down
14 changes: 7 additions & 7 deletions src/scripts/federal-holidays.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ describe("federal holidays bot", () => {
name: "Test Holiday day",
});

handler({ event: { ts: 0 }, say });
handler({ event: {}, say });

expect(say.mock.calls.length).toBe(1);
expect(say).toHaveBeenCalledWith({
text: "The next federal holiday is Test Holiday day in 1 days on Friday, January 2nd",
thread_ts: 0,
thread_ts: undefined,
});
});

Expand All @@ -103,7 +103,7 @@ describe("federal holidays bot", () => {
alsoObservedAs: "Other holiday day day day",
});

handler({ event: { thread_ts: "thread", ts: 12345 }, say });
handler({ event: { thread_ts: "thread" }, say });

expect(say.mock.calls.length).toBe(1);
expect(say).toHaveBeenCalledWith({
Expand All @@ -124,12 +124,12 @@ describe("federal holidays bot", () => {
name: "Christmas Day",
});

handler({ event: { ts: 12345 }, say });
handler({ event: {}, say });

expect(say.mock.calls.length).toBe(1);
expect(say).toHaveBeenCalledWith({
text: "The next federal holiday is Christmas Day :christmas_tree: in 1 days on Friday, January 2nd",
thread_ts: 12345,
thread_ts: undefined,
});
});

Expand All @@ -144,12 +144,12 @@ describe("federal holidays bot", () => {
alsoObservedAs: "Indigenous Peoples' Day",
});

handler({ event: { ts: 0 }, say });
handler({ event: {}, say });

expect(say.mock.calls.length).toBe(1);
expect(say).toHaveBeenCalledWith({
text: "The next federal holiday is Indigenous Peoples' Day in 1 days on Friday, January 2nd",
thread_ts: 0,
thread_ts: undefined,
});
});
});
Expand Down

0 comments on commit 9d5e142

Please sign in to comment.