1package theme23import (4 "testing"56 "github.com/charmbracelet/x/ansi"7)89func TestKeyLabel(t *testing.T) {10 for in, want := range map[string]string{11 "ctrl+s": "Ctrl+S",12 "f10": "F10",13 "delete": "Del",14 "esc": "Esc",15 "alt+pgdown": "Alt+PgDn",16 "ctrl+shift+p": "Ctrl+Shift+P",17 } {18 if got := KeyLabel(in); got != want {19 t.Errorf("KeyLabel(%q) = %q, want %q", in, got, want)20 }21 }22}2324func TestFrameKeepsEveryLineTheSameWidth(t *testing.T) {25 th := New(true)26 lines := th.Frame(12, "A long title that won't fit", "3 of 9", []string{PadRight("row", 12), SepRow, Cells(th.MenuBar, "a row that is too long", 12)})27 if len(lines) != 5 {28 t.Fatalf("%d lines, want 5", len(lines))29 }30 for i, l := range lines {31 if w := ansi.StringWidth(l); w != 14 {32 t.Errorf("line %d is %d wide: %q", i, w, ansi.Strip(l))33 }34 }35 if got := ansi.Strip(lines[4]); got != "└─── 3 of 9 ─┘" {36 t.Errorf("footer %q", got)37 }38}3940func TestPadding(t *testing.T) {41 if got := PadLeft("7", 3) + "|" + PadRight("7", 3) + "|" + Center("ab", 5); got != " 7|7 | ab " {42 t.Errorf("got %q", got)43 }44}