11import { render , screen } from '@testing-library/react' ;
22import { describe , expect , it } from 'vitest' ;
33import CreatorInitialsAvatar from '@/components/common/CreatorInitialsAvatar' ;
4- import { getFallbackAvatarColors } from '@/utils/avatarColor.util' ;
4+ import {
5+ getCreatorGradientFallback ,
6+ getFallbackAvatarColors ,
7+ } from '@/utils/avatarColor.util' ;
58
69describe ( 'CreatorInitialsAvatar' , ( ) => {
710 it ( 'uses deterministic fallback colors for the same creator id' , ( ) => {
@@ -14,6 +17,16 @@ describe('CreatorInitialsAvatar', () => {
1417 expect ( first . textColor ) . toBe ( 'rgba(255, 255, 255, 0.95)' ) ;
1518 } ) ;
1619
20+ it ( 'uses the fallback gradient helper deterministically for handles or ids' , ( ) => {
21+ const first = getCreatorGradientFallback ( 'creator-123' ) ;
22+ const second = getCreatorGradientFallback ( 'creator-123' ) ;
23+ const third = getCreatorGradientFallback ( 'creator-456' ) ;
24+
25+ expect ( first ) . toEqual ( second ) ;
26+ expect ( first ) . not . toBe ( third ) ;
27+ expect ( first ) . toContain ( 'linear-gradient' ) ;
28+ } ) ;
29+
1730 it ( 'renders initials fallback with hashed background when image is missing' , ( ) => {
1831 render ( < CreatorInitialsAvatar name = "Alex Rivers" creatorId = "creator-123" /> ) ;
1932
0 commit comments