ssh-chat/chat/message_test.go
2015-01-18 18:55:47 -08:00

53 lines
1.1 KiB
Go

package chat
import "testing"
type testId string
func (i testId) Id() string {
return string(i)
}
func (i testId) SetId(s string) {
// no-op
}
func (i testId) Name() string {
return i.Id()
}
func TestMessage(t *testing.T) {
var expected, actual string
expected = " * foo"
actual = NewAnnounceMsg("foo").String()
if actual != expected {
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
}
u := NewUser(testId("foo"))
expected = "foo: hello"
actual = NewPublicMsg("hello", u).String()
if actual != expected {
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
}
expected = "** foo sighs."
actual = NewEmoteMsg("sighs.", u).String()
if actual != expected {
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
}
expected = "-> hello"
actual = NewSystemMsg("hello", u).String()
if actual != expected {
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
}
expected = "[PM from foo] hello"
actual = NewPrivateMsg("hello", u, u).String()
if actual != expected {
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
}
}
// TODO: Add theme rendering tests