package web
import (
"bytes"
"strings"
"testing"
)
// An inbox row names its repository and, when there is one, a summary,
// joined by a separator. A row with a repository and no summary ended
// in a dangling " ·", and a row with neither drew an empty meta line
// that made it taller than its neighbours.
func TestAnInboxRowDrawsOnlyTheMetaItHas(t *testing.T) {
data := pageData{Title: "Inbox", AttnRecent: []attnRow{
{ID: "local:1", Reason: "dmestas accepted x", Repo: "quarry"},
{ID: "local:2", Reason: "slow render: GET /"},
{ID: "local:3", Reason: "mentioned", Repo: "quarry", Summary: "see #12"},
}}
var buf bytes.Buffer
if err := inboxPage.ExecuteTemplate(&buf, "inbox-live", data); err != nil {
t.Fatal(err)
}
page := buf.String()
if strings.Contains(page, `</span> · </div>`) || strings.Contains(page, "</span> · \n</div>") {
t.Error("FAIL: a row with no summary ends in a separator")
}
if n := strings.Count(page, `class="attn-why"`); n != 2 {
t.Errorf("FAIL: %d meta lines for three rows, one of which has no repository or summary", n)
}
if !strings.Contains(page, `<span class="attn-repo">quarry</span> · <span class="attn-summary">see #12</span>`) {
t.Error("FAIL: a row with both no longer joins them")
}
}