1package theme23import (4 "strings"5 "testing"67 "charm.land/lipgloss/v2"8)910// The standout roles are drawn in reverse video with their colors11// swapped, so they look as defined in color; Drawable undoes that where12// lipgloss would draw spaces without reverse video.13func TestStandouts(t *testing.T) {14 th := New(true)15 p := th.Pointer16 if !p.GetReverse() || p.GetForeground() != lipgloss.Cyan || p.GetBackground() != lipgloss.Black {17 t.Errorf("pointer: reverse %v fg %v bg %v", p.GetReverse(), p.GetForeground(), p.GetBackground())18 }19 if !strings.Contains(p.Render("x"), "7") {20 t.Errorf("no SGR 7: %q", p.Render("x"))21 }22 if Drawable(p).Render("x") != p.Render("x") {23 t.Error("Drawable changed a plain standout")24 }25 d := Drawable(p.Underline(true))26 if d.GetReverse() || d.GetForeground() != lipgloss.Black || d.GetBackground() != lipgloss.Cyan {27 t.Errorf("underlined: reverse %v fg %v bg %v", d.GetReverse(), d.GetForeground(), d.GetBackground())28 }29 for _, s := range []lipgloss.Style{th.Selection, th.HeaderSel, th.HeaderActive, th.Found, th.Precedent, th.Dependent, th.MenuSelected} {30 if !s.GetReverse() {31 t.Errorf("%v isn't reversed", s)32 }33 }34 // Monochrome keeps attributes and makes every color one.35 m := Monochrome(th)36 if !m.Pointer.GetReverse() || m.Pointer.GetForeground() != m.Error.GetForeground() || !m.Spilled.GetItalic() {37 t.Error("monochrome lost an attribute or kept a color")38 }39}