Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package server
|
||
|
||
import (
|
||
"testing"
|
||
"time"
|
||
)
|
||
|
||
func TestSlugFromCompany(t *testing.T) {
|
||
for in, want := range map[string]string{
|
||
"Müller Maschinenbau GmbH": "mueller-maschinenbau",
|
||
"Müller Maschinenbau GmbH & Co. KG": "mueller-maschinenbau",
|
||
"Straßenbau Süd AG": "strassenbau-sued",
|
||
"Élan Systèmes SARL": "elan-systemes",
|
||
"ACME": "acme",
|
||
"X GmbH": "x-firma",
|
||
"GmbH": "gmbh",
|
||
"Die sehr lange Firmenbezeichnung für Maschinen und Anlagenbau GmbH": "die-sehr-lange-firmenbezeichnung-fuer",
|
||
"123 Industries Ltd.": "123-industries",
|
||
} {
|
||
if got := slugFromCompany(in); got != want {
|
||
t.Errorf("%q → %q, want %q", in, got, want)
|
||
}
|
||
if got := slugFromCompany(in); len(got) > 40 || !slugRE.MatchString(got) {
|
||
t.Errorf("%q → %q is not a valid slug", in, got)
|
||
}
|
||
}
|
||
}
|
||
|
||
func TestTrialEndIsFourteenCalendarDaysInBerlin(t *testing.T) {
|
||
// across the switch to winter time (25.10.2026): 14 calendar days, same
|
||
// clock time in Berlin, so 14×24h + 1h
|
||
start := time.Date(2026, 10, 20, 8, 30, 0, 0, time.UTC) // 10:30 CEST
|
||
end := trialEnd(start)
|
||
if got := end.In(erpZone).Format("02.01.2006 15:04"); got != "03.11.2026 10:30" {
|
||
t.Fatalf("end %s", got)
|
||
}
|
||
if d := end.Sub(start); d != 14*24*time.Hour+time.Hour {
|
||
t.Fatalf("duration %v", d)
|
||
}
|
||
}
|
||
|
||
func TestGermanDate(t *testing.T) {
|
||
if got := germanDate("2026-10-01"); got != "1. Oktober 2026" {
|
||
t.Fatal(got)
|
||
}
|
||
if got := germanDate("bad"); got != "bad" {
|
||
t.Fatal(got)
|
||
}
|
||
}
|