package menu import ( "strings" "testing" ) func joined(a []string) string { return strings.Join(a, " ") } func TestStartArgs(t *testing.T) { got := startArgs("ARCHER", "Admin", []string{"emails", "sorted"}, "inbox zero") want := "start -p ARCHER -d Admin --note inbox zero --tag emails --tag sorted" if joined(got) != want { t.Fatalf("got %q want %q", joined(got), want) } if joined(startArgs("ARCHER", "", nil, "")) != "start -p ARCHER" { t.Errorf("minimal start wrong: %q", joined(startArgs("ARCHER", "", nil, ""))) } } func TestStopArgs(t *testing.T) { if joined(stopArgs("")) != "stop" { t.Errorf("stop no-note wrong") } if joined(stopArgs("done")) != "stop --note done" { t.Errorf("stop note wrong: %q", joined(stopArgs("done"))) } } func TestNoteAndTagArgs(t *testing.T) { if joined(noteArgs("hello world")) != "note hello world" { t.Errorf("note wrong") } if joined(tagArgs([]string{"review", "urgent"})) != "tag review urgent" { t.Errorf("tag wrong: %q", joined(tagArgs([]string{"review", "urgent"}))) } } func TestContinueArgs(t *testing.T) { if joined(continueArgs("")) != "continue" { t.Errorf("continue no-num wrong") } if joined(continueArgs("3")) != "continue 3" { t.Errorf("continue num wrong") } } func TestReportArgs(t *testing.T) { cases := map[string]string{ "today": "report --today", "yesterday": "report --yesterday", "all": "report", } for period, want := range cases { if joined(reportArgs(period, "")) != want { t.Errorf("report %s = %q, want %q", period, joined(reportArgs(period, "")), want) } } if joined(reportArgs("date", "2026-07-07")) != "report --date 2026-07-07" { t.Errorf("report date wrong") } } func TestSplitTags(t *testing.T) { got := splitTags(" a , ,b ,c") if strings.Join(got, "|") != "a|b|c" { t.Errorf("splitTags = %v", got) } if splitTags(" ") != nil { t.Errorf("blank should be nil") } }