24 lines
657 B
Go
24 lines
657 B
Go
package web
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestLocaleURLPreservesExplorerQuery(t *testing.T) {
|
|
request := httptest.NewRequest("GET", "/accounts?class=USER_AVAILABLE&asset_id=9", nil)
|
|
value := localeURL(request, LocalePersian)
|
|
for _, expected := range []string{"/accounts?", "class=USER_AVAILABLE", "asset_id=9", "lang=fa"} {
|
|
if !strings.Contains(value, expected) {
|
|
t.Fatalf("locale URL %q did not preserve %q", value, expected)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestTranslationFallsBackToEnglish(t *testing.T) {
|
|
if got := tr(Locale("invalid"), "overview"); got != "Overview" {
|
|
t.Fatalf("unexpected fallback translation: %q", got)
|
|
}
|
|
}
|