internal/web/layout_test.go
31 lines · 1100 bytes
1package web
2
3import (
4 "strings"
5 "testing"
6)
7
8// The repository header, main and footer share one centered container:
9// the header's inner content is wrapped, and the stylesheet caps and
10// centers all three on the same token (desktop layout spec).
11func TestSharedCenteredContainer(t *testing.T) {
12 layout, err := templateFS.ReadFile("templates/layout.html")
13 if err != nil {
14 t.Fatal(err)
15 }
16 if !strings.Contains(string(layout), "<header class=\"repohead\">\n<div class=\"wrap\">") {
17 t.Fatalf("repohead is not wrapped in .wrap")
18 }
19 css := string(StyleCSS)
20 for _, want := range []string{
21 "--container: 100rem;",
22 "main.content, main.wide, footer { max-width: calc(var(--container) + 2 * var(--sp-6)); margin: 0 auto; }",
23 ".repohead .wrap { max-width: calc(var(--container) + 2 * var(--sp-6)); margin: 0 auto; padding: 0 var(--sp-6); }",
24 "main.reading { max-width: calc(72rem + 2 * var(--sp-6)); margin: 0 auto; }",
25 "main.bounded { max-width: calc(48rem + 2 * var(--sp-6)); margin: 0 auto; }",
26 } {
27 if !strings.Contains(css, want) {
28 t.Errorf("style.css lacks %q", want)
29 }
30 }
31}