mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-03 00:13:35 -05:00
11ca84f8cb
Now aliases and indexes are not restricted ASCII letters and can include any unicode letters.
45 lines
999 B
Go
45 lines
999 B
Go
package helpers
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestMakePath(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
expected string
|
|
}{
|
|
{" foo bar ", "foo-bar"},
|
|
{"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"},
|
|
{"foo,bar:foo%bar", "foobarfoobar"},
|
|
{"foo/bar.html", "foo/bar.html"},
|
|
{"трям/трям", "трям/трям"},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
output := MakePath(test.input)
|
|
if output != test.expected {
|
|
t.Errorf("Expected %#v, got %#v\n", test.expected, output)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestUrlize(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
expected string
|
|
}{
|
|
{" foo bar ", "foo-bar"},
|
|
{"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"},
|
|
{"foo,bar:foo%bar", "foobarfoobar"},
|
|
{"foo/bar.html", "foo/bar.html"},
|
|
{"трям/трям", "%D1%82%D1%80%D1%8F%D0%BC/%D1%82%D1%80%D1%8F%D0%BC"},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
output := Urlize(test.input)
|
|
if output != test.expected {
|
|
t.Errorf("Expected %#v, got %#v\n", test.expected, output)
|
|
}
|
|
}
|
|
}
|