List binds with 插槽=rail render aside.side-rail and set has-rail; cards honor pinned; pages that load KaTeX auto-render get an official deferred math boot so authors need no volume.js. Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
715 B
Go
29 lines
715 B
Go
package render
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestIsRailTarget(t *testing.T) {
|
|
for _, in := range []string{"rail", "轨", "新闻轨", "#side-rail", "aside.side-rail"} {
|
|
if !isRailTarget(in) {
|
|
t.Fatalf("expected rail: %q", in)
|
|
}
|
|
}
|
|
if isRailTarget("#comment-list") {
|
|
t.Fatal("comment list must not be rail")
|
|
}
|
|
}
|
|
|
|
func TestRenderNewsRail(t *testing.T) {
|
|
html := renderNewsRail([]map[string]any{
|
|
{"title": "A", "href": "https://ex.test/a", "meta": "2026-09-01", "tag": "IBM"},
|
|
})
|
|
for _, want := range []string{`side-rail--news`, `https://ex.test/a`, `target="_blank"`, `量子新闻`, `全部 →`} {
|
|
if !strings.Contains(html, want) {
|
|
t.Fatalf("missing %q in %s", want, html)
|
|
}
|
|
}
|
|
}
|