test: cmds

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos A Becker 2021-10-10 11:44:08 -03:00 committed by Christian Rocha
parent 7934b60e21
commit cfb871c5ca
1 changed files with 21 additions and 0 deletions

View File

@ -3,8 +3,29 @@ package tea
import ( import (
"fmt" "fmt"
"testing" "testing"
"time"
) )
func TestEvery(t *testing.T) {
expected := "every ms"
msg := Every(time.Millisecond, func(t time.Time) Msg {
return expected
})()
if expected != msg {
t.Fatalf("expected a msg %v but got %v", expected, msg)
}
}
func TestTick(t *testing.T) {
expected := "tick"
msg := Tick(time.Millisecond, func(t time.Time) Msg {
return expected
})()
if expected != msg {
t.Fatalf("expected a msg %v but got %v", expected, msg)
}
}
func TestSequentially(t *testing.T) { func TestSequentially(t *testing.T) {
var expectedErrMsg = fmt.Errorf("some err") var expectedErrMsg = fmt.Errorf("some err")
var expectedStrMsg = "some msg" var expectedStrMsg = "some msg"