Files
Summerize/internal/output/spotify_test.go
2026-05-10 13:37:17 -06:00

68 lines
1.4 KiB
Go

package output
import (
"strings"
"testing"
)
func TestMarkdownToSpotifyHTML(t *testing.T) {
in := `# Sermon Title
**Speaker:** Pastor Bob
**Scripture:** John 3:16
## Overview
This was a *short* message about hope. See [the site](https://example.com).
## Key Points
- First point
- Second point with **bold** text
- Third one
1. Step one
2. Step two
> A pithy quote.
`
got := MarkdownToSpotifyHTML(in)
mustContain := []string{
"<p><b>Sermon Title</b></p>",
"<b>Speaker:</b>",
"<p><b>Overview</b></p>",
"<i>short</i>",
`<a href="https://example.com">the site</a>`,
"<ul>",
"<li>First point</li>",
"<li>Second point with <b>bold</b> text</li>",
"</ul>",
"<ol>",
"<li>Step one</li>",
"</ol>",
"<p><i>A pithy quote.</i></p>",
}
for _, s := range mustContain {
if !strings.Contains(got, s) {
t.Errorf("expected output to contain %q\n--- got ---\n%s", s, got)
}
}
mustNotContain := []string{"<h1>", "<h2>", "<blockquote>", "**", "##"}
for _, s := range mustNotContain {
if strings.Contains(got, s) {
t.Errorf("did not expect output to contain %q\n--- got ---\n%s", s, got)
}
}
}
func TestEscapesHTML(t *testing.T) {
got := MarkdownToSpotifyHTML("A <script>tag</script> & ampersand")
if strings.Contains(got, "<script>") {
t.Errorf("unescaped <script>: %s", got)
}
if !strings.Contains(got, "&amp;") {
t.Errorf("expected &amp; in: %s", got)
}
}