package admin

import (
    "testing"
    "time"
)

func TestPercentChange(t *testing.T) {
    if s := percentChange(0, 10); s != "+0%" { t.Fatalf("prev0") }
    if s := percentChange(10, 15); s == "" { t.Fatalf("empty") }
}

func TestPreviousWindow(t *testing.T) {
    s := time.Date(2025, 1, 1, 0, 0, 0, 0, time.Local)
    e := s.Add(7*24*time.Hour).Add(-time.Second)
    ps, pe := previousWindow(s, e)
    if !pe.Before(s) { t.Fatalf("pe not before start") }
    if ps.After(pe) { t.Fatalf("ps after pe") }
}

func TestDaysBetween(t *testing.T) {
    s := time.Date(2025, 1, 1, 0, 0, 0, 0, time.Local)
    e := time.Date(2025, 1, 03, 23, 59, 59, 0, time.Local)
    ds := daysBetween(s, e)
    if len(ds) != 3 { t.Fatalf("expect3") }
}