▍ humdrum codex / ticktock v0.0.2
license AGPL-3.0
1.9 KB raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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")
	}
}