Message tests.

This commit is contained in:
Andrey Petrov 2014-12-21 14:30:42 -08:00
parent bcfacb89b1
commit 54b593ed47
1 changed files with 34 additions and 0 deletions

34
chat/message_test.go Normal file
View File

@ -0,0 +1,34 @@
package chat
import "testing"
func TestMessage(t *testing.T) {
var expected, actual string
expected = " * foo"
actual = NewMessage("foo").String()
if actual != expected {
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
}
u := NewUser("foo")
expected = "foo: hello"
actual = NewMessage("hello").From(u).String()
if actual != expected {
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
}
expected = "-> hello"
actual = NewMessage("hello").To(u).String()
if actual != expected {
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
}
expected = "[PM from foo] hello"
actual = NewMessage("hello").From(u).To(u).String()
if actual != expected {
t.Errorf("Got: `%s`; Expected: `%s`", actual, expected)
}
}
// TODO: Add theme rendering tests