package router import ( "testing" "time" ) func TestCalendarEventFormatter(t *testing.T) { f := CalendarEventFormatter{} date := time.Date(2026, 7, 6, 0, 0, 0, 0, time.UTC) // Empty if got := f.Format(nil, date); got != "на 06.07.2026 ничего нет." { t.Errorf("empty: got %q", got) } // One event if got := f.Format([]string{"Standup @ 10:00-10:30"}, date); got != "на 06.07.2026: Standup @ 10:00-10:30" { t.Errorf("one: got %q", got) } // Multiple events if got := f.Format([]string{"Standup @ 10:00-10:30", "Lunch @ 12:00-13:00"}, date); got != "на 06.07.2026: Standup @ 10:00-10:30; Lunch @ 12:00-13:00" { t.Errorf("multiple: got %q", got) } } func TestCalendarEventFormatterHedgesUncertainEntries(t *testing.T) { f := CalendarEventFormatter{} date := time.Date(2026, 7, 6, 0, 0, 0, 0, time.UTC) // An event relayed off a phone notification is not a calendar read, and she // says so instead of reciting a guess as fact. got := f.FormatEntries([]CalendarEntry{ {Text: "Standup @ 10:00-10:30"}, {Text: "Планёрка @ 14:00-14:30", Uncertain: true}, }, date) want := "на 06.07.2026: Standup @ 10:00-10:30; похоже, Планёрка @ 14:00-14:30" if got != want { t.Errorf("got %q\nwant %q", got, want) } // Format is FormatEntries with everything certain. if got := f.FormatEntries(nil, date); got != "на 06.07.2026 ничего нет." { t.Errorf("empty: got %q", got) } } func TestIsDayPlanQuery(t *testing.T) { yes := []string{ "какие планы на сегодня?", "что у меня по плану", "расскажи план", "мой распорядок на сегодня", "расписание?", "что дальше?", "what's next", "what is my plan today", } for _, s := range yes { if !IsDayPlanQuery(s) { t.Errorf("IsDayPlanQuery(%q) = false, want true", s) } } no := []string{ // The calendar listing owns these. "что у меня сегодня?", "какие планы на завтра?", "план на послезавтра", "что было вчера", // "планёрка" is a meeting, not a request for the plan. "когда планёрка?", "запиши планёрку на 14:00", "какая погода?", "", } for _, s := range no { if IsDayPlanQuery(s) { t.Errorf("IsDayPlanQuery(%q) = true, want false", s) } } }