package keymaps_test import ( ansi "clx/utils/strip-ansi" "testing" "clx/keymaps" "github.com/stretchr/testify/assert" ) func TestKeymaps(t *testing.T) { t.Parallel() keys := new(keymaps.List) keys.Init() keys.AddHeader("Header") keys.AddSeparator() keys.AddKeymap("Very long description", "x") keys.AddKeymap("Separate item", "xyz") keys.AddSeparator() keys.AddKeymap("Add item", "x") keys.AddKeymap("Delete item", "x") keys.AddSeparator() keys.AddHeader("Header") keys.AddSeparator() keys.AddKeymap("Delete item", "x") keys.AddKeymap("Item", "a + b") actual := keys.Print(80) expected := ` Header x ........................................................ Very long description xyz .............................................................. Separate item x ..................................................................... Add item x .................................................................. Delete item Header x .................................................................. Delete item a + b ..................................................................... Item ` // Workaround for a bug where lipgloss does not render ansi formatting during testing // Possibly related to https://github.com/charmbracelet/lipgloss/issues/176 expectedWithoutAnsi := ansi.Strip(expected) assert.Equal(t, expectedWithoutAnsi, actual) }