Small refactoring
This commit is contained in:
+11
-41
@@ -1,51 +1,22 @@
|
||||
package str_test
|
||||
|
||||
import (
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/utils/str"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Clean", func() {
|
||||
DescribeTable("replaces some Unicode chars with their equivalent ASCII",
|
||||
func(input, expected string) {
|
||||
Expect(str.Clear(input)).To(Equal(expected))
|
||||
},
|
||||
Entry("k-os", "k–os", "k-os"),
|
||||
Entry("k‐os", "k‐os", "k-os"),
|
||||
Entry(`"Weird" Al Yankovic`, "“Weird” Al Yankovic", `"Weird" Al Yankovic`),
|
||||
Entry("Single quotes", "‘Single’ quotes", "'Single' quotes"),
|
||||
)
|
||||
})
|
||||
|
||||
var _ = Describe("Strings", func() {
|
||||
Describe("NoArticle", func() {
|
||||
Context("Empty articles list", func() {
|
||||
BeforeEach(func() {
|
||||
conf.Server.IgnoredArticles = ""
|
||||
})
|
||||
It("returns empty if string is empty", func() {
|
||||
Expect(str.NoArticle("")).To(BeEmpty())
|
||||
})
|
||||
It("returns same string", func() {
|
||||
Expect(str.NoArticle("The Beatles")).To(Equal("The Beatles"))
|
||||
})
|
||||
})
|
||||
Context("Default articles", func() {
|
||||
BeforeEach(func() {
|
||||
conf.Server.IgnoredArticles = "The El La Los Las Le Les Os As O A"
|
||||
})
|
||||
It("returns empty if string is empty", func() {
|
||||
Expect(str.NoArticle("")).To(BeEmpty())
|
||||
})
|
||||
It("remove prefix article from string", func() {
|
||||
Expect(str.NoArticle("Os Paralamas do Sucesso")).To(Equal("Paralamas do Sucesso"))
|
||||
})
|
||||
It("does not remove article if it is part of the first word", func() {
|
||||
Expect(str.NoArticle("Thelonious Monk")).To(Equal("Thelonious Monk"))
|
||||
})
|
||||
})
|
||||
var _ = Describe("String Utils", func() {
|
||||
Describe("Clear", func() {
|
||||
DescribeTable("replaces some Unicode chars with their equivalent ASCII",
|
||||
func(input, expected string) {
|
||||
Expect(str.Clear(input)).To(Equal(expected))
|
||||
},
|
||||
Entry("k-os", "k–os", "k-os"),
|
||||
Entry("k‐os", "k‐os", "k-os"),
|
||||
Entry(`"Weird" Al Yankovic`, "“Weird” Al Yankovic", `"Weird" Al Yankovic`),
|
||||
Entry("Single quotes", "‘Single’ quotes", "'Single' quotes"),
|
||||
)
|
||||
})
|
||||
|
||||
Describe("LongestCommonPrefix", func() {
|
||||
@@ -53,7 +24,6 @@ var _ = Describe("Strings", func() {
|
||||
Expect(str.LongestCommonPrefix(testPaths)).To(Equal("/Music/iTunes 1/iTunes Media/Music/"))
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
var testPaths = []string{
|
||||
|
||||
Reference in New Issue
Block a user