test(cli): humanize_age bucket boundaries + plural transitions
Locks the singular vs plural transition (1 minute ago vs 2 minutes ago) and each bucket boundary (59→60s minutes, 3599→3600s hours, 86400→86400×2 days, etc.) so future tweaks can't silently regress the user-facing labels.
This commit is contained in:
@@ -118,4 +118,21 @@ mod tests {
|
||||
// 2026-04-19T00:00:00Z = 1776556800
|
||||
assert_eq!(iso8601(1_776_556_800), "2026-04-19T00:00:00Z");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn humanize_age_buckets() {
|
||||
assert_eq!(humanize_age(0), "just now");
|
||||
assert_eq!(humanize_age(59), "just now");
|
||||
assert_eq!(humanize_age(60), "1 minute ago");
|
||||
assert_eq!(humanize_age(120), "2 minutes ago");
|
||||
assert_eq!(humanize_age(3_599), "59 minutes ago");
|
||||
assert_eq!(humanize_age(3_600), "1 hour ago");
|
||||
assert_eq!(humanize_age(7_200), "2 hours ago");
|
||||
assert_eq!(humanize_age(86_400), "1 day ago");
|
||||
assert_eq!(humanize_age(86_400 * 2), "2 days ago");
|
||||
assert_eq!(humanize_age(86_400 * 30), "1 month ago");
|
||||
assert_eq!(humanize_age(86_400 * 60), "2 months ago");
|
||||
assert_eq!(humanize_age(86_400 * 365), "1 year ago");
|
||||
assert_eq!(humanize_age(86_400 * 365 * 3), "3 years ago");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user