@@ -57,58 +57,49 @@ describe('callStateToIcon', () => {
5757
5858describe ( 'getFormattedCallDuration' , ( ) => {
5959 it ( 'should return undefined when callDuration is undefined' , ( ) => {
60- const result = getFormattedCallDuration ( undefined , 'ended' ) ;
60+ const result = getFormattedCallDuration ( undefined ) ;
6161 expect ( result ) . toBeUndefined ( ) ;
6262 } ) ;
6363
64- it ( 'should return 00:00 when callDuration is 0' , ( ) => {
65- const result = getFormattedCallDuration ( 0 , 'ended' ) ;
66- expect ( result ) . toEqual ( { type : 'mrkdwn' , text : '*00:00*' } ) ;
64+ it ( 'should return undefined when callDuration is 0' , ( ) => {
65+ const result = getFormattedCallDuration ( 0 ) ;
66+ expect ( result ) . toBeUndefined ( ) ;
6767 } ) ;
6868
6969 it ( 'should format duration correctly for seconds only (less than 60 seconds)' , ( ) => {
70- const result = getFormattedCallDuration ( 30 , 'ended' ) ;
70+ const result = getFormattedCallDuration ( 30 ) ;
7171 expect ( result ) . toEqual ( { type : 'mrkdwn' , text : '*00:30*' } ) ;
7272 } ) ;
7373
7474 it ( 'should format duration correctly for minutes and seconds (less than 1 hour)' , ( ) => {
75- const result = getFormattedCallDuration ( 125 , 'ended' ) ; // 2 minutes 5 seconds
75+ const result = getFormattedCallDuration ( 125 ) ; // 2 minutes 5 seconds
7676 expect ( result ) . toEqual ( { type : 'mrkdwn' , text : '*02:05*' } ) ;
7777 } ) ;
7878
7979 it ( 'should format duration correctly for exactly 1 minute' , ( ) => {
80- const result = getFormattedCallDuration ( 60 , 'ended' ) ;
80+ const result = getFormattedCallDuration ( 60 ) ;
8181 expect ( result ) . toEqual ( { type : 'mrkdwn' , text : '*01:00*' } ) ;
8282 } ) ;
8383
8484 it ( 'should format duration correctly for hours, minutes, and seconds' , ( ) => {
85- const result = getFormattedCallDuration ( 3665 , 'ended' ) ; // 1 hour 1 minute 5 seconds
85+ const result = getFormattedCallDuration ( 3665 ) ; // 1 hour 1 minute 5 seconds
8686 expect ( result ) . toEqual ( { type : 'mrkdwn' , text : '*01:01:05*' } ) ;
8787 } ) ;
8888
8989 it ( 'should format duration correctly for multiple hours' , ( ) => {
90- const result = getFormattedCallDuration ( 7325 , 'ended' ) ; // 2 hours 2 minutes 5 seconds
90+ const result = getFormattedCallDuration ( 7325 ) ; // 2 hours 2 minutes 5 seconds
9191 expect ( result ) . toEqual ( { type : 'mrkdwn' , text : '*02:02:05*' } ) ;
9292 } ) ;
9393
9494 it ( 'should pad single digit values with zeros' , ( ) => {
95- const result = getFormattedCallDuration ( 61 , 'ended' ) ; // 1 minute 1 second
95+ const result = getFormattedCallDuration ( 61 ) ; // 1 minute 1 second
9696 expect ( result ) . toEqual ( { type : 'mrkdwn' , text : '*01:01*' } ) ;
9797 } ) ;
9898
9999 it ( 'should handle large durations correctly' , ( ) => {
100- const result = getFormattedCallDuration ( 36661 , 'ended' ) ; // 10 hours 11 minutes 1 second
100+ const result = getFormattedCallDuration ( 36661 ) ; // 10 hours 11 minutes 1 second
101101 expect ( result ) . toEqual ( { type : 'mrkdwn' , text : '*10:11:01*' } ) ;
102102 } ) ;
103-
104- it ( 'should return undefined when callState is not "ended" or "transferred"' , ( ) => {
105- const resultNotAnswered = getFormattedCallDuration ( 125 , 'not-answered' ) ;
106- const resultFailed = getFormattedCallDuration ( 125 , 'failed' ) ;
107- const resultError = getFormattedCallDuration ( 125 , 'error' ) ;
108- expect ( resultNotAnswered ) . toBeUndefined ( ) ;
109- expect ( resultFailed ) . toBeUndefined ( ) ;
110- expect ( resultError ) . toBeUndefined ( ) ;
111- } ) ;
112103} ) ;
113104
114105describe ( 'getHistoryMessagePayload' , ( ) => {
@@ -270,11 +261,10 @@ describe('getHistoryMessagePayload', () => {
270261 } ) ;
271262
272263 it ( 'should handle all call states with duration correctly' , ( ) => {
273- const activeStates = [ 'ended' , 'transferred' ] as const ;
274- const notActiveStates = [ 'not-answered' , 'failed' , 'error' ] as const ;
264+ const states = [ 'ended' , 'transferred' , 'not-answered' , 'failed' , 'error' ] as const ;
275265 const duration = 125 ;
276266
277- activeStates . forEach ( ( state ) => {
267+ states . forEach ( ( state ) => {
278268 const result = getHistoryMessagePayload ( state , duration ) ;
279269 expect ( result . msg ) . toBe ( '' ) ;
280270 expect ( result . groupable ) . toBe ( false ) ;
@@ -284,13 +274,5 @@ describe('getHistoryMessagePayload', () => {
284274 expect ( result . blocks [ 0 ] . rows [ 1 ] . background ) . toBe ( 'secondary' ) ;
285275 expect ( result . blocks [ 0 ] . rows [ 1 ] . elements [ 0 ] . type ) . toBe ( 'mrkdwn' ) ;
286276 } ) ;
287- notActiveStates . forEach ( ( state ) => {
288- const result = getHistoryMessagePayload ( state , duration ) ;
289- expect ( result . msg ) . toBe ( '' ) ;
290- expect ( result . groupable ) . toBe ( false ) ;
291- expect ( result . blocks ) . toHaveLength ( 1 ) ;
292- expect ( result . blocks [ 0 ] . type ) . toBe ( 'info_card' ) ;
293- expect ( result . blocks [ 0 ] . rows ) . toHaveLength ( 1 ) ;
294- } ) ;
295277 } ) ;
296278} ) ;
0 commit comments