| 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 |
} |