-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel_test.go
More file actions
50 lines (40 loc) · 1.18 KB
/
Copy pathmodel_test.go
File metadata and controls
50 lines (40 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"strings"
"testing"
)
func TestSetErrorContent(t *testing.T) {
t.Run("wraps long text to viewport width", func(t *testing.T) {
m := initialModel("")
m.viewport.Width = 40
longError := strings.Repeat("error ", 20) // 120 chars
m.setErrorContent(longError)
content := m.viewport.View()
lines := strings.Split(content, "\n")
if len(lines) < 2 {
t.Errorf("expected wrapped text (multiple lines), got %d line(s)", len(lines))
}
})
t.Run("uses default width when viewport uninitialized", func(t *testing.T) {
m := initialModel("")
m.viewport.Width = 0
m.setErrorContent("some error text")
content := m.viewport.View()
if !strings.Contains(content, "some error text") {
t.Error("expected error text in viewport content")
}
})
t.Run("preserves line breaks in error", func(t *testing.T) {
m := initialModel("")
m.viewport.Width = 80
m.viewport.Height = 20
m.setErrorContent("line one\nline two\nline three")
content := m.viewport.View()
if !strings.Contains(content, "line one") {
t.Error("expected 'line one' in content")
}
if !strings.Contains(content, "line two") {
t.Error("expected 'line two' in content")
}
})
}