init
Release Please / release-please (push) Failing after 4m2s
Web CI / web typecheck + build (push) Successful in 3m39s
CodeQL Analysis / Analyze (javascript-typescript) (push) Failing after 1h1m49s
CodeQL Analysis / Analyze (go) (push) Failing after 1h1m49s

This commit is contained in:
redlineo committed 2026-07-13 10:14:00 +03:00
commit d295c7f139
1527 files changed
+270726

No files matched your search

@@ -0,0 +1,34 @@
package screens
import (
"testing"
"time"
)
func TestFormatTimeAgo(t *testing.T) {
today := time.Now().Format("2006-01-02")
yesterday := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
threeDaysAgo := time.Now().AddDate(0, 0, -3).Format("2006-01-02")
// Day-granular dates never fabricate sub-day hours: same day is "today".
if got := formatTimeAgo(today); got != "today" {
t.Errorf("today should render as \"today\", got %q", got)
}
if got := formatTimeAgo(yesterday); got != "yesterday" {
t.Errorf("one day ago should render as \"yesterday\", got %q", got)
}
if got := formatTimeAgo(threeDaysAgo); got != "3d ago" {
t.Errorf("three days ago should render as \"3d ago\", got %q", got)
}
// Future dates clamp to "today" instead of going negative.
tomorrow := time.Now().AddDate(0, 0, 1).Format("2006-01-02")
if got := formatTimeAgo(tomorrow); got != "today" {
t.Errorf("future date should clamp to \"today\", got %q", got)
}
// Non-dates pass through untouched.
if got := formatTimeAgo("—"); got != "—" {
t.Errorf("non-date should pass through, got %q", got)
}
}