Skip to content
quarry Artifact [850ebf9a5e]
Login

Artifact [850ebf9a5e]

Artifact 850ebf9a5e1c263e5d1e453ac5ab26895af5f2f535bdeee61f66924575cc7191:


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 := noHooks.template(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")
	}
}