BlueGit

timfa bluegit

Files

bluegit / internal / markdown / markdown_test.go

markdown_test.go

feat: voeg een issue-tracker per repository toe
timfa project_87923614_bot_3aff574f6f98414b945a8799374f9092 · pushed by timfa · 3 weeks ago
f3222d5f History
markdown_test.go 1.1 KiB Download Raw
1package markdown
2
3import (
4 "strings"
5 "testing"
6)
7
8func TestTableAndEscape(t *testing.T) {
9 src := "# Demo\n\nEen <script>regel</script> met **vet**.\n\n| Sleutel | Actie |\n| --- | --- |\n| A | Links |\n| D | Rechts |\n\nZie [regels](docs/regels.md).\n"
10 got := Render(src, "/tim/demo/-/blob/", "master", "")
11 for _, want := range []string{
12 "<h1>Demo</h1>",
13 "<strong>vet</strong>",
14 "&lt;script&gt;",
15 "<table class=\"md\">",
16 "<th>Sleutel</th>",
17 "<td>Links</td>",
18 `href="/tim/demo/-/blob/docs/regels.md?rev=master"`,
19 } {
20 if !strings.Contains(got, want) {
21 t.Errorf("mist %s in\n%s", want, got)
22 }
23 }
24}
25
26func TestIssueRefs(t *testing.T) {
27 got := Render("Zie #12 en !5.\n\n`#9` en a#3 en x!7.", "", "", "/tim/app")
28 for _, want := range []string{
29 `<a href="/tim/app/-/issues/12">#12</a>`,
30 `<a href="/tim/app/-/merge-requests/5">!5</a>`,
31 "<code>#9</code>",
32 } {
33 if !strings.Contains(got, want) {
34 t.Errorf("mist %s in\n%s", want, got)
35 }
36 }
37 if strings.Contains(got, "/issues/3") || strings.Contains(got, "/issues/9") || strings.Contains(got, "merge-requests/7") {
38 t.Fatalf("verwijzing in code of woord: %s", got)
39 }
40}