Add DarkGray to the ColorTheme. (#12420)

This commit is contained in:
Jacob Richman
2025-11-01 16:50:51 -07:00
committed by GitHub
parent e3262f8766
commit d7243fb81f
20 changed files with 147 additions and 4 deletions

View File

@@ -8,9 +8,80 @@ import { describe, it, expect } from 'vitest';
import * as themeModule from './theme.js';
import { themeManager } from './theme-manager.js';
const { validateCustomTheme } = themeModule;
const { validateCustomTheme, createCustomTheme } = themeModule;
type CustomTheme = themeModule.CustomTheme;
describe('createCustomTheme', () => {
const baseTheme: CustomTheme = {
type: 'custom',
name: 'Test Theme',
Background: '#000000',
Foreground: '#ffffff',
LightBlue: '#ADD8E6',
AccentBlue: '#0000FF',
AccentPurple: '#800080',
AccentCyan: '#00FFFF',
AccentGreen: '#008000',
AccentYellow: '#FFFF00',
AccentRed: '#FF0000',
DiffAdded: '#00FF00',
DiffRemoved: '#FF0000',
Comment: '#808080',
Gray: '#cccccc',
// DarkGray intentionally omitted to test fallback
};
it('should interpolate DarkGray when not provided', () => {
const theme = createCustomTheme(baseTheme);
// Interpolate between Gray (#cccccc) and Background (#000000) at 0.5
// #cccccc is RGB(204, 204, 204)
// #000000 is RGB(0, 0, 0)
// Midpoint is RGB(102, 102, 102) which is #666666
expect(theme.colors.DarkGray).toBe('#666666');
});
it('should use provided DarkGray', () => {
const theme = createCustomTheme({
...baseTheme,
DarkGray: '#123456',
});
expect(theme.colors.DarkGray).toBe('#123456');
});
it('should interpolate DarkGray when text.secondary is provided but DarkGray is not', () => {
const customTheme: CustomTheme = {
type: 'custom',
name: 'Test',
text: {
secondary: '#cccccc', // Gray source
},
background: {
primary: '#000000', // Background source
},
};
const theme = createCustomTheme(customTheme);
// Should be interpolated between #cccccc and #000000 at 0.5 -> #666666
expect(theme.colors.DarkGray).toBe('#666666');
});
it('should prefer text.secondary over Gray for interpolation', () => {
const customTheme: CustomTheme = {
type: 'custom',
name: 'Test',
text: {
secondary: '#cccccc', // Should be used
},
Gray: '#aaaaaa', // Should be ignored
background: {
primary: '#000000',
},
};
const theme = createCustomTheme(customTheme);
// Interpolate between #cccccc and #000000 -> #666666
expect(theme.colors.DarkGray).toBe('#666666');
});
});
describe('validateCustomTheme', () => {
const validTheme: CustomTheme = {
type: 'custom',