generated from alexstojda/go-react-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(utils): Add tests for slugify function
- Loading branch information
1 parent
1ec6aec
commit 75c8765
Showing
2 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package utils_test | ||
|
||
import ( | ||
"github.com/onsi/ginkgo/v2" | ||
"github.com/onsi/gomega" | ||
"pinman/internal/utils" | ||
) | ||
|
||
var _ = ginkgo.Describe("Slugify", func() { | ||
ginkgo.Context("when it receives a string to be slugified", func() { | ||
ginkgo.It("should return a slugified string", func() { | ||
value := "This is a string to be slugified" | ||
expected := "this-is-a-string-to-be-slugified" | ||
gomega.Expect(utils.Slugify(value)).To(gomega.Equal(expected)) | ||
}) | ||
}) | ||
ginkgo.Context("when it receives a string with special characters to be slugified", func() { | ||
ginkgo.It("should return a slugified string", func() { | ||
value := "This is a string to be slugified with special characters: áéíóúñ" | ||
expected := "this-is-a-string-to-be-slugified-with-special-characters-aeioun" | ||
gomega.Expect(utils.Slugify(value)).To(gomega.Equal(expected)) | ||
}) | ||
}) | ||
ginkgo.Context("when it receives a string to be slugified and a max length", func() { | ||
ginkgo.It("should return a slugified string with the max length", func() { | ||
value := "This is a string to be slugified" | ||
expected := "this-is-a-string" | ||
gomega.Expect(utils.Slugify(value, 17)).To(gomega.Equal(expected)) | ||
}) | ||
}) | ||
}) |