Files
AppleSync/internal/text/text_test.go
T
2026-11-26 15:11:41 +01:00

46 lines
1.1 KiB
Go

package text
import "testing"
func TestSearchTitle(t *testing.T) {
cases := map[string]string{
"The X-panded Universe - Single": "The X-panded Universe",
"Ambiguous Desire (Deluxe)": "Ambiguous Desire",
"Album - Deluxe Edition": "Album",
"Song (Remastered)": "Song",
"Untouched": "Untouched",
}
for input, want := range cases {
if got := SearchTitle(input); got != want {
t.Errorf("SearchTitle(%q) = %q, want %q", input, got, want)
}
}
}
func TestSimilarityEmptyArtists(t *testing.T) {
if got := Similarity("@", "@"); got != 1 {
t.Fatalf("Similarity(@,@) = %v, want 1", got)
}
if got := Similarity("@", "Someone"); got != 0 {
t.Fatalf("Similarity(@,Someone) = %v, want 0", got)
}
}
func TestSlug(t *testing.T) {
if got := Slug("indie + chill"); got != "indie-chill" {
t.Fatalf("Slug = %q", got)
}
if got := Slug(" *** "); got != "playlist" {
t.Fatalf("Slug fallback = %q", got)
}
}
func TestIsNoisyAlbum(t *testing.T) {
if !IsNoisyAlbum("Greatest Hits") {
t.Fatal("expected Greatest Hits to be noisy")
}
if IsNoisyAlbum("Popfly") {
t.Fatal("Popfly should not be noisy")
}
}