@@ -37,7 +37,7 @@ describe('propsToPropsWithTypography', () => {
3737 figma . getStyleByIdAsync = ( id : string ) =>
3838 Promise . resolve (
3939 id === 'ts-1'
40- ? ( { id : 'ts-1' , name : 'Typography /Body' } as unknown as BaseStyle )
40+ ? ( { id : 'ts-1' , name : 'mobile /Body' } as unknown as BaseStyle )
4141 : null ,
4242 ) as ReturnType < typeof figma . getStyleByIdAsync >
4343
@@ -63,6 +63,45 @@ describe('propsToPropsWithTypography', () => {
6363 figma . getStyleByIdAsync = origGetStyle
6464 } )
6565
66+ it ( 'should preserve scoped (non-breakpoint) prefix in typography key' , async ( ) => {
67+ const origGetLocal = figma . getLocalTextStylesAsync
68+ const origGetStyle = figma . getStyleByIdAsync
69+ figma . getLocalTextStylesAsync = ( ) =>
70+ Promise . resolve ( [ { id : 'ts-cms' } as unknown as TextStyle ] ) as ReturnType <
71+ typeof figma . getLocalTextStylesAsync
72+ >
73+ figma . getStyleByIdAsync = ( id : string ) =>
74+ Promise . resolve (
75+ id === 'ts-cms'
76+ ? ( {
77+ id : 'ts-cms' ,
78+ name : 'cms/bodyLgBold' ,
79+ } as unknown as BaseStyle )
80+ : null ,
81+ ) as ReturnType < typeof figma . getStyleByIdAsync >
82+
83+ // Async path — "cms/" is not a breakpoint, so the full name must be
84+ // converted to camelCase to match the devup.json export key.
85+ const r1 = await propsToPropsWithTypography (
86+ { fontFamily : 'Arial' , fontSize : 18 } ,
87+ 'ts-cms' ,
88+ )
89+ expect ( r1 . typography ) . toBe ( 'cmsBodyLgBold' )
90+ expect ( r1 . fontFamily ) . toBeUndefined ( )
91+ expect ( r1 . fontSize ) . toBeUndefined ( )
92+
93+ // Sync fast path — same assertion via the resolved cache branch.
94+ const r2 = await propsToPropsWithTypography (
95+ { fontFamily : 'Inter' , fontSize : 20 } ,
96+ 'ts-cms' ,
97+ )
98+ expect ( r2 . typography ) . toBe ( 'cmsBodyLgBold' )
99+ expect ( r2 . fontFamily ) . toBeUndefined ( )
100+
101+ figma . getLocalTextStylesAsync = origGetLocal
102+ figma . getStyleByIdAsync = origGetStyle
103+ } )
104+
66105 it ( 'should return early from sync path when textStyleId not in resolved set' , async ( ) => {
67106 const origGetLocal = figma . getLocalTextStylesAsync
68107 const origGetStyle = figma . getStyleByIdAsync
0 commit comments