Skip to content

Commit

Permalink
chore: add getDMReminderMessage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moromis committed Apr 2, 2024
1 parent eb7a112 commit b9a4124
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cov-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/constants/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const NO_ASSIGNED_CHORE =
const MAYBE_NO_CHORE =
"Couldn't find your chore. Maybe you need to do `/assign`?";
const SWAP_FAILED = "Failed to swap for a new chore.";
const LAST_DAY = "This is the last day";

const strings = {
USER_HAS_CHORE,
Expand All @@ -16,6 +17,7 @@ const strings = {
NO_ASSIGNED_CHORE,
SWAP_FAILED,
MAYBE_NO_CHORE,
LAST_DAY,
};

module.exports = strings;
3 changes: 2 additions & 1 deletion src/helpers/getDMReminderMessage.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const strings = require("../constants/strings");
const { getChoreMessage } = require("./getChoreMessage");

exports.getDMReminderMessage = (days, chore) => {
let timeString = `you have ${days} ${days === 1 ? "day" : "days"}`;
if (days === 0) {
timeString = "This is the last day";
timeString = strings.LAST_DAY;
}
return `### Reminder: ${timeString} to do your chore.\n${getChoreMessage(
chore,
Expand Down
16 changes: 16 additions & 0 deletions src/helpers/getDMReminderMessage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const strings = require("../constants/strings");
const { getChoreMessage } = require("./getChoreMessage");
const { getDMReminderMessage } = require("./getDMReminderMessage");

jest.mock("./getChoreMessage");

describe("getDMReminderMessage", () => {
it("should use getChoreMessage to compose its message", () => {
getDMReminderMessage();
expect(getChoreMessage).toHaveBeenCalled();
});
it("should let you know this is the last day if 0 days is passed", () => {
const message = getDMReminderMessage(0);
expect(message).toContain(strings.LAST_DAY);
});
});

0 comments on commit b9a4124

Please sign in to comment.