package httpd
import (
"html/template"
"strings"
"testing"
)
func TestFocusableBlocks(t *testing.T) {
got := string(focusableBlocks(`
x
y
z
`))
want := `x
y
z
`
if got != want {
t.Fatalf("got %s\nwant %s", got, want)
}
}
func TestImageAlt(t *testing.T) {
cases := map[string]string{
`
`: `
`,
`
`: `
`,
`
`: `
`,
`
`: `
`,
`
`: `
`,
}
for in, want := range cases {
if got := string(imageAlt(template.HTML(in))); got != want {
t.Errorf("%s\n got %s\nwant %s", in, got, want)
}
}
}
// A README badge written as a bare org image link renders as a named
// image, and an org source block takes keyboard focus.
func TestOrgReadmeBadgeAndBlocks(t *testing.T) {
out := string(renderReadme("README.org", []byte("[[https://forge.test/krz/gitbay/builds][https://forge.test/krz/gitbay/badge/build.svg]]\n\n#+begin_src go\npackage main\n#+end_src\n")))
for _, want := range []string{`alt="build"`, `