diff options
| author | ewy <ewy0@protonmail.com> | 2026-04-29 00:47:34 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-04-29 00:47:34 +0200 |
| commit | 630d77e1962b43ee95e88a664f5e8b8993213060 (patch) | |
| tree | 8849c2a87443cd231786aed53b76dc7e4ea11aed /viewport/viewport_test.go | |
| parent | 8efcf029576ad82908b4ae80b2c92022dfb857d2 (diff) | |
big stuff
* send empty screen after tui confirmation
* add scroll view / viewport
* auto enable scroll view on short terminals
* add motd tips
* add subdirs as categories
* add inline toggle hotkey (i)
Diffstat (limited to 'viewport/viewport_test.go')
| -rw-r--r-- | viewport/viewport_test.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/viewport/viewport_test.go b/viewport/viewport_test.go new file mode 100644 index 0000000..9da4c3c --- /dev/null +++ b/viewport/viewport_test.go @@ -0,0 +1,54 @@ +//go:build test + +package viewport + +import ( + "github.com/stretchr/testify/assert" + "strings" + "testing" +) + +func TestCrop(t *testing.T) { + input := `0000 +AAAA +` + Caret + `BBB +CCC` + expected := `AAAA +` + Caret + `BBB` + result, _, _ := Crop(input, strings.Split(input, "\n"), 2) + assert.Equal(t, expected, result) +} + +func TestCrop_Under(t *testing.T) { + input := `0000 +AAAA +` + Caret + `BBB` + expected := `AAAA +` + Caret + `BBB` + result, _, _ := Crop(input, strings.Split(input, "\n"), 2) + assert.Equal(t, expected, result) +} + +func TestCrop_Unnecessary(t *testing.T) { + input := `AAAA +` + Caret + `BBB +CCC +DDDD` + expected := input + result, _, _ := Crop(input, strings.Split(input, "\n"), 8) + assert.Equal(t, expected, result) +} + +func TestNeedsViewport(t *testing.T) { + amount := 3 + input := strings.Repeat("\n", amount) + output := NeedsViewport(input, 4) + assert.Equal(t, false, output) +} + +func TestNeedsViewport_Negative(t *testing.T) { + amount := 8 + input := strings.Repeat("\n", amount) + output := NeedsViewport(input, 4) + assert.Equal(t, true, output) +} |
