glow/ui/ui_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

24 lines
592 B
Go

package ui
import (
"os"
"path/filepath"
"strings"
"testing"
)
func TestNewModelLoadsDocumentBody(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "test.md")
if err := os.WriteFile(path, []byte("# Hello\n\nSome text here.\n"), 0o644); err != nil {
t.Fatal(err)
}
m := newModel(Config{Path: path}, "").(model)
if m.state != stateShowDocument {
t.Fatalf("expected stateShowDocument, got %s", m.state)
}
if !strings.Contains(m.pager.currentDocument.Body, "Some text") {
t.Errorf("expected document body to be loaded, got %q", m.pager.currentDocument.Body)
}
}