Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion packages/compass-preferences-model/src/global-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ forceConnectionOptions:
globalConfigPaths: [],
argv: ['--enable-maps=true', '--theme'],
});
expect(result.cli).to.deep.equal({ enableMaps: true });
expect(result.cli).to.deep.equal({ enableMaps: true, theme: 'LIGHT' });
});

it('knows the expected types of cli options when followed by an extra positional argument', async function () {
Expand Down Expand Up @@ -226,4 +226,28 @@ forceConnectionOptions:
'See the MongoDB Compass documentation for more details.'
);
});

it('allows empty theme option and defaults to LIGHT', async function () {
const result = await parseAndValidateGlobalPreferences({
globalConfigPaths: [],
argv: ['--theme='],
});
expect(result.cli).to.deep.equal({ theme: 'LIGHT' });
});

it('allows lowercase theme value', async function () {
const result = await parseAndValidateGlobalPreferences({
globalConfigPaths: [],
argv: ['--theme=dark'],
});
expect(result.cli).to.deep.equal({ theme: 'DARK' });
});

it('allows empty optional string value', async function () {
const result = await parseAndValidateGlobalPreferences({
globalConfigPaths: [],
argv: ['--username', '--password'],
});
expect(result.cli).to.deep.equal({ username: '', password: '' });
});
});
8 changes: 5 additions & 3 deletions packages/compass-preferences-model/src/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ const storedUserPreferencesProps: Required<{
},
validator: Joi.string<THEMES>()
.valid(...THEMES_VALUES)
.uppercase() // allow lowercase and convert it to uppercase
.empty('') // allow empty string and its defaulted to LIGHT
.default('LIGHT'),
},
/**
Expand Down Expand Up @@ -639,7 +641,7 @@ const nonUserPreferences: Required<{
description: {
short: 'Specify a List of Connections for Automatically Connecting',
},
validator: Joi.string().optional(),
validator: Joi.string().optional().allow(''),
},
username: {
ui: false,
Expand All @@ -648,7 +650,7 @@ const nonUserPreferences: Required<{
description: {
short: 'Specify a Username for Automatically Connecting',
},
validator: Joi.string().optional(),
validator: Joi.string().optional().allow(''),
},
password: {
ui: false,
Expand All @@ -657,7 +659,7 @@ const nonUserPreferences: Required<{
description: {
short: 'Specify a Password for Automatically Connecting',
},
validator: Joi.string().optional(),
validator: Joi.string().optional().allow(''),
},
};

Expand Down