theme_test.go 1.7 KB

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