xonecas.io
8356
Wx

www-xonecas-io / files

www-xonecas-io / internal / site / sidebar_test.go

581 bytes
1package site
2
3import (
4	"fmt"
5	"testing"
6)
7
8// TestSidebar opens only the folders on the way to the page, and marks the page.
9func TestSidebar(t *testing.T) {
10	tree := Tree{Files: map[string]int64{"a/b/c.go": 1, "a/d.go": 1, "e/f.go": 1, "g.md": 1}, Dirs: map[string]bool{"a": true, "a/b": true, "e": true}}
11	got := ""
12	for _, e := range sidebar(Children("p", tree), "a/b/c.go") {
13		got += fmt.Sprintf("%d%s%v ", e.Depth, e.Name, e.Here || e.Open)
14	}
15	if want := "0atrue 1btrue 2c.gotrue 1d.gofalse 0efalse 0g.mdfalse "; got != want {
16		t.Errorf("got %q, want %q", got, want)
17	}
18}