@@ -44,12 +44,7 @@ describe("sendTaskUpdate function", () => {
4444
4545 await expect (
4646 sendTaskUpdate (
47- completed ,
48- planned ,
49- blockers ,
50- userName ,
51- taskId ,
52- taskTitle ,
47+ { completed, planned, blockers, userName, taskId, taskTitle } ,
5348 mockEnv
5449 )
5550 ) . rejects . toThrowError ( "Failed to send task update: 400 - Bad Request" ) ;
@@ -73,12 +68,7 @@ describe("sendTaskUpdate function", () => {
7368 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
7469
7570 await sendTaskUpdate (
76- completed ,
77- planned ,
78- blockers ,
79- userName ,
80- taskId ,
81- taskTitle ,
71+ { completed, planned, blockers, userName, taskId, taskTitle } ,
8272 mockEnv
8373 ) ;
8474
@@ -101,12 +91,7 @@ describe("sendTaskUpdate function", () => {
10191 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
10292
10393 await sendTaskUpdate (
104- completed ,
105- "" ,
106- "" ,
107- userName ,
108- taskId ,
109- taskTitle ,
94+ { completed, planned : "" , blockers : "" , userName, taskId, taskTitle } ,
11095 mockEnv
11196 ) ;
11297
@@ -128,7 +113,10 @@ describe("sendTaskUpdate function", () => {
128113 . spyOn ( global , "fetch" )
129114 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
130115
131- await sendTaskUpdate ( "" , planned , "" , userName , taskId , taskTitle , mockEnv ) ;
116+ await sendTaskUpdate (
117+ { completed : "" , planned, blockers : "" , userName, taskId, taskTitle } ,
118+ mockEnv
119+ ) ;
132120
133121 assertFetchCall ( url , bodyObj , mockEnv ) ;
134122 } ) ;
@@ -149,12 +137,7 @@ describe("sendTaskUpdate function", () => {
149137 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
150138
151139 await sendTaskUpdate (
152- "" ,
153- "" ,
154- blockers ,
155- userName ,
156- taskId ,
157- taskTitle ,
140+ { completed : "" , planned : "" , blockers, userName, taskId, taskTitle } ,
158141 mockEnv
159142 ) ;
160143
@@ -177,12 +160,7 @@ describe("sendTaskUpdate function", () => {
177160 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
178161
179162 await sendTaskUpdate (
180- completed ,
181- planned ,
182- "" ,
183- userName ,
184- taskId ,
185- taskTitle ,
163+ { completed, planned, blockers : "" , userName, taskId, taskTitle } ,
186164 mockEnv
187165 ) ;
188166
@@ -205,12 +183,7 @@ describe("sendTaskUpdate function", () => {
205183 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
206184
207185 await sendTaskUpdate (
208- completed ,
209- "" ,
210- blockers ,
211- userName ,
212- taskId ,
213- taskTitle ,
186+ { completed, planned : "" , blockers, userName, taskId, taskTitle } ,
214187 mockEnv
215188 ) ;
216189
@@ -233,15 +206,30 @@ describe("sendTaskUpdate function", () => {
233206 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
234207
235208 await sendTaskUpdate (
236- "" ,
237- planned ,
238- blockers ,
239- userName ,
240- taskId ,
241- taskTitle ,
209+ { completed : "" , planned, blockers, userName, taskId, taskTitle } ,
242210 mockEnv
243211 ) ;
244212
245213 assertFetchCall ( url , bodyObj , mockEnv ) ;
246214 } ) ;
215+
216+ test ( "should send the standup update to discord tracking channel when task id is absent" , async ( ) => {
217+ const url = config ( mockEnv ) . TRACKING_CHANNEL_URL ;
218+ const formattedString =
219+ `**${ userName } ** added a standup update\n` +
220+ `\n**Completed**\n${ completed } \n\n` +
221+ `**Planned**\n${ planned } \n\n` +
222+ `**Blockers**\n${ blockers } ` ;
223+ const bodyObj = {
224+ content : formattedString ,
225+ } ;
226+
227+ jest
228+ . spyOn ( global , "fetch" )
229+ . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
230+
231+ await sendTaskUpdate ( { completed, planned, blockers, userName } , mockEnv ) ;
232+
233+ assertFetchCall ( url , bodyObj , mockEnv ) ;
234+ } ) ;
247235} ) ;
0 commit comments