Files
arr-tui/internal/ui/notify_test.go
T
2026-10-20 19:57:05 +02:00

42 lines
1007 B
Go

package ui
import (
"testing"
"github.com/rivo/tview"
)
func TestPlainText(t *testing.T) {
for _, tc := range []struct{ in, want string }{
{"[green]Done[-]", "Done"},
{"[red]" + tview.Escape("Movie [1080p] failed"), "Movie [1080p] failed"},
{"plain", "plain"},
{"[yellow]a [::b]b[::-]", "a b"},
} {
if got := plainText(tc.in); got != tc.want {
t.Errorf("plainText(%q) = %q, want %q", tc.in, got, tc.want)
}
}
}
func TestToastProgress(t *testing.T) {
if !(toast{text: "Searching…"}).progress() || (toast{text: "Done"}).progress() {
t.Error("progress detection wrong")
}
}
func TestOnlyFullOverlays(t *testing.T) {
a := &App{}
if !a.onlyFullOverlays() {
t.Error("no overlays: view shortcuts must work")
}
a.overlays = []overlay{{full: true}, {full: true}}
if !a.onlyFullOverlays() {
t.Error("full-screen views must not block view shortcuts")
}
a.overlays = append(a.overlays, overlay{})
if a.onlyFullOverlays() {
t.Error("a dialog must block view shortcuts")
}
}