@@ -106,6 +106,18 @@ describe('computeFlagUsage', () => {
106106 const usage = computeFlagUsage ( args , mockOptions ) ;
107107 assert . equal ( usage . string_flag_present , false ) ;
108108 } ) ;
109+
110+ it ( 'sanitizes flag names containing underscores before numbers' , ( ) => {
111+ const mock3pOptions = {
112+ experimental3pTool : {
113+ type : 'boolean' as const ,
114+ description : 'A 3p flag' ,
115+ } ,
116+ } as unknown as typeof cliOptions ;
117+ const args = { experimental3pTool : true } ;
118+ const usage = computeFlagUsage ( args , mock3pOptions ) ;
119+ assert . equal ( usage . experimental3p_tool , true ) ;
120+ } ) ;
109121 } ) ;
110122} ) ;
111123
@@ -141,4 +153,19 @@ describe('getPossibleFlagMetrics', () => {
141153 } ,
142154 ] ) ;
143155 } ) ;
156+
157+ it ( 'sanitizes flag names containing underscores before numbers' , ( ) => {
158+ const mock3pOptions = {
159+ experimental3pTool : {
160+ type : 'boolean' as const ,
161+ description : 'A 3p flag' ,
162+ } ,
163+ } as unknown as typeof cliOptions ;
164+ const metrics = getPossibleFlagMetrics ( mock3pOptions ) ;
165+
166+ assert . deepEqual ( metrics , [
167+ { name : 'experimental3p_tool_present' , flagType : 'boolean' } ,
168+ { name : 'experimental3p_tool' , flagType : 'boolean' } ,
169+ ] ) ;
170+ } ) ;
144171} ) ;
0 commit comments