MCPcopy
hub / github.com/moncho/dry / TestRenderMainScreen_LineCount

Function TestRenderMainScreen_LineCount

app/render_test.go:14–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestRenderMainScreen_LineCount(t *testing.T) {
15 appui.InitStyles()
16 m := newTestModel()
17 m.header = appui.NewHeaderModel(m.daemon, m.width)
18
19 containers := m.daemon.Containers(nil, docker.SortByContainerID)
20
21 result, _ := m.Update(containersLoadedMsg{containers: containers})
22 m = result.(model)
23
24 hdrLines := strings.Split(m.header.View(), "\n")
25 sepLines := strings.Split(m.header.SeparatorLine(""), "\n")
26 t.Logf("Header lines: %d, Separator lines: %d", len(hdrLines), len(sepLines))
27
28 contentLines := strings.Split(m.containers.View(), "\n")
29 t.Logf("Content lines: %d (expected contentHeight=%d)", len(contentLines), m.contentHeight())
30
31 v := m.renderMainScreen()
32 lines := strings.Split(v, "\n")
33 t.Logf("Terminal: %dx%d, Total lines: %d (expected %d)", m.width, m.height, len(lines), m.height)
34
35 dataRows := 0
36 for _, l := range contentLines {
37 if strings.Contains(l, "▶") || strings.Contains(l, "■") {
38 dataRows++
39 }
40 }
41 t.Logf("Data rows: %d", dataRows)
42
43 if len(lines) != m.height {
44 t.Errorf("Expected %d lines, got %d", m.height, len(lines))
45 }
46
47 result, _ = m.Update(tea.KeyPressMsg{Code: tea.KeyDown})
48 m = result.(model)
49 contentLines2 := strings.Split(m.containers.View(), "\n")
50 dataRows2 := 0
51 for _, l := range contentLines2 {
52 if strings.Contains(l, "▶") || strings.Contains(l, "■") {
53 dataRows2++
54 }
55 }
56 t.Logf("Data rows after nav: %d", dataRows2)
57 if dataRows != dataRows2 {
58 t.Errorf("Data row count changed: %d -> %d", dataRows, dataRows2)
59 }
60}
61
62func TestRenderMainScreen_SmallTerminal(t *testing.T) {
63 // Simulate a small terminal where rows exceed viewport capacity

Callers

nothing calls this directly

Calls 10

InitStylesFunction · 0.92
NewHeaderModelFunction · 0.92
newTestModelFunction · 0.85
SeparatorLineMethod · 0.80
contentHeightMethod · 0.80
renderMainScreenMethod · 0.80
ContainsMethod · 0.80
ContainersMethod · 0.65
UpdateMethod · 0.45
ViewMethod · 0.45

Tested by

no test coverage detected