@@ -1134,10 +1134,45 @@ describe('arg-parser', function () {
11341134 } ) ;
11351135
11361136 describe ( 'union type fields' , function ( ) {
1137- for ( const { argument, values, onlyFalse, strict } of [
1137+ describe ( '--browser' , function ( ) {
1138+ it ( 'does not coerce to boolean with --browser=true' , function ( ) {
1139+ expect (
1140+ parseArgsWithCliOptions ( { args : [ '--browser=true' ] } ) . parsed . browser
1141+ ) . to . equal ( 'true' ) ;
1142+ } ) ;
1143+
1144+ it ( 'coerces to boolean with --browser=false' , function ( ) {
1145+ expect (
1146+ parseArgsWithCliOptions ( { args : [ '--browser=false' ] } ) . parsed . browser
1147+ ) . to . equal ( false ) ;
1148+ } ) ;
1149+
1150+ it ( 'coerces to false with --no-browser' , function ( ) {
1151+ expect (
1152+ parseArgsWithCliOptions ( { args : [ '--no-browser' ] } ) . parsed . browser
1153+ ) . to . equal ( false ) ;
1154+ } ) ;
1155+
1156+ it ( 'uses string if browser=something' , function ( ) {
1157+ expect (
1158+ parseArgsWithCliOptions ( { args : [ '--browser=something' ] } ) . parsed
1159+ . browser
1160+ ) . to . equal ( 'something' ) ;
1161+ } ) ;
1162+
1163+ it ( 'throws if just --browser is provided' , function ( ) {
1164+ expect (
1165+ ( ) => parseArgsWithCliOptions ( { args : [ '--browser' ] } ) . parsed . browser
1166+ ) . to . throw (
1167+ MongoshUnimplementedError ,
1168+ '--browser can only be true or a string'
1169+ ) ;
1170+ } ) ;
1171+ } ) ;
1172+
1173+ for ( const { argument, values } of [
11381174 { argument : 'json' , values : [ 'relaxed' , 'canonical' ] } ,
11391175 { argument : 'oidcDumpTokens' , values : [ 'redacted' , 'include-secrets' ] } ,
1140- { argument : 'browser' , values : [ 'test' ] , onlyFalse : true , strict : false } ,
11411176 ] as const ) {
11421177 describe ( `with ${ argument } ` , function ( ) {
11431178 context ( 'with boolean' , function ( ) {
@@ -1149,23 +1184,13 @@ describe('arg-parser', function () {
11491184 ) . to . equal ( true ) ;
11501185 } ) ;
11511186
1152- if ( ! onlyFalse ) {
1153- it ( `coerces to true with --${ argument } =true` , function ( ) {
1154- expect (
1155- parseArgsWithCliOptions ( {
1156- args : [ `--${ argument } =true` ] ,
1157- } ) . parsed [ argument ]
1158- ) . to . equal ( true ) ;
1159- } ) ;
1160- } else {
1161- it ( `does not coerce with "--${ argument } true"` , function ( ) {
1162- expect (
1163- parseArgsWithCliOptions ( {
1164- args : [ `--${ argument } =true` ] ,
1165- } ) . parsed [ argument ]
1166- ) . to . be . equal ( 'true' ) ;
1167- } ) ;
1168- }
1187+ it ( `coerces to true with --${ argument } =true` , function ( ) {
1188+ expect (
1189+ parseArgsWithCliOptions ( {
1190+ args : [ `--${ argument } =true` ] ,
1191+ } ) . parsed [ argument ]
1192+ ) . to . equal ( true ) ;
1193+ } ) ;
11691194
11701195 it ( `coerces to false with --${ argument } =false` , function ( ) {
11711196 expect (
@@ -1197,22 +1222,16 @@ describe('arg-parser', function () {
11971222 } ) ;
11981223 }
11991224
1200- if ( strict ) {
1201- it ( 'throws an error with invalid value' , function ( ) {
1202- try {
1203- parseArgsWithCliOptions ( {
1204- args : [ `--${ argument } ` , 'invalid' ] ,
1205- } ) ;
1206- } catch ( e : any ) {
1207- expect ( e ) . to . be . instanceOf ( MongoshUnimplementedError ) ;
1208- expect ( e . message ) . to . include (
1209- `--${ argument } can only have the values ${ values . join ( ', ' ) } `
1210- ) ;
1211- return ;
1212- }
1213- expect . fail ( 'Expected error' ) ;
1214- } ) ;
1215- }
1225+ it ( 'throws an error with invalid value' , function ( ) {
1226+ expect ( ( ) =>
1227+ parseArgsWithCliOptions ( {
1228+ args : [ `--${ argument } ` , 'invalid' ] ,
1229+ } )
1230+ ) . to . throw (
1231+ MongoshUnimplementedError ,
1232+ `--${ argument } can only have the values ${ values . join ( ', ' ) } `
1233+ ) ;
1234+ } ) ;
12161235 } ) ;
12171236 }
12181237 } ) ;
@@ -1246,7 +1265,7 @@ describe('arg-parser', function () {
12461265 } ) ;
12471266 } ) ;
12481267
1249- it ( 'generates the expected options for Cli Options ' , function ( ) {
1268+ it ( 'generates the expected options for CliOptions ' , function ( ) {
12501269 const options = generateYargsOptionsFromSchema ( {
12511270 schema : CliOptionsSchema ,
12521271 } ) ;
@@ -1260,6 +1279,7 @@ describe('arg-parser', function () {
12601279 'awsIamSessionToken' ,
12611280 'awsSecretAccessKey' ,
12621281 'awsSessionToken' ,
1282+ 'browser' ,
12631283 'csfleLibraryPath' ,
12641284 'cryptSharedLibPath' ,
12651285 'db' ,
@@ -1294,6 +1314,7 @@ describe('arg-parser', function () {
12941314 'apiDeprecationErrors' ,
12951315 'apiStrict' ,
12961316 'buildInfo' ,
1317+ 'deepInspect' ,
12971318 'exposeAsyncRewriter' ,
12981319 'help' ,
12991320 'ipv6' ,
0 commit comments