1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 20:15:07 +00:00

test(status): add narrow-width rendering coverage

This commit is contained in:
tw93
2026-02-27 09:53:24 +08:00
parent 369d3b8840
commit 8436377922

View File

@@ -3,6 +3,8 @@ package main
import ( import (
"strings" "strings"
"testing" "testing"
"github.com/charmbracelet/lipgloss"
) )
func TestFormatRate(t *testing.T) { func TestFormatRate(t *testing.T) {
@@ -934,6 +936,46 @@ func TestRenderHeaderErrorReturnsMoleOnce(t *testing.T) {
} }
} }
func TestRenderHeaderWrapsOnNarrowWidth(t *testing.T) {
m := MetricsSnapshot{
HealthScore: 91,
Hardware: HardwareInfo{
Model: "MacBook Pro",
CPUModel: "Apple M3 Max",
TotalRAM: "128GB",
DiskSize: "4TB",
RefreshRate: "120Hz",
OSVersion: "macOS 15.0",
},
Uptime: "10d 3h",
}
header, _ := renderHeader(m, "", 0, 38, true)
for _, line := range strings.Split(header, "\n") {
if lipgloss.Width(stripANSI(line)) > 38 {
t.Fatalf("renderHeader() line exceeds width: %q", line)
}
}
}
func TestRenderCardWrapsOnNarrowWidth(t *testing.T) {
card := cardData{
icon: iconCPU,
title: "CPU",
lines: []string{
"Total ████████████████ 100.0% @ 85.0°C",
"Load 12.34 / 8.90 / 7.65, 4P+4E",
},
}
rendered := renderCard(card, 26, 0)
for _, line := range strings.Split(rendered, "\n") {
if lipgloss.Width(stripANSI(line)) > 26 {
t.Fatalf("renderCard() line exceeds width: %q", line)
}
}
}
func TestModelViewErrorRendersSingleMole(t *testing.T) { func TestModelViewErrorRendersSingleMole(t *testing.T) {
m := model{ m := model{
width: 120, width: 120,