-
Notifications
You must be signed in to change notification settings - Fork 17
/
utils_test.go
49 lines (39 loc) · 1.51 KB
/
utils_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
package main
import (
"testing"
)
func TestParseText(t *testing.T) {
var text string
text = parseText("It’s a really really good book")
if text != "It’s a really really good book" {
t.Error("Plain text parsing failed")
}
text = parseText("<https://twitter.com/mikeash/status/645014517005570048>")
if text != "" {
t.Error("URL stripping failed")
}
text = parseText(">>> \"And our cardboard cutout of Niall from One Direction had been moved — someone had taken him out of the living room and put him in the garage.\"")
if text != ">>> \"And our cardboard cutout of Niall from One Direction had been moved — someone had taken him out of the living room and put him in the garage.\"" {
t.Error("Entity replacement failed")
}
text = parseText("That should be posted in <#C05476P6Z>")
if text != "That should be posted in" {
t.Error("Bare channels failed")
}
text = parseText("That should be posted in <#C05476P6Z|random>")
if text != "That should be posted in #random" {
t.Error("Channel with name failed")
}
text = parseText("That sounds like something for <@U06CTQTRU|myles>")
if text != "That sounds like something for @myles" {
t.Error("User with name failed")
}
text = parseText("That sounds like something for <@W06CTQTRU|myles>")
if text != "That sounds like something for @myles" {
t.Error("User with name failed")
}
text = parseText("That sounds like something for <@myles>")
if text != "That sounds like something for @myles" {
t.Error("User with with no id failed")
}
}