-
Notifications
You must be signed in to change notification settings - Fork 1
/
text_test.go
59 lines (53 loc) · 1.07 KB
/
text_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package humanize
import (
"strings"
"testing"
)
func TestFormatFuzzyText(t *testing.T) {
tests := []struct {
input, expected string
formatter interface{}
}{
{
"formatting_test",
"FORMATTING TEST",
strings.ToUpper,
},
{
"@@@@@a.b.c!!!!1.2.3",
"a b c 1 2 3",
nil,
},
{
"some-----text-----here",
"Some Text Here",
strings.Title,
},
{
"1_2_3",
"1 2 3",
"invalid formatter",
},
}
for _, test := range tests {
if actual := FormatFuzzyText(test.input, test.formatter); actual != test.expected {
t.Errorf("expected `%s` but got `%s`", test.expected, actual)
}
}
}
func TestFuzzyText(t *testing.T) {
tests := []struct {
input, expected string
}{
{"some_random-Sentence", "Some random sentence"},
{"App_Id", "App id"},
{"Field-name", "Field name"},
{"PascalCase", "Pascal case"},
{"some-!!@@----Wierd_____format", "Some wierd format"},
}
for _, test := range tests {
if actual := FuzzyText(test.input); actual != test.expected {
t.Errorf("expected `%s` but got `%s`", test.expected, actual)
}
}
}