internal/httpd/headings_test.go

98b0b03d448a247f3d4284ddb51fefeea04ecbdd
gitbay/internal/httpd/headings_test.go

20 lines · 573 bytes

 1package httpd
 2
 3import (
 4	"strings"
 5	"testing"
 6)
 7
 8// A rendered README sits under the page's own h1, so its headings move
 9// down one level, ids intact; h6 stays h6 (#133).
10func TestDemoteHeadings(t *testing.T) {
11	out := string(renderReadme("README.md", []byte("# Top\n\n## Next\n\n###### Deep\n")))
12	for _, want := range []string{`<h2 id="top">Top</h2>`, `<h3 id="next">Next</h3>`, `<h6 id="deep">Deep</h6>`} {
13		if !strings.Contains(out, want) {
14			t.Errorf("lacks %s:\n%s", want, out)
15		}
16	}
17	if strings.Contains(out, "<h1") {
18		t.Errorf("an h1 survived:\n%s", out)
19	}
20}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form