34 lines
754 B
Go
34 lines
754 B
Go
package components
|
||
|
||
import (
|
||
"testing"
|
||
"time"
|
||
)
|
||
|
||
func TestRenderClock(t *testing.T) {
|
||
rows := RenderClock(time.Date(2026, 10, 15, 18, 28, 41, 0, time.UTC))
|
||
if len(rows) != 5 {
|
||
t.Fatalf("baris jam: %d, mau 5", len(rows))
|
||
}
|
||
w := len([]rune(rows[0]))
|
||
for i, r := range rows {
|
||
if len([]rune(r)) != w {
|
||
t.Fatalf("lebar baris %d tidak konsisten: %d vs %d", i, len([]rune(r)), w)
|
||
}
|
||
}
|
||
// "18:28:41" = 8 glyph × 3 + 7 spasi = 31
|
||
if w != 27 {
|
||
t.Fatalf("lebar jam: %d, mau 27", w)
|
||
}
|
||
if rows[0] == "" || rows[4] == "" {
|
||
t.Fatal("baris kosong")
|
||
}
|
||
}
|
||
|
||
func TestCenterBlock(t *testing.T) {
|
||
rows := CenterBlock([]string{"ab", "abcd"}, 8)
|
||
if rows[0] != " ab" || rows[1] != " abcd" {
|
||
t.Fatalf("center salah: %q %q", rows[0], rows[1])
|
||
}
|
||
}
|