package render import ( "strings" "testing" ) func TestRenderMarkdown(t *testing.T) { cases := []struct { name string markdown string want string }{ { name: "Markdown, no link", markdown: `# Test ## 01/24/26 09:14:20 - some entry check this out`, want: `
check this out
`, }, { name: "Markdown, some link", markdown: `# Test 2 ## 01/24/26 09:14:20 - some entry (bare link) Check this out http://tatata.toto here `, want: `Check this out http://tatata.toto here
`, }, { name: "Markdown, some link with description", markdown: `# Test 2 ## 01/24/26 09:14:20 - some entry (bare link) Check this out [here](http://tatata.toto) `, want: `Check this out here
`, }, } for _, test := range cases { got, err := RenderMarkdown([]byte(test.markdown)) if err != nil { t.Errorf("Error rendering markdown: '%s'\n", err) } strip := strings.ReplaceAll(string(got), "\n", "") strip = strings.Trim(strip, " ") if strip != test.want { t.Errorf("Rendering markdown: Wanted '%s', got '%s'.\n", test.want, strip) } } }