glow/ui/pager_test.go
Drew Smirnoff 6b365eea95
feat: text sizing protocol for headers (#1029)
Signed-off-by: drew <me@andrinoff.com>
2026-09-22 15:13:40 +04:00

43 lines
1.1 KiB
Go

package ui
import (
"strings"
"testing"
)
func TestGlamourRenderTextSizing(t *testing.T) {
t.Setenv("GLOW_TEXT_SIZING", "on")
common := &commonModel{
cfg: Config{
GlamourEnabled: true,
GlamourStyle: "dark",
GlamourMaxWidth: 80,
},
styles: newStyles(true),
width: 80,
height: 24,
}
m := newPagerModel(common)
m.currentDocument = markdown{Note: "test.md"}
m.setSize(80, 24)
out, err := glamourRender(m, "# Hello\n\n## World\n")
if err != nil {
t.Fatal(err)
}
// The dark style's H1 has a background color, which renders broken when
// scaled, so it is left at normal size.
if strings.Contains(out, "\x1b]66;s=3;") {
t.Errorf("expected H1 with background to not be scaled, got %q", out)
}
if !strings.Contains(out, "Hello") {
t.Errorf("expected H1 text in pager output, got %q", out)
}
if !strings.Contains(out, "\x1b]66;s=2;World\x1b\\") {
t.Errorf("expected H2 at 2x scale in pager output, got %q", out)
}
if strings.Contains(out, "\x1b]6666;") {
t.Errorf("expected no leftover markers in pager output, got %q", out)
}
}