Something went wrong. Try again.
Ghostty for the web with xterm.js API compatibility
Something went wrong. Try again.
2.3 kB · 62 lines
TypeScript
at renderstate
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263/** * Tests for Canvas Renderer * * Note: Most renderer tests are visual and require a browser environment. * These tests verify non-visual aspects like theme configuration. * Full visual tests are in examples/renderer-demo.html */
import { describe, expect, test } from 'bun:test';import { DEFAULT_THEME } from './renderer';
describe('CanvasRenderer', () => { describe('Default Theme', () => { test('has all required ANSI colors', () => { expect(DEFAULT_THEME.black).toBe('#000000'); expect(DEFAULT_THEME.red).toBe('#cd3131'); expect(DEFAULT_THEME.green).toBe('#0dbc79'); expect(DEFAULT_THEME.yellow).toBe('#e5e510'); expect(DEFAULT_THEME.blue).toBe('#2472c8'); expect(DEFAULT_THEME.magenta).toBe('#bc3fbc'); expect(DEFAULT_THEME.cyan).toBe('#11a8cd'); expect(DEFAULT_THEME.white).toBe('#e5e5e5'); });
test('has all bright ANSI colors', () => { expect(DEFAULT_THEME.brightBlack).toBe('#666666'); expect(DEFAULT_THEME.brightRed).toBe('#f14c4c'); expect(DEFAULT_THEME.brightGreen).toBe('#23d18b'); expect(DEFAULT_THEME.brightYellow).toBe('#f5f543'); expect(DEFAULT_THEME.brightBlue).toBe('#3b8eea'); expect(DEFAULT_THEME.brightMagenta).toBe('#d670d6'); expect(DEFAULT_THEME.brightCyan).toBe('#29b8db'); expect(DEFAULT_THEME.brightWhite).toBe('#ffffff'); });
test('has foreground and background colors', () => { expect(DEFAULT_THEME.foreground).toBe('#d4d4d4'); expect(DEFAULT_THEME.background).toBe('#1e1e1e'); });
test('has cursor colors', () => { expect(DEFAULT_THEME.cursor).toBe('#ffffff'); expect(DEFAULT_THEME.cursorAccent).toBe('#1e1e1e'); });
test('has selection colors', () => { expect(DEFAULT_THEME.selectionBackground).toBe('rgba(255, 255, 255, 0.3)'); expect(DEFAULT_THEME.selectionForeground).toBe('#d4d4d4'); }); });
describe('Theme Color Format', () => { test('all colors are valid hex strings', () => { const hexPattern = /^#[0-9a-f]{6}$/i;
expect(DEFAULT_THEME.black).toMatch(hexPattern); expect(DEFAULT_THEME.foreground).toMatch(hexPattern); expect(DEFAULT_THEME.background).toMatch(hexPattern); expect(DEFAULT_THEME.cursor).toMatch(hexPattern); }); });});