1- import { describe , expect , it , jest } from "@jest/globals" ;
1+ import { describe , expect , it , jest , beforeEach } from "@jest/globals" ;
22import { simpleTaskReportMessage } from "@src/reminders/messages" ;
33import { itemFactory } from "../../factories/itemFactory" ;
44
@@ -7,27 +7,51 @@ jest.mock("@src/constants", () => ({
77 EMOJIS : [ "🧪" ] ,
88} ) ) ;
99
10+ // Mock @infrastructure /facts
11+ jest . mock ( "@infrastructure/facts" , ( ) => ( {
12+ fetchFact : jest . fn ( ) ,
13+ } ) ) ;
14+
15+ import { fetchFact } from "@infrastructure/facts" ;
16+
1017describe ( "simpleTaskReportMessage" , ( ) => {
11- it ( "will return default message when both urgent and unassigned are empty" , ( ) => {
12- const result = simpleTaskReportMessage ( {
18+ // Define the mocked return shape explicitly
19+ beforeEach ( ( ) => {
20+ // @ts -ignore – mocking return type to match Result<string, Error>
21+ ( fetchFact as jest . Mock ) . mockResolvedValue ( {
22+ ok : true ,
23+ val : "Fun facts make reports better" ,
24+ } ) ;
25+ } ) ;
26+
27+ it ( "returns default message when both urgent and unassigned are empty" , async ( ) => {
28+ const result = await simpleTaskReportMessage ( {
1329 urgentItems : [ ] ,
1430 unassignedItems : [ ] ,
1531 } ) ;
1632
1733 expect ( result . title ) . toBe ( "Daily Task Reminder 🧪" ) ;
18- expect ( result . message ) . toBe ( "Nothing urgent or unassigned today! 🐀🥂" ) ;
34+ expect ( result . message ) . toContain (
35+ "Nothing urgent or unassigned today! 🐀🥂" ,
36+ ) ;
37+ expect ( result . message ) . toContain (
38+ "💡 **Fun Fact**: Fun facts make reports better." ,
39+ ) ;
1940 expect ( result . sections ) . toEqual ( [ ] ) ;
2041 } ) ;
2142
22- it ( "will include urgent section when there are urgent items" , ( ) => {
43+ it ( "includes urgent section when there are urgent items" , async ( ) => {
2344 const urgent = [ itemFactory ( ) ] ;
2445
25- const result = simpleTaskReportMessage ( {
46+ const result = await simpleTaskReportMessage ( {
2647 urgentItems : urgent ,
2748 unassignedItems : [ ] ,
2849 } ) ;
2950
3051 expect ( result . message ) . toContain ( "Check out all upcoming tasks" ) ;
52+ expect ( result . message ) . toContain (
53+ "💡 **Fun Fact**: Fun facts make reports better." ,
54+ ) ;
3155 expect ( result . sections ) . toEqual ( [
3256 {
3357 title : "🔥 Urgent & Overdue" ,
@@ -37,10 +61,10 @@ describe("simpleTaskReportMessage", () => {
3761 ] ) ;
3862 } ) ;
3963
40- it ( "will include unassigned section when there are unassigned items" , ( ) => {
64+ it ( "includes unassigned section when there are unassigned items" , async ( ) => {
4165 const unassigned = [ itemFactory ( ) ] ;
4266
43- const result = simpleTaskReportMessage ( {
67+ const result = await simpleTaskReportMessage ( {
4468 urgentItems : [ ] ,
4569 unassignedItems : unassigned ,
4670 } ) ;
@@ -52,13 +76,16 @@ describe("simpleTaskReportMessage", () => {
5276 includeLinks : false ,
5377 } ,
5478 ] ) ;
79+ expect ( result . message ) . toContain (
80+ "💡 **Fun Fact**: Fun facts make reports better." ,
81+ ) ;
5582 } ) ;
5683
57- it ( "will include both sections when both item types are present" , ( ) => {
84+ it ( "includes both sections when both item types are present" , async ( ) => {
5885 const urgent = [ itemFactory ( ) ] ;
5986 const unassigned = [ itemFactory ( ) ] ;
6087
61- const result = simpleTaskReportMessage ( {
88+ const result = await simpleTaskReportMessage ( {
6289 urgentItems : urgent ,
6390 unassignedItems : unassigned ,
6491 } ) ;
@@ -75,5 +102,8 @@ describe("simpleTaskReportMessage", () => {
75102 includeLinks : false ,
76103 } ,
77104 ] ) ;
105+ expect ( result . message ) . toContain (
106+ "💡 **Fun Fact**: Fun facts make reports better." ,
107+ ) ;
78108 } ) ;
79109} ) ;
0 commit comments