Debian Codegraph @

helpers/emoji_test.go

raw
1 // Copyright 2016 The Hugo Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 package helpers
14
15 import (
16 "reflect"
17 "testing"
18 )
19
20 func TestEmojiCustom(t *testing.T) {
21 for i, this := range []struct {
22 input string
23 expect []byte
24 }{
25 {"A :smile: a day", []byte("A πŸ˜„ a day")},
26 {"A few :smile:s a day", []byte("A few πŸ˜„s a day")},
27 {"A :smile: and a :beer: makes the day for sure.", []byte("A πŸ˜„ and a 🍺 makes the day for sure.")},
28 {"A :smile: and: a :beer:", []byte("A πŸ˜„ and: a 🍺")},
29 {"A :diamond_shape_with_a_dot_inside: and then some.", []byte("A πŸ’  and then some.")},
30 {":smile:", []byte("πŸ˜„")},
31 {":smi", []byte(":smi")},
32 {"A :smile:", []byte("A πŸ˜„")},
33 {":beer:!", []byte("🍺!")},
34 {"::smile:", []byte(":πŸ˜„")},
35 {":beer::", []byte("🍺:")},
36 {" :beer: :", []byte(" 🍺 :")},
37 {":beer: and :smile: and another :beer:!", []byte("🍺 and πŸ˜„ and another 🍺!")},
38 {" :beer: : ", []byte(" 🍺 : ")},
39 {"No smiles for you!", []byte("No smiles for you!")},
40 {" The motto: no smiles! ", []byte(" The motto: no smiles! ")},
41 {":hugo_is_the_best_static_gen:", []byte(":hugo_is_the_best_static_gen:")},
42 {"은행 :smile: 은행", []byte("은행 πŸ˜„ 은행")},
43 // #2198
44 {"See: A :beer:!", []byte("See: A 🍺!")},
45 {`Aaaaaaaaaa: aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa.
46
47 :beer:`, []byte(`Aaaaaaaaaa: aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa.
48
49 🍺`)},
50 {"test :\n```bash\nthis is a test\n```\n\ntest\n\n:cool::blush:::pizza:\\:blush : : blush: :pizza:", []byte("test :\n```bash\nthis is a test\n```\n\ntest\n\nπŸ†’πŸ˜Š:πŸ•\\:blush : : blush: πŸ•")},
51 {
52 // 2391
53 "[a](http://gohugo.io) :smile: [r](http://gohugo.io/introduction/overview/) :beer:",
54 []byte(`[a](http://gohugo.io) πŸ˜„ [r](http://gohugo.io/introduction/overview/) 🍺`),
55 },
56 } {
57
58 result := Emojify([]byte(this.input))
59
60 if !reflect.DeepEqual(result, this.expect) {
61 t.Errorf("[%d] got %q but expected %q", i, result, this.expect)
62 }
63
64 }
65 }