From 77619d21f5865c81c04fecdfc953f4bb44c99277 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 8 Oct 2022 18:53:59 +0200 Subject: [PATCH] test: add sequenceMsg test --- tea_test.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tea_test.go b/tea_test.go index eebd8ba..2205a00 100644 --- a/tea_test.go +++ b/tea_test.go @@ -125,6 +125,27 @@ func TestTeaBatchMsg(t *testing.T) { } if m.counter.Load() != 2 { - t.Fatalf("counter should be 2, got %d", m.counter) + t.Fatalf("counter should be 2, got %d", m.counter.Load()) + } +} + +func TestTeaSequenceMsg(t *testing.T) { + var buf bytes.Buffer + var in bytes.Buffer + + inc := func() Msg { + return incrementMsg{} + } + + m := &testModel{} + p := NewProgram(m, WithInput(&in), WithOutput(&buf)) + go p.Send(sequenceMsg{inc, inc, Quit}) + + if _, err := p.Run(); err != nil { + t.Fatal(err) + } + + if m.counter.Load() != 2 { + t.Fatalf("counter should be 2, got %d", m.counter.Load()) } }