@@ -15,7 +15,7 @@ const appearances: AccentAppearance[] = [
1515 'accent4' ,
1616] ;
1717
18- const sizes : AvatarSize [ ] = [ 'regular' , 'tiny' ] ;
18+ const sizes : AvatarSize [ ] = [ 'regular' , 'tiny' , 'micro' ] ;
1919
2020const shapes : AvatarShape [ ] = [ 'round' , 'square' ] ;
2121const booleanValues = [ true , false ] ;
@@ -134,14 +134,14 @@ describe('Avatar component with prop:appearance', () => {
134134} ) ;
135135
136136describe ( 'Avatar component accessibility' , ( ) => {
137- it ( 'should have the Avatar-content class when appearance is secondary' , ( ) => {
137+ it ( 'should have the Avatar-content--secondary class when appearance is secondary' , ( ) => {
138138 const { getByTestId } = render ( < Avatar appearance = "secondary" > Design</ Avatar > ) ;
139- expect ( getByTestId ( 'DesignSystem-Text' ) ) . toHaveClass ( 'Avatar-content' ) ;
139+ expect ( getByTestId ( 'DesignSystem-Text' ) ) . toHaveClass ( 'Avatar-content--secondary ' ) ;
140140 } ) ;
141141
142- it ( 'should not have the Avatar-content class when appearance is primary' , ( ) => {
142+ it ( 'should have the Avatar-content--primary class when appearance is primary' , ( ) => {
143143 const { getByTestId } = render ( < Avatar appearance = "primary" > Design</ Avatar > ) ;
144- expect ( getByTestId ( 'DesignSystem-Text' ) ) . not . toHaveClass ( 'Avatar-content' ) ;
144+ expect ( getByTestId ( 'DesignSystem-Text' ) ) . toHaveClass ( 'Avatar-content--primary ' ) ;
145145 } ) ;
146146} ) ;
147147
@@ -316,3 +316,94 @@ describe('Avatar component with prop:status', () => {
316316 expect ( statusElement ) . toHaveStyle ( 'box-shadow: 0 0 0 var(--spacing-05) red' ) ;
317317 } ) ;
318318} ) ;
319+
320+ describe ( 'Avatar component with prop:shape square fallback icon' , ( ) => {
321+ it ( 'should render groups icon when shape is square and no initials' , ( ) => {
322+ const { getByTestId } = render ( < Avatar shape = "square" /> ) ;
323+ const icon = getByTestId ( 'DesignSystem-Avatar--Icon' ) ;
324+ expect ( icon ) . toBeInTheDocument ( ) ;
325+ expect ( icon . textContent ) . toBe ( 'groups' ) ;
326+ } ) ;
327+
328+ it ( 'should render person icon when shape is round and no initials' , ( ) => {
329+ const { getByTestId } = render ( < Avatar shape = "round" /> ) ;
330+ const icon = getByTestId ( 'DesignSystem-Avatar--Icon' ) ;
331+ expect ( icon ) . toBeInTheDocument ( ) ;
332+ expect ( icon . textContent ) . toBe ( 'person' ) ;
333+ } ) ;
334+
335+ it ( 'should render initials when shape is square and initials are provided' , ( ) => {
336+ const { getByTestId, queryByTestId } = render ( < Avatar shape = "square" firstName = "John" lastName = "Doe" /> ) ;
337+ expect ( getByTestId ( 'DesignSystem-Avatar' ) . textContent ) . toMatch ( 'JD' ) ;
338+ expect ( queryByTestId ( 'DesignSystem-Avatar--Icon' ) ) . not . toBeInTheDocument ( ) ;
339+ } ) ;
340+ } ) ;
341+
342+ describe ( 'Avatar component with prop:size micro and presence/status' , ( ) => {
343+ it ( 'should not render presence when size is micro' , ( ) => {
344+ render ( < Avatar firstName = "John" lastName = "Doe" presence = "active" size = "micro" /> ) ;
345+ const presenceEle = screen . queryByTestId ( 'DesignSystem-Avatar--Presence' ) ;
346+ expect ( presenceEle ) . not . toBeInTheDocument ( ) ;
347+ } ) ;
348+
349+ it ( 'should not render status when size is micro' , ( ) => {
350+ render (
351+ < Avatar firstName = "John" lastName = "Doe" status = { statusComponent } size = "micro" >
352+ Design
353+ </ Avatar >
354+ ) ;
355+ const statusElement = screen . queryByTestId ( 'DesignSystem-Avatar--Status' ) ;
356+ expect ( statusElement ) . not . toBeInTheDocument ( ) ;
357+ } ) ;
358+
359+ it ( 'should render presence when size is regular' , ( ) => {
360+ const { getByTestId } = render ( < Avatar firstName = "John" lastName = "Doe" presence = "active" size = "regular" /> ) ;
361+ const presenceEle = getByTestId ( 'DesignSystem-Avatar--Presence' ) ;
362+ expect ( presenceEle ) . toBeInTheDocument ( ) ;
363+ } ) ;
364+
365+ it ( 'should render status when size is regular' , ( ) => {
366+ const { getByTestId } = render (
367+ < Avatar status = { statusComponent } size = "regular" >
368+ Design
369+ </ Avatar >
370+ ) ;
371+ const statusElement = getByTestId ( 'DesignSystem-Avatar--Status' ) ;
372+ expect ( statusElement ) . toBeInTheDocument ( ) ;
373+ } ) ;
374+ } ) ;
375+
376+ describe ( 'Avatar component with Avatar.Image child and appearance' , ( ) => {
377+ it ( 'should apply appearance background when Avatar.Image is child' , ( ) => {
378+ const { getByTestId } = render (
379+ < Avatar appearance = "primary" firstName = "John" lastName = "Doe" >
380+ < Avatar . Image src = "https://design.innovaccer.com/images/avatar2.jpeg" />
381+ </ Avatar >
382+ ) ;
383+ const avatarElement = getByTestId ( 'DesignSystem-Avatar' ) ;
384+ expect ( avatarElement ) . toHaveClass ( 'Avatar--primary' ) ;
385+ } ) ;
386+
387+ it ( 'should apply appearance background when Avatar.Icon is child' , ( ) => {
388+ const { getByTestId } = render (
389+ < Avatar appearance = "primary" firstName = "John" lastName = "Doe" >
390+ < Avatar . Icon name = "person" />
391+ </ Avatar >
392+ ) ;
393+ const avatarElement = getByTestId ( 'DesignSystem-Avatar' ) ;
394+ expect ( avatarElement ) . toHaveClass ( 'Avatar--primary' ) ;
395+ } ) ;
396+
397+ it ( 'should apply appearance background when only initials are provided' , ( ) => {
398+ const { getByTestId } = render ( < Avatar appearance = "primary" firstName = "John" lastName = "Doe" /> ) ;
399+ const avatarElement = getByTestId ( 'DesignSystem-Avatar' ) ;
400+ expect ( avatarElement ) . toHaveClass ( 'Avatar--primary' ) ;
401+ } ) ;
402+ } ) ;
403+
404+ describe ( 'Avatar component with prop:size micro' , ( ) => {
405+ it ( 'should have the Avatar--micro class when size is micro' , ( ) => {
406+ const { getByTestId } = render ( < Avatar size = "micro" > Design</ Avatar > ) ;
407+ expect ( getByTestId ( 'DesignSystem-Avatar' ) ) . toHaveClass ( 'Avatar--micro' ) ;
408+ } ) ;
409+ } ) ;
0 commit comments