package form import ( "testing" "ticktock/internal/store" ) func TestSplitTagsTrimsAndDropsEmpty(t *testing.T) { got := SplitTags(" a , ,b,c ") want := []string{"a", "b", "c"} if len(got) != len(want) { t.Fatalf("got %v want %v", got, want) } for i := range want { if got[i] != want[i] { t.Fatalf("got %v want %v", got, want) } } } func TestBuildEntryParsesTimesAndTags(t *testing.T) { e, err := BuildEntry("2026-07-07", store.Entry{}, Values{ Start: "08:00", End: "09:30", Project: "ARCHER", Desc: "work", Tags: "a, b", Note: "n", }) if err != nil { t.Fatal(err) } if e.Start.Hour() != 8 || e.End.Hour() != 9 || e.End.Minute() != 30 { t.Errorf("times wrong: %v..%v", e.Start, e.End) } if e.Project != "ARCHER" || e.Description != "work" || e.Notes != "n" { t.Errorf("fields wrong: %+v", e) } if len(e.Tags) != 2 || e.Tags[0] != "a" || e.Tags[1] != "b" { t.Errorf("tags wrong: %v", e.Tags) } } func TestBuildEntryRejectsBadTime(t *testing.T) { if _, err := BuildEntry("2026-07-07", store.Entry{}, Values{Start: "8am", End: "09:00"}); err == nil { t.Fatal("expected error on bad start time") } } func TestAddFormPrefillsStartEndProject(t *testing.T) { var v Values _ = AddForm("10:00", "10:30", "ARCHER", &v, Suggest{}) if v.Start != "10:00" || v.End != "10:30" || v.Project != "ARCHER" { t.Errorf("add-form prefill wrong: %+v", v) } if v.Desc != "" || v.Tags != "" || v.Note != "" { t.Errorf("add-form should leave desc/tags/note empty: %+v", v) } }