fix
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package processing
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPlainDescriptionFromAny_arrayAndHTML(t *testing.T) {
|
||||
got := PlainDescriptionFromAny([]any{"Hello<br>World", "Second"})
|
||||
@@ -16,6 +19,24 @@ func TestPlainDescriptionFromAny_arrayAndHTML(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescriptionFromAny_preservesFormulaHTML(t *testing.T) {
|
||||
htmlDesc := `<h1>Anker Soundcore Space One Pro</h1><p>Zložljive ANC slušalke.</p><ul><li>Bluetooth</li></ul>`
|
||||
got := DescriptionFromAny(htmlDesc)
|
||||
if !strings.Contains(got, "<h1>") || !strings.Contains(got, "<p>") || !strings.Contains(got, "<ul>") {
|
||||
t.Fatalf("expected formula HTML preserved, got %q", got)
|
||||
}
|
||||
// Array unwrap should still keep tags.
|
||||
got = DescriptionFromAny([]any{htmlDesc})
|
||||
if !strings.Contains(got, "<h1>") || !strings.Contains(got, "</p>") {
|
||||
t.Fatalf("array unwrap should keep HTML, got %q", got)
|
||||
}
|
||||
// Plain path still strips (meta/SEO / feed normalize).
|
||||
plain := PlainDescriptionFromAny(htmlDesc)
|
||||
if strings.Contains(plain, "<h1>") || strings.Contains(plain, "<p>") {
|
||||
t.Fatalf("PlainDescriptionFromAny should strip tags, got %q", plain)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeMapped_descriptionArrayBecomesPlainString(t *testing.T) {
|
||||
got := NormalizeMapped(map[string]any{
|
||||
"description": []any{"Line1<br/>A", "Line2"},
|
||||
|
||||
Reference in New Issue
Block a user