MCPcopy
hub / github.com/basecamp/once / TestMenu_MinWidthFloorForShortcuts

Function TestMenu_MinWidthFloorForShortcuts

internal/ui/menu_test.go:141–156  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

139}
140
141func TestMenu_MinWidthFloorForShortcuts(t *testing.T) {
142 menu := NewMenu(
143 MenuItem{Label: "Stop", Key: 0, Shortcut: WithHelp(NewKeyBinding("s"), "s", "")},
144 MenuItem{Label: "Remove", Key: 1, Shortcut: WithHelp(NewKeyBinding("r"), "r", "")},
145 )
146 // Set width narrower than content needs — minWidth should be used
147 menu.SetWidth(3)
148
149 view := ansi.Strip(menu.View())
150 lines := strings.Split(view, "\n")
151
152 // Both keys should be consistently right-aligned
153 assert.True(t, strings.HasSuffix(lines[0], "s"))
154 assert.True(t, strings.HasSuffix(lines[1], "r"))
155 assert.Equal(t, lipgloss.Width(lines[0]), lipgloss.Width(lines[1]))
156}

Callers

nothing calls this directly

Calls 6

SetWidthMethod · 0.95
ViewMethod · 0.95
NewMenuFunction · 0.85
WithHelpFunction · 0.85
NewKeyBindingFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…