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

Function TestRun

termdash_test.go:184–470  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

182}
183
184func TestRun(t *testing.T) {
185 t.Parallel()
186
187 tests := []struct {
188 desc string
189 size image.Point
190 opts func(*eventHandlers) []Option
191 events []terminalapi.Event
192 // The number of expected processed events, used for synchronization.
193 // Equals len(events) * number of subscribers for the event type.
194 wantProcessed int
195 // function to execute after the test case, can do additional comparison.
196 after func(*eventHandlers) error
197 want func(size image.Point) *faketerm.Terminal
198 wantErr bool
199 }{
200 {
201 desc: "draws the dashboard until closed",
202 size: image.Point{60, 10},
203 opts: func(*eventHandlers) []Option {
204 return []Option{
205 RedrawInterval(1),
206 }
207 },
208 want: func(size image.Point) *faketerm.Terminal {
209 ft := faketerm.MustNew(size)
210
211 fakewidget.MustDraw(
212 ft,
213 testcanvas.MustNew(ft.Area()),
214 &widgetapi.Meta{Focused: true},
215 widgetapi.Options{},
216 )
217 return ft
218 },
219 },
220 {
221 desc: "fails when the widget doesn't draw due to size too small",
222 size: image.Point{1, 1},
223 opts: func(*eventHandlers) []Option {
224 return []Option{
225 RedrawInterval(1),
226 }
227 },
228 want: func(size image.Point) *faketerm.Terminal {
229 ft := faketerm.MustNew(size)
230 return ft
231 },
232 wantErr: true,
233 },
234 {
235 desc: "forwards mouse events to container",
236 size: image.Point{60, 10},
237 opts: func(*eventHandlers) []Option {
238 return []Option{
239 RedrawInterval(1),
240 }
241 },

Callers

nothing calls this directly

Calls 15

ProcessedMethod · 0.95
MustNewFunction · 0.92
MustDrawFunction · 0.92
MustNewFunction · 0.92
NewErrorFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
WithEventQueueFunction · 0.92
NewFunction · 0.92
PlaceWidgetFunction · 0.92
NewFunction · 0.92
NewDistributionSystemFunction · 0.92

Tested by

no test coverage detected