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
|
package grid
import (
"testing"
"ticktock/internal/store"
)
func TestPaintLoggedLabelAndContinuation(t *testing.T) {
g := BuildGrid(30, 7*60, 9*60, nil) // FirstMin 420, Rows 4 (07:00..09:00)
es := []store.Entry{{
Key: "2026-07-07-01", Start: at(7, 0), End: at(8, 30),
Project: "ARCHER", Description: "work", Duration: 90 * 60 * 1e9,
}}
cells := paintLogged(g, es)
if cells[0].Kind != CellLabel {
t.Fatalf("row0 kind=%v, want Label", cells[0].Kind)
}
if cells[0].Project != "ARCHER" || cells[1].Project != "ARCHER" {
t.Errorf("project not carried onto cells: %q / %q", cells[0].Project, cells[1].Project)
}
if cells[1].Kind != CellCont || cells[2].Kind != CellCont {
t.Errorf("rows1-2 should be continuation")
}
if cells[3].Kind != CellEmpty {
t.Errorf("row3 should be empty (session ends 08:30)")
}
if cells[0].Key != "2026-07-07-01" || cells[2].Key != "2026-07-07-01" {
t.Errorf("key not propagated to covered slots")
}
}
func TestEntryKeyAtRow(t *testing.T) {
g := BuildGrid(30, 7*60, 9*60, nil)
es := []store.Entry{{Key: "K", Start: at(7, 30), End: at(8, 0), Description: "x"}}
cells := paintLogged(g, es)
if k, ok := entryKeyAtRow(cells, 1); !ok || k != "K" {
t.Errorf("row1 → %q,%v want K,true", k, ok)
}
if _, ok := entryKeyAtRow(cells, 0); ok {
t.Errorf("row0 empty should be false")
}
}
func TestLabelForFormatsDurationAndTags(t *testing.T) {
e := store.Entry{Description: "emails", Tags: []string{"admin"}, Duration: 50 * 60 * 1e9}
got := labelFor(e)
if got != "✓ emails [admin] (0:50)" {
t.Errorf("labelFor=%q", got)
}
}
|