MCPcopy
hub / github.com/mum4k/termdash / TestTextInput

Function TestTextInput

widgets/textinput/textinput_test.go:67–1590  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestTextInput(t *testing.T) {
68 // Makes the empty text input field visible and cursor in test outputs.
69 textFieldRune = '_'
70 cursorRune = '█'
71
72 tests := []struct {
73 desc string
74 callback *callbackTracker
75 opts []Option
76 events []terminalapi.Event
77 canvas image.Rectangle
78 meta *widgetapi.Meta
79 want func(size image.Point) *faketerm.Terminal
80 wantCallback *callbackTracker
81 wantNewErr bool
82 wantDrawErr bool
83 wantEventErr bool
84 }{
85 {
86 desc: "fails on WidthPerc too low",
87 opts: []Option{
88 WidthPerc(0),
89 },
90 wantNewErr: true,
91 },
92 {
93 desc: "fails on WidthPerc too high",
94 opts: []Option{
95 WidthPerc(101),
96 },
97 wantNewErr: true,
98 },
99 {
100 desc: "fails on MaxWidthCells too low",
101 opts: []Option{
102 MaxWidthCells(3),
103 },
104 wantNewErr: true,
105 },
106 {
107 desc: "fails on HideTextWith control rune",
108 opts: []Option{
109 HideTextWith(0x007f),
110 },
111 wantNewErr: true,
112 },
113 {
114 desc: "fails on HideTextWith full-width rune",
115 opts: []Option{
116 HideTextWith('世'),
117 },
118 wantNewErr: true,
119 },
120 {
121 desc: "fails on invalid DefaultText which has control characters",
122 opts: []Option{
123 DefaultText("\r"),
124 },

Callers

nothing calls this directly

Calls 15

MustNewFunction · 0.92
MustNewFunction · 0.92
MustSetAreaCellsFunction · 0.92
BgColorFunction · 0.92
ColorNumberFunction · 0.92
MustApplyFunction · 0.92
MustBorderFunction · 0.92
BorderCellOptsFunction · 0.92
FgColorFunction · 0.92
MustSetCellFunction · 0.92
MustTextFunction · 0.92
TextCellOptsFunction · 0.92

Tested by

no test coverage detected