File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed
src/components/conditions Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { useConditions } from '@hooks/useConditions';
66import { formatConditions } from '@services/conditionService' ;
77import { ConditionStatus , FormattedCondition } from '@types/condition' ;
88import { formatDate , formatDateTime } from '@utils/date' ;
9+ import { FormatDateResult } from '@types/date' ;
910
1011/**
1112 * Maps condition status to appropriate tag type
@@ -58,12 +59,20 @@ const ConditionsTable: React.FC = () => {
5859 { condition . status }
5960 </ Tag >
6061 ) ;
61- case 'onsetDate' :
62- return formatDate ( condition . onsetDate || '' ) ;
62+ case 'onsetDate' : {
63+ const onsetDate : FormatDateResult = formatDate (
64+ condition . onsetDate || '' ,
65+ ) ;
66+ return onsetDate . formattedResult || 'Not available' ;
67+ }
6368 case 'recorder' :
6469 return condition . recorder || 'Not available' ;
65- case 'recordedDate' :
66- return formatDateTime ( condition . recordedDate || '' ) ;
70+ case 'recordedDate' : {
71+ const recordedDate : FormatDateResult = formatDateTime (
72+ condition . recordedDate || '' ,
73+ ) ;
74+ return recordedDate . formattedResult || 'Not available' ;
75+ }
6776 }
6877 } ;
6978
Original file line number Diff line number Diff line change @@ -105,17 +105,19 @@ const mockedFormatConditions = formatConditions as jest.MockedFunction<
105105const mockedFormatDateTime = formatDateTime as jest . MockedFunction <
106106 typeof formatDateTime
107107> ;
108- const mockedFormatDate = formatDate as jest . MockedFunction <
109- typeof formatDateTime
110- > ;
108+ const mockedFormatDate = formatDate as jest . MockedFunction < typeof formatDate > ;
111109const mockedGenerateId = generateId as jest . MockedFunction < typeof generateId > ;
112110
113111describe ( 'ConditionsTable Unit Tests' , ( ) => {
114112 beforeEach ( ( ) => {
115113 jest . clearAllMocks ( ) ;
116114 mockedGenerateId . mockReturnValue ( 'mock-id' ) ;
117- mockedFormatDateTime . mockImplementation ( ( date ) => `Formatted: ${ date } ` ) ;
118- mockedFormatDate . mockImplementation ( ( date ) => `Formatted: ${ date } ` ) ;
115+ mockedFormatDateTime . mockImplementation ( ( date ) => ( {
116+ formattedResult : `Formatted: ${ date } ` ,
117+ } ) ) ;
118+ mockedFormatDate . mockImplementation ( ( date ) => ( {
119+ formattedResult : `Formatted: ${ date } ` ,
120+ } ) ) ;
119121 } ) ;
120122
121123 // 1. Component Initialization and Hook Interactions
You can’t perform that action at this time.
0 commit comments