-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
153 lines (132 loc) Β· 4.03 KB
/
main_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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func HandleInputWithoutSingleEmoji(t *testing.T) {
testCases := []struct {
input string
output string
}{
{"no emoji :(", "no emoji :("},
}
for _, tc := range testCases {
assert.Equal(t, processConvert(tc.input), tc.output)
}
}
func HandleInputWithSingleEmoji(t *testing.T) {
testCases := []struct {
input string
output string
}{
{"an emoji :grin:", "an emoji π"},
}
for _, tc := range testCases {
assert.Equal(t, processConvert(tc.input), tc.output)
}
}
func HandleInputWithLotOfEmojis(t *testing.T) {
testCases := []struct {
input string
output string
}{
{"emojis :grin::grin: :tada:yay:champagne:", "emojis ππ πyayπΎ"},
}
for _, tc := range testCases {
assert.Equal(t, processConvert(tc.input), tc.output)
}
}
func HandleEmojisWithUnderScoresAndNumbers(t *testing.T) {
testCases := []struct {
input string
output string
}{
{"this is perfect :100: :1st_place_medal:", "this is perfect π― π₯"},
}
for _, tc := range testCases {
assert.Equal(t, processConvert(tc.input), tc.output)
}
}
func HandleEmojisWithPlusMinus(t *testing.T) {
testCases := []struct {
input string
output string
}{
{"great :+1::+1::-1:", "great πππ"},
}
for _, tc := range testCases {
assert.Equal(t, processConvert(tc.input), tc.output)
}
}
func HandleRightHandSideEmojis(t *testing.T) {
testCases := []struct {
input string
output string
}{
{":not_an_emoji:point_right:", ":not_an_emojiπ"},
{"::::point_right:", ":::π"},
}
for _, tc := range testCases {
assert.Equal(t, processConvert(tc.input), tc.output)
}
}
func HandlePunctuationsJustAfterAliases(t *testing.T) {
testCases := []struct {
input string
output string
}{
{"Enter the :airplane:!", "Enter the βοΈ!"},
}
for _, tc := range testCases {
assert.Equal(t, processConvert(tc.input), tc.output)
}
}
func IgnoreExistingUnicodeEmoji(t *testing.T) {
testCases := []struct {
input string
output string
}{
{"π leave the emojis alone!!", "π leave the emojis alone!!"},
}
for _, tc := range testCases {
assert.Equal(t, processConvert(tc.input), tc.output)
}
}
func HandleMultipleSpacesAfterEmoji(t *testing.T) {
testCases := []struct {
input string
output string
}{
{":sparkles: Three spaces", "β¨ Three spaces"},
{":sparkles: Five spaces", "β¨ Five spaces"},
{":sparkles: One space", "β¨ One space"},
}
for _, tc := range testCases {
assert.Equal(t, processConvert(tc.input), tc.output)
}
}
func HandleExampleReadme(t *testing.T) {
testCases := []struct {
input string
output string
}{
{"Hey, I just :raising_hand: you, and this is :scream: , but here's my :calling: , so :telephone_receiver: me, maybe?", "Hey, I just π you, and this is π± , but here's my π² , so π me, maybe?"},
{"To :bee: , or not to :bee: : that is the question... To take :muscle: against a :ocean: of troubles, and by opposing, end them?", "To π , or not to π : that is the question... To take πͺ against a π of troubles, and by opposing, end them?"},
}
for _, tc := range testCases {
assert.Equal(t, processConvert(tc.input), tc.output)
}
}
func TestGoemojifyTestSuite(t *testing.T) {
GetEmojiDB()
t.Run("handles an input without a single emoji πΏ", HandleInputWithoutSingleEmoji)
t.Run("handles an input with a single emoji πΉ", HandleInputWithSingleEmoji)
t.Run("handles an input with a lot of emojis π»", HandleInputWithLotOfEmojis)
t.Run("handles emojis with underscores and numbers π―", HandleEmojisWithUnderScoresAndNumbers)
t.Run("handles emojis with + and - π", HandleEmojisWithPlusMinus)
t.Run("handles right-hand side emojis π", HandleRightHandSideEmojis)
t.Run("handles punctuations just after aliases", HandlePunctuationsJustAfterAliases)
t.Run("ignores existing unicode emoji characters", IgnoreExistingUnicodeEmoji)
t.Run("handles multiple spaces after an emoji", HandleMultipleSpacesAfterEmoji)
t.Run("handles the examples from the readme π", HandleExampleReadme)
}