package ui_test import ( "testing" "github.com/juanatsap/cv-site/internal/models/ui" ) func TestLoadUI(t *testing.T) { tests := []struct { name string lang string wantErr bool }{ { name: "English UI", lang: "en", wantErr: false, }, { name: "Spanish UI", lang: "es", wantErr: false, }, { name: "Invalid language", lang: "fr", wantErr: true, }, { name: "Empty language", lang: "", wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { uiData, err := ui.LoadUI(tt.lang) if (err != nil) != tt.wantErr { t.Errorf("LoadUI() error = %v, wantErr %v", err, tt.wantErr) return } if !tt.wantErr { if uiData == nil { t.Error("LoadUI() returned nil UI data") return } // Validate UI has essential data if uiData.InfoModal.Title == "" { t.Error("LoadUI() returned UI with empty InfoModal title") } if uiData.ShortcutsModal.Title == "" { t.Error("LoadUI() returned UI with empty ShortcutsModal title") } // Validate TechStack is populated if uiData.InfoModal.TechStack.GoHono == "" { t.Error("LoadUI() returned UI with empty TechStack.GoHono") } } }) } } func TestLoadUI_ModalData(t *testing.T) { uiData, err := ui.LoadUI("en") if err != nil { t.Fatalf("LoadUI() failed: %v", err) } // Test InfoModal structure if uiData.InfoModal.Description == "" { t.Error("InfoModal.Description should not be empty") } if uiData.InfoModal.ViewSource == "" { t.Error("InfoModal.ViewSource should not be empty") } // Test ShortcutsModal structure if uiData.ShortcutsModal.Description == "" { t.Error("ShortcutsModal.Description should not be empty") } // Test that shortcuts sections exist if uiData.ShortcutsModal.Sections.Zoom.Title == "" { t.Error("Zoom shortcuts section should have a title") } if uiData.ShortcutsModal.Sections.Actions.Title == "" { t.Error("Actions shortcuts section should have a title") } }