WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a69c449

Browse files
committed
Update tests to initialise visuals (despite not being shown)
1 parent 2422b43 commit a69c449

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

escape_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ func TestClearScreen(t *testing.T) {
1313
term := New()
1414
term.config.Columns = 5
1515
term.config.Rows = 2
16+
term.Refresh() // ensure visuals set up
17+
1618
term.handleOutput([]byte("Hello"))
1719
assert.Equal(t, "Hello", term.content.Text())
1820

@@ -28,6 +30,7 @@ func TestScrollBack_Tmux(t *testing.T) {
2830
term.debug = true
2931
term.config.Columns = 80 // 80 columns (standard terminal width)
3032
term.config.Rows = 5 // Doesn't matter
33+
term.Refresh() // ensure visuals set up
3134

3235
// Step 2: Populate the entire screen with lines using cursor movement
3336
for i := 1; i <= 40; i++ {
@@ -88,6 +91,7 @@ func TestScrollBack_With_Zero_Back_Buffer(t *testing.T) {
8891
term.debug = true
8992
term.config.Columns = 80 // 80 columns (standard terminal width)
9093
term.config.Rows = 5 // Doesn't matter
94+
term.Refresh() // ensure visuals set up
9195

9296
// Step 1: Populate the entire screen with lines using cursor movement
9397
for i := 1; i <= tt.linesToAdd; i++ {
@@ -117,6 +121,8 @@ func TestInsertDeleteChars(t *testing.T) {
117121
term := New()
118122
term.config.Columns = 5
119123
term.config.Rows = 2
124+
term.Refresh() // ensure visuals set up
125+
120126
term.handleOutput([]byte("Hello"))
121127
assert.Equal(t, "Hello", term.content.Text())
122128

@@ -131,6 +137,8 @@ func TestEraseLine(t *testing.T) {
131137
term := New()
132138
term.config.Columns = 5
133139
term.config.Rows = 2
140+
term.Refresh() // ensure visuals set up
141+
134142
term.handleOutput([]byte("Hello"))
135143
assert.Equal(t, "Hello", term.content.Text())
136144

@@ -143,6 +151,8 @@ func TestCursorMove(t *testing.T) {
143151
term := New()
144152
term.config.Columns = 5
145153
term.config.Rows = 2
154+
term.Refresh() // ensure visuals set up
155+
146156
term.handleOutput([]byte("Hello"))
147157
assert.Equal(t, 0, term.cursorRow)
148158
assert.Equal(t, 5, term.cursorCol)
@@ -172,6 +182,8 @@ func TestCursorMove_Overflow(t *testing.T) {
172182
term := New()
173183
term.config.Columns = 2
174184
term.config.Rows = 2
185+
term.Refresh() // ensure visuals set up
186+
175187
term.handleEscape("2;2H")
176188
assert.Equal(t, 1, term.cursorRow)
177189
assert.Equal(t, 1, term.cursorCol)
@@ -326,6 +338,8 @@ func TestTerminalEscapeSequences(t *testing.T) {
326338
term := New()
327339
term.config.Columns = 10
328340
term.config.Rows = 1
341+
term.Refresh() // ensure visuals set up
342+
329343
term.handleOutput([]byte(testCase.input))
330344
actual := term.content.Text()
331345
if actual != testCase.expected {

term_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
func TestNewTerminal(t *testing.T) {
1616
term := New()
1717
assert.NotNil(t, term)
18+
19+
term.Refresh() // ensure visuals set up
1820
assert.NotNil(t, term.content)
1921
}
2022

0 commit comments

Comments
 (0)