|
| 1 | +import { completeTaskReportMessage } from "@src/reminders/messages"; |
| 2 | +import { itemFactory } from "../../factories/itemFactory"; |
| 3 | +import { Item } from "@src/items"; |
| 4 | + |
| 5 | +describe("completeTaskReportMessage", () => { |
| 6 | + it("will show the default message when there are no urgent or unassigned items", () => { |
| 7 | + const urgentItems: Item[] = []; |
| 8 | + const unassignedItems: Item[] = []; |
| 9 | + const upcomingItems: Item[] = [itemFactory()]; |
| 10 | + |
| 11 | + const result = completeTaskReportMessage({ |
| 12 | + urgentItems, |
| 13 | + unassignedItems, |
| 14 | + upcomingItems, |
| 15 | + }); |
| 16 | + |
| 17 | + expect(result.title).toBe("Biweekly Tasks Reminder ☀️🌱"); |
| 18 | + expect(result.message).toBe("Nothing urgent or unassigned upcoming! 🐀🥂"); |
| 19 | + expect(result.sections).toEqual([ |
| 20 | + { |
| 21 | + title: "📅 Assigned Items", |
| 22 | + items: upcomingItems, |
| 23 | + includeLinks: false, |
| 24 | + }, |
| 25 | + ]); |
| 26 | + }); |
| 27 | + |
| 28 | + it("will include the urgent section when there are urgent items", () => { |
| 29 | + const urgentItems: Item[] = [itemFactory()]; |
| 30 | + const unassignedItems: Item[] = []; |
| 31 | + const upcomingItems: Item[] = []; |
| 32 | + |
| 33 | + const result = completeTaskReportMessage({ |
| 34 | + urgentItems, |
| 35 | + unassignedItems, |
| 36 | + upcomingItems, |
| 37 | + }); |
| 38 | + |
| 39 | + expect(result.message).toContain("Check out all upcoming tasks"); |
| 40 | + expect(result.sections).toEqual([ |
| 41 | + { |
| 42 | + title: "🔥 Urgent & Overdue", |
| 43 | + items: urgentItems, |
| 44 | + includeLinks: true, |
| 45 | + }, |
| 46 | + ]); |
| 47 | + }); |
| 48 | + |
| 49 | + it("will include the unassigned section when there are unassigned items", () => { |
| 50 | + const urgentItems: Item[] = []; |
| 51 | + const unassignedItems: Item[] = [itemFactory()]; |
| 52 | + const upcomingItems: Item[] = []; |
| 53 | + |
| 54 | + const result = completeTaskReportMessage({ |
| 55 | + urgentItems, |
| 56 | + unassignedItems, |
| 57 | + upcomingItems, |
| 58 | + }); |
| 59 | + |
| 60 | + expect(result.sections).toEqual([ |
| 61 | + { |
| 62 | + title: "📥 Unassigned Items", |
| 63 | + items: unassignedItems, |
| 64 | + includeLinks: false, |
| 65 | + }, |
| 66 | + ]); |
| 67 | + }); |
| 68 | + |
| 69 | + it("includes all sections when all item types are present", () => { |
| 70 | + const urgentItems: Item[] = [itemFactory()]; |
| 71 | + const unassignedItems: Item[] = [itemFactory()]; |
| 72 | + const upcomingItems: Item[] = [itemFactory()]; |
| 73 | + |
| 74 | + const result = completeTaskReportMessage({ |
| 75 | + urgentItems, |
| 76 | + unassignedItems, |
| 77 | + upcomingItems, |
| 78 | + }); |
| 79 | + |
| 80 | + expect(result.sections).toEqual([ |
| 81 | + { |
| 82 | + title: "🔥 Urgent & Overdue", |
| 83 | + items: urgentItems, |
| 84 | + includeLinks: true, |
| 85 | + }, |
| 86 | + { |
| 87 | + title: "📅 Assigned Items", |
| 88 | + items: upcomingItems, |
| 89 | + includeLinks: false, |
| 90 | + }, |
| 91 | + { |
| 92 | + title: "📥 Unassigned Items", |
| 93 | + items: unassignedItems, |
| 94 | + includeLinks: false, |
| 95 | + }, |
| 96 | + ]); |
| 97 | + }); |
| 98 | + |
| 99 | + it("returns no sections and default message when all item arrays are empty", () => { |
| 100 | + const result = completeTaskReportMessage({ |
| 101 | + urgentItems: [], |
| 102 | + unassignedItems: [], |
| 103 | + upcomingItems: [], |
| 104 | + }); |
| 105 | + |
| 106 | + expect(result.message).toBe( |
| 107 | + "Check out all upcoming tasks [here.](https://github.com/orgs/CarletonComputerScienceSociety/projects/18) 🐀🐀", |
| 108 | + ); |
| 109 | + expect(result.sections).toEqual([]); |
| 110 | + }); |
| 111 | +}); |
0 commit comments