feat(cli): support independent light and dark mode themes

This commit is contained in:
Dan Zaharia
2026-02-26 16:50:26 -05:00
parent 717660997d
commit 98a0a2f0ef
25 changed files with 548 additions and 330 deletions

View File

@@ -23,30 +23,46 @@ describe('theme', () => {
mockSettings = {
merged: {
ui: {
theme: 'test-theme',
themeLight: 'test-light-theme',
themeDark: 'test-dark-theme',
},
},
} as unknown as LoadedSettings;
});
it('should return null if theme is found', () => {
it('should return null if themes are found', () => {
vi.mocked(themeManager.findThemeByName).mockReturnValue(
{} as unknown as ReturnType<typeof themeManager.findThemeByName>,
);
const result = validateTheme(mockSettings);
expect(result).toBeNull();
expect(themeManager.findThemeByName).toHaveBeenCalledWith('test-theme');
expect(themeManager.findThemeByName).toHaveBeenCalledWith(
'test-light-theme',
);
expect(themeManager.findThemeByName).toHaveBeenCalledWith(
'test-dark-theme',
);
});
it('should return error message if theme is not found', () => {
vi.mocked(themeManager.findThemeByName).mockReturnValue(undefined);
it('should return error message if light theme is not found', () => {
vi.mocked(themeManager.findThemeByName).mockImplementation((name) => name === 'test-dark-theme'
? ({} as unknown as ReturnType<typeof themeManager.findThemeByName>)
: undefined);
const result = validateTheme(mockSettings);
expect(result).toBe('Theme "test-theme" not found.');
expect(themeManager.findThemeByName).toHaveBeenCalledWith('test-theme');
expect(result).toBe('Theme "test-light-theme" not found.');
});
it('should return null if theme is undefined', () => {
mockSettings.merged.ui.theme = undefined;
it('should return error message if dark theme is not found', () => {
vi.mocked(themeManager.findThemeByName).mockImplementation((name) => name === 'test-light-theme'
? ({} as unknown as ReturnType<typeof themeManager.findThemeByName>)
: undefined);
const result = validateTheme(mockSettings);
expect(result).toBe('Theme "test-dark-theme" not found.');
});
it('should return null if themes are undefined', () => {
mockSettings.merged.ui.themeLight = undefined;
mockSettings.merged.ui.themeDark = undefined;
const result = validateTheme(mockSettings);
expect(result).toBeNull();
expect(themeManager.findThemeByName).not.toHaveBeenCalled();