Initial patterm project
This commit is contained in:
58
internal/app/layout_test.go
Normal file
58
internal/app/layout_test.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/harrybrwn/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() != 92 {
|
||||
t.Fatalf("child cols: got %d want 92", l.childCols())
|
||||
}
|
||||
if l.childRows() != 38 {
|
||||
t.Fatalf("child rows: got %d want 38", l.childRows())
|
||||
}
|
||||
if l.mainTop != 2 || 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() != 10 {
|
||||
t.Fatalf("child rows: got %d want 10", 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 != 92 || rows != 38 {
|
||||
t.Fatalf("launcher size: got %dx%d want 92x38", cols, rows)
|
||||
}
|
||||
|
||||
host := newToolHost(nil, nil, nil, preset.Set{}, nil, l.childCols(), l.childRows())
|
||||
cols, rows = host.size()
|
||||
if cols != 92 || rows != 38 {
|
||||
t.Fatalf("tool host size: got %dx%d want 92x38", cols, rows)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user