Files
patterm/internal/app/layout_test.go

59 lines
1.6 KiB
Go

package app
import (
"testing"
"github.com/hjbdev/patterm/internal/preset"
)
func TestTerminalLayoutWideUsesMainViewport(t *testing.T) {
l := newTerminalLayout(120, 40)
if !l.sidebarVisible {
t.Fatal("wide layout should show sidebar")
}
if l.childCols() != 91 {
t.Fatalf("child cols: got %d want 91", l.childCols())
}
if l.childRows() != 36 {
t.Fatalf("child rows: got %d want 36", l.childRows())
}
if l.mainTop != 4 || l.statusRow != 40 {
t.Fatalf("unexpected vertical chrome: mainTop=%d statusRow=%d", l.mainTop, l.statusRow)
}
}
func TestTerminalLayoutNarrowHidesSidebar(t *testing.T) {
l := newTerminalLayout(38, 12)
if l.sidebarVisible {
t.Fatal("narrow layout should hide sidebar")
}
if l.childCols() != 38 {
t.Fatalf("child cols: got %d want 38", l.childCols())
}
if l.childRows() != 8 {
t.Fatalf("child rows: got %d want 8", l.childRows())
}
}
func TestTerminalLayoutTinyClampsChildSize(t *testing.T) {
l := newTerminalLayout(0, 1)
if l.childCols() != 1 || l.childRows() != 1 {
t.Fatalf("child size: got %dx%d want 1x1", l.childCols(), l.childRows())
}
}
func TestSpawnSizingUsesViewportDimensions(t *testing.T) {
l := newTerminalLayout(120, 40)
launcher := NewLauncher(nil, "", l.childCols(), l.childRows())
cols, rows := launcher.size()
if cols != 91 || rows != 36 {
t.Fatalf("launcher size: got %dx%d want 91x36", cols, rows)
}
host := newToolHost(nil, nil, nil, preset.Set{}, nil, l.childCols(), l.childRows())
cols, rows = host.size()
if cols != 91 || rows != 36 {
t.Fatalf("tool host size: got %dx%d want 91x36", cols, rows)
}
}