summaryrefslogtreecommitdiffstats
path: root/webapp/tests/emoticons.test.jsx
blob: bf025e6b217893141d15d73746eb4ad9f7a2708b (plain)
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
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import assert from 'assert';

import EmojiStore from 'stores/emoji_store.jsx';
import * as Emoticons from 'utils/emoticons.jsx';

describe('Emoticons', function() {
    this.timeout(100000);

    it('handleEmoticons', function(done) {
        const emojis = EmojiStore.getEmojis();

        assert.equal(
            Emoticons.handleEmoticons(':goat: :dash:', new Map(), emojis),
            'MM_EMOTICON0 MM_EMOTICON1',
            'should replace emoticons with tokens'
        );

        assert.equal(
            Emoticons.handleEmoticons(':goat::dash:', new Map(), emojis),
            'MM_EMOTICON0MM_EMOTICON1',
            'should replace emoticons not separated by whitespace'
        );

        assert.equal(
            Emoticons.handleEmoticons('/:goat:..:dash:)', new Map(), emojis),
            '/MM_EMOTICON0..MM_EMOTICON1)',
            'should replace emoticons separated by punctuation'
        );

        assert.equal(
            Emoticons.handleEmoticons('asdf:goat:asdf:dash:asdf', new Map(), emojis),
            'asdfMM_EMOTICON0asdfMM_EMOTICON1asdf',
            'should replace emoticons separated by text'
        );

        assert.equal(
            Emoticons.handleEmoticons(':asdf: :goat : : dash:', new Map(), emojis),
            ':asdf: :goat : : dash:',
            'shouldn\'t replace invalid emoticons'
        );

        done();
    });
});