File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ const PatientHeader: React.FC<PatientHeaderProps> = ({
2222} ) => {
2323 const { t } = useTranslation ( ) ;
2424
25+ const handleOnButtonClick = ( ) => {
26+ if ( ! isActionAreaVisible ) setIsActionAreaVisible ( true ) ;
27+ } ;
28+
2529 return (
2630 < Tile aria-label = { t ( 'PATIENT_HEADER_LABEL' ) } className = { styles . header } >
2731 < Grid >
@@ -40,11 +44,7 @@ const PatientHeader: React.FC<PatientHeaderProps> = ({
4044 xl = { isActionAreaVisible ? 6 : 3 }
4145 className = { styles . controls }
4246 >
43- < Button
44- size = "lg"
45- onClick = { ( ) => setIsActionAreaVisible ( ! isActionAreaVisible ) }
46- renderIcon = { Add }
47- >
47+ < Button size = "lg" onClick = { handleOnButtonClick } renderIcon = { Add } >
4848 { t ( 'PATIENT_HEADER_SHOW_ACTION_AREA' ) }
4949 </ Button >
5050 </ Column >
Original file line number Diff line number Diff line change @@ -98,14 +98,13 @@ describe('PatientHeader Component', () => {
9898 expect ( mockSetIsActionAreaVisible ) . toHaveBeenCalledWith ( true ) ;
9999 } ) ;
100100
101- test ( 'calls setIsActionAreaVisible with toggled value when button is clicked (starting with true) ' , ( ) => {
101+ test ( 'setIsActionAreaVisible is not called when action area is already visible ' , ( ) => {
102102 renderComponent ( { isActionAreaVisible : true } ) ;
103103 const button = screen . getByRole ( 'button' ) ;
104104
105105 fireEvent . click ( button ) ;
106106
107- expect ( mockSetIsActionAreaVisible ) . toHaveBeenCalledTimes ( 1 ) ;
108- expect ( mockSetIsActionAreaVisible ) . toHaveBeenCalledWith ( false ) ;
107+ expect ( mockSetIsActionAreaVisible ) . toHaveBeenCalledTimes ( 0 ) ;
109108 } ) ;
110109 } ) ;
111110
You can’t perform that action at this time.
0 commit comments