@@ -5,25 +5,16 @@ import { render, screen } from '@testing-library/react';
55import ProfileCard from './ProfileCard' ;
66import { Profile } from '@/app/types/profile' ;
77import { userEvent } from '@testing-library/user-event' ;
8+ import { type ComponentProps } from 'react' ;
89
910jest . mock ( '@radix-ui/react-avatar' , ( ) => {
1011 const actual = jest . requireActual ( '@radix-ui/react-avatar' ) ;
11- return {
12+ return ( {
1213 ...actual ,
13- Image : ( { src, alt, ...props } : { src ?: string ; alt ?: string } ) => {
14- if ( ! src ) {
15- return (
16- < img
17- data-testid = "avatar-fallback-image"
18- src = "https://static.vecteezy.com/system/resources/previews/024/183/525/non_2x/avatar-of-a-man-portrait-of-a-young-guy-illustration-of-male-character-in-modern-color-style-vector.jpg"
19- alt = "default avatar"
20- { ...props }
21- />
22- ) ;
23- }
24- return < img data-testid = "avatar-image" src = { src } alt = { alt } { ...props } /> ;
25- } ,
26- } ;
14+ Image : ( props : ComponentProps < 'img' > ) => {
15+ return < img { ...props } /> ;
16+ }
17+ } )
2718} ) ;
2819
2920const testProfile : Profile = {
@@ -91,11 +82,9 @@ describe('ProfileCard', () => {
9182 showEditButton = { false }
9283 /> ,
9384 ) ;
94- const avatarFallbackImage = screen . getByTestId ( 'avatar-fallback-image' ) ;
95- expect ( avatarFallbackImage ) . toHaveAttribute (
96- 'src' ,
97- 'https://static.vecteezy.com/system/resources/previews/024/183/525/non_2x/avatar-of-a-man-portrait-of-a-young-guy-illustration-of-male-character-in-modern-color-style-vector.jpg' ,
98- ) ;
85+
86+ const avatarFallbackImage = screen . getByTestId ( 'avatar-fallback' ) ;
87+ expect ( avatarFallbackImage ) . toBeInTheDocument ( ) ;
9988 } ) ;
10089
10190 it ( 'Edit Profile Button navigates to the onboarding path after user click' , async ( ) => {
0 commit comments