File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed
packages/compass-preferences-model/src Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ forceConnectionOptions:
130
130
globalConfigPaths : [ ] ,
131
131
argv : [ '--enable-maps=true' , '--theme' ] ,
132
132
} ) ;
133
- expect ( result . cli ) . to . deep . equal ( { enableMaps : true } ) ;
133
+ expect ( result . cli ) . to . deep . equal ( { enableMaps : true , theme : 'LIGHT' } ) ;
134
134
} ) ;
135
135
136
136
it ( 'knows the expected types of cli options when followed by an extra positional argument' , async function ( ) {
@@ -226,4 +226,28 @@ forceConnectionOptions:
226
226
'See the MongoDB Compass documentation for more details.'
227
227
) ;
228
228
} ) ;
229
+
230
+ it ( 'allows empty theme option and defaults to LIGHT' , async function ( ) {
231
+ const result = await parseAndValidateGlobalPreferences ( {
232
+ globalConfigPaths : [ ] ,
233
+ argv : [ '--theme=' ] ,
234
+ } ) ;
235
+ expect ( result . cli ) . to . deep . equal ( { theme : 'LIGHT' } ) ;
236
+ } ) ;
237
+
238
+ it ( 'allows lowercase theme value' , async function ( ) {
239
+ const result = await parseAndValidateGlobalPreferences ( {
240
+ globalConfigPaths : [ ] ,
241
+ argv : [ '--theme=dark' ] ,
242
+ } ) ;
243
+ expect ( result . cli ) . to . deep . equal ( { theme : 'DARK' } ) ;
244
+ } ) ;
245
+
246
+ it ( 'allows empty optional string value' , async function ( ) {
247
+ const result = await parseAndValidateGlobalPreferences ( {
248
+ globalConfigPaths : [ ] ,
249
+ argv : [ '--username' , '--password' ] ,
250
+ } ) ;
251
+ expect ( result . cli ) . to . deep . equal ( { username : '' , password : '' } ) ;
252
+ } ) ;
229
253
} ) ;
Original file line number Diff line number Diff line change @@ -285,6 +285,8 @@ const storedUserPreferencesProps: Required<{
285
285
} ,
286
286
validator : Joi . string < THEMES > ( )
287
287
. valid ( ...THEMES_VALUES )
288
+ . uppercase ( ) // allow lowercase and convert it to uppercase
289
+ . empty ( '' ) // allow empty string and its defaulted to LIGHT
288
290
. default ( 'LIGHT' ) ,
289
291
} ,
290
292
/**
@@ -639,7 +641,7 @@ const nonUserPreferences: Required<{
639
641
description : {
640
642
short : 'Specify a List of Connections for Automatically Connecting' ,
641
643
} ,
642
- validator : Joi . string ( ) . optional ( ) ,
644
+ validator : Joi . string ( ) . optional ( ) . allow ( '' ) ,
643
645
} ,
644
646
username : {
645
647
ui : false ,
@@ -648,7 +650,7 @@ const nonUserPreferences: Required<{
648
650
description : {
649
651
short : 'Specify a Username for Automatically Connecting' ,
650
652
} ,
651
- validator : Joi . string ( ) . optional ( ) ,
653
+ validator : Joi . string ( ) . optional ( ) . allow ( '' ) ,
652
654
} ,
653
655
password : {
654
656
ui : false ,
@@ -657,7 +659,7 @@ const nonUserPreferences: Required<{
657
659
description : {
658
660
short : 'Specify a Password for Automatically Connecting' ,
659
661
} ,
660
- validator : Joi . string ( ) . optional ( ) ,
662
+ validator : Joi . string ( ) . optional ( ) . allow ( '' ) ,
661
663
} ,
662
664
} ;
663
665
You can’t perform that action at this time.
0 commit comments