-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathformatting_test.go
96 lines (94 loc) · 2.09 KB
/
formatting_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
92
93
94
95
96
package main
import (
"github.com/kelaresg/matrix-skype/database"
"github.com/kelaresg/matrix-skype/types"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/format"
"reflect"
"regexp"
"sync"
"testing"
)
func TestFormatter_ParseSkype(t *testing.T) {
type fields struct {
bridge *Bridge
matrixHTMLParser *format.HTMLParser
waReplString map[*regexp.Regexp]string
waReplFunc map[*regexp.Regexp]func(string) string
waReplFuncText map[*regexp.Regexp]func(string) string
}
type args struct {
content *event.MessageEventContent
}
type expect struct {
content *event.MessageEventContent
}
testUser := &User{
User: &database.User{
MXID: "mxtestid",
},
}
testBridge := &Bridge{
usersLock: *new(sync.Mutex),
usersByJID: map[types.SkypeID]*User{"test": testUser},
}
testFormatter := &Formatter{
bridge: testBridge,
}
tests := []struct {
name string
args args
expect expect
}{
{
"simple message",
args{
&event.MessageEventContent{
Body: "This is a very simple message.",
},
},
expect{
&event.MessageEventContent{
Body: "This is a very simple message.",
},
},
},
{
"simple punctuation test",
args{
&event.MessageEventContent{
Body: "It's the inclusion of "simple" punctuation that causes most of the problems.",
},
},
expect{
&event.MessageEventContent{
Body: "It's the inclusion of \"simple\" punctuation that causes most of the problems.",
Format: event.FormatHTML,
},
},
},
{
"full punctuation test",
args{
&event.MessageEventContent{
Body: "&<>"'", // use a few different encodings
Format: event.FormatHTML,
},
},
expect{
&event.MessageEventContent{
Body: "&<>\"'",
Format: event.FormatHTML,
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
testFormatter.ParseSkype(tt.args.content, "")
if !reflect.DeepEqual(tt.args.content, tt.expect.content) {
t.Errorf("content = %v, wanted %v", tt.args.content, tt.expect.content)
}
})
}
}