11// SPDX-License-Identifier: MIT
22import { describe , it , expect } from 'vitest' ;
3- import { A2uiIconComponent } from './icon.component' ;
3+ import { A2uiIconComponent , toMaterialSymbolName } from './icon.component' ;
44
55describe ( 'A2uiIconComponent' , ( ) => {
66 // Display-only component: renders name() input as a <span>.
@@ -11,3 +11,24 @@ describe('A2uiIconComponent', () => {
1111 expect ( A2uiIconComponent ) . toBeDefined ( ) ;
1212 } ) ;
1313} ) ;
14+
15+ describe ( 'toMaterialSymbolName' , ( ) => {
16+ it ( 'converts camelCase identifiers to snake_case ligatures' , ( ) => {
17+ expect ( toMaterialSymbolName ( 'accountCircle' ) ) . toBe ( 'account_circle' ) ;
18+ expect ( toMaterialSymbolName ( 'shoppingCart' ) ) . toBe ( 'shopping_cart' ) ;
19+ expect ( toMaterialSymbolName ( 'moreVert' ) ) . toBe ( 'more_vert' ) ;
20+ expect ( toMaterialSymbolName ( 'visibilityOff' ) ) . toBe ( 'visibility_off' ) ;
21+ expect ( toMaterialSymbolName ( 'arrowForward' ) ) . toBe ( 'arrow_forward' ) ;
22+ } ) ;
23+
24+ it ( 'passes single-word and already-snake_case names through unchanged' , ( ) => {
25+ expect ( toMaterialSymbolName ( 'check' ) ) . toBe ( 'check' ) ;
26+ expect ( toMaterialSymbolName ( 'star' ) ) . toBe ( 'star' ) ;
27+ expect ( toMaterialSymbolName ( 'trending_up' ) ) . toBe ( 'trending_up' ) ;
28+ } ) ;
29+
30+ it ( 'leaves non-identifier glyphs (emoji) untouched' , ( ) => {
31+ expect ( toMaterialSymbolName ( '✓' ) ) . toBe ( '✓' ) ;
32+ expect ( toMaterialSymbolName ( '⚠️' ) ) . toBe ( '⚠️' ) ;
33+ } ) ;
34+ } ) ;
0 commit comments