GitRoot
craft your forge, build your project, grow your community freely
1// SPDX-FileCopyrightText: 2025 Romain Maneschi <romain@gitroot.dev>
2//
3// SPDX-License-Identifier: EUPL-1.2
4
5package main
6
7import (
8 "testing"
9
10 "gitroot.dev/libs/golang/plugin/test"
11)
12
13func TestRelativeLink(t *testing.T) {
14 l := relativePath("/doc/main.md", "/")
15 if l != "../" {
16 t.Errorf("l should be ../ but was %s", l)
17 }
18}
19
20func TestMenu(t *testing.T) {
21 p := &Plugin{
22 server: test.NewFakeServer(t, test.Override{}),
23 }
24 p.config = p.NewConf(`{"menu": [
25 {"display": "🏠 Home", "link": "/"},
26 {"display": "📖 Documentation", "link": "/doc/"}
27 ]}`)
28 menu := p.buildMenu("/doc/index.md")
29 menuForDoc := "<ul><li><a href=\"../\">🏠 Home</a></li><li><a aria-current=\"page\">📖 Documentation</a></li></ul>"
30 if menu != menuForDoc {
31 t.Errorf("l should be %s but was %s", menuForDoc, menu)
32 }
33}