- Append .message-row/.message-own/.message-other/.message-bubble/.message-meta CSS classes to app.css - Create discussion_view.go with DiscussionMessageView, DiscussionTabData, NewDiscussionTabData - Create discussion_view_test.go with TestChatMainContentRendersBubbleClasses (RED: compile error expected)
28 lines
629 B
Go
28 lines
629 B
Go
package views
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestChatMainContentRendersBubbleClasses(t *testing.T) {
|
|
data := DiscussionTabData{
|
|
Messages: []DiscussionMessageView{
|
|
{Author: "you@xtablo.com", Timestamp: "09:14", Body: "Hello", IsOwn: true},
|
|
{Author: "other@xtablo.com", Timestamp: "09:17", Body: "Hi there", IsOwn: false},
|
|
},
|
|
}
|
|
|
|
html := renderViewToString(t, ChatMainContent(data))
|
|
|
|
for _, want := range []string{
|
|
`class="ui-card"`,
|
|
`message-own`,
|
|
`message-other`,
|
|
`message-bubble`,
|
|
} {
|
|
if !strings.Contains(html, want) {
|
|
t.Fatalf("expected %q in rendered HTML, got:\n%s", want, html)
|
|
}
|
|
}
|
|
}
|