MCPcopy
hub / github.com/charmbracelet/bubbletea / TestTeaBatchMsg

Function TestTeaBatchMsg

tea_test.go:400–434  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

398}
399
400func TestTeaBatchMsg(t *testing.T) {
401 t.Parallel()
402 var buf bytes.Buffer
403 var in bytes.Buffer
404
405 inc := func() Msg {
406 return incrementMsg{}
407 }
408
409 m := &testModel{}
410 p := NewProgram(m,
411 WithInput(&in),
412 WithOutput(&buf),
413 )
414 go func() {
415 p.Send(BatchMsg{inc, inc})
416
417 for {
418 time.Sleep(time.Millisecond)
419 i := m.counter.Load()
420 if i != nil && i.(int) >= 2 {
421 p.Quit()
422 return
423 }
424 }
425 }()
426
427 if _, err := p.Run(); err != nil {
428 t.Fatal(err)
429 }
430
431 if m.counter.Load() != 2 {
432 t.Fatalf("counter should be 2, got %d", m.counter.Load())
433 }
434}
435
436func TestTeaSequenceMsg(t *testing.T) {
437 t.Parallel()

Callers

nothing calls this directly

Calls 6

SendMethod · 0.95
QuitMethod · 0.95
RunMethod · 0.95
NewProgramFunction · 0.85
WithInputFunction · 0.85
WithOutputFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…