theme_test.go

 1package theme
 2
 3import (
 4	"testing"
 5)
 6
 7func TestThemeRegistration(t *testing.T) {
 8	// Get list of available themes
 9	availableThemes := AvailableThemes()
10	
11	// Check if "catppuccin" theme is registered
12	catppuccinFound := false
13	for _, themeName := range availableThemes {
14		if themeName == "catppuccin" {
15			catppuccinFound = true
16			break
17		}
18	}
19	
20	if !catppuccinFound {
21		t.Errorf("Catppuccin theme is not registered")
22	}
23	
24	// Check if "gruvbox" theme is registered
25	gruvboxFound := false
26	for _, themeName := range availableThemes {
27		if themeName == "gruvbox" {
28			gruvboxFound = true
29			break
30		}
31	}
32	
33	if !gruvboxFound {
34		t.Errorf("Gruvbox theme is not registered")
35	}
36	
37	// Check if "monokai" theme is registered
38	monokaiFound := false
39	for _, themeName := range availableThemes {
40		if themeName == "monokai" {
41			monokaiFound = true
42			break
43		}
44	}
45	
46	if !monokaiFound {
47		t.Errorf("Monokai theme is not registered")
48	}
49	
50	// Try to get the themes and make sure they're not nil
51	catppuccin := GetTheme("catppuccin")
52	if catppuccin == nil {
53		t.Errorf("Catppuccin theme is nil")
54	}
55	
56	gruvbox := GetTheme("gruvbox")
57	if gruvbox == nil {
58		t.Errorf("Gruvbox theme is nil")
59	}
60	
61	monokai := GetTheme("monokai")
62	if monokai == nil {
63		t.Errorf("Monokai theme is nil")
64	}
65	
66	// Test switching theme
67	originalTheme := CurrentThemeName()
68	
69	err := SetTheme("gruvbox")
70	if err != nil {
71		t.Errorf("Failed to set theme to gruvbox: %v", err)
72	}
73	
74	if CurrentThemeName() != "gruvbox" {
75		t.Errorf("Theme not properly switched to gruvbox")
76	}
77	
78	err = SetTheme("monokai")
79	if err != nil {
80		t.Errorf("Failed to set theme to monokai: %v", err)
81	}
82	
83	if CurrentThemeName() != "monokai" {
84		t.Errorf("Theme not properly switched to monokai")
85	}
86	
87	// Switch back to original theme
88	_ = SetTheme(originalTheme)
89}