-
Notifications
You must be signed in to change notification settings - Fork 6
/
normalize_test.go
91 lines (76 loc) · 2.38 KB
/
normalize_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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package normalize_email
import (
"testing"
)
func TestNormalize(t *testing.T) {
testCases := map[string]string{
// Only supported domains
// Gmail dots
// Plus
// Non-standard TLDs
// Yahoo!
// Microsoft
// Google Apps for Work
// FastMail
// http://outcoldman.com/en/archive/2014/05/08/fastmail/
}
// TODO: force remove dot and force remove tags
testCases2 := map[string]string{
// Non-standard TLDs
}
// TODO: detect provider
testCases3 := map[string]string{
// Google Apps for Work
// Async test Google Apps for Work
// Async test no special provider
}
for input, expected := range testCases {
result := Normalize(input, nil, nil)
if result != expected {
t.Errorf("err got %s, expected %s\n", result, expected)
}
}
for input, expected := range testCases2 {
var option = Option{
ForceRemoveDots: true,
ForceRemoveTags: true,
}
result := Normalize(input, &option, nil)
if result != expected {
t.Errorf("err got %s, expected %s\n", result, expected)
}
}
for input, expected := range testCases3 {
var option = Option{
DetectProvider: true,
}
callback := make(chan string)
Normalize(input, &option, callback)
result := <-callback
if result != expected {
t.Errorf("err got %s, expected %s\n", result, expected)
}
}
}