summaryrefslogtreecommitdiffstats
path: root/webapp/tests
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-05-16 15:54:24 -0400
committerChristopher Speller <crspeller@gmail.com>2016-05-16 15:54:24 -0400
commit1b9deb43925393a52b03cd43bb733e9e602c1483 (patch)
tree74b2e780692838cdd6540493c7c694c954bd3f60 /webapp/tests
parent1f609e9cf799ddb6bedd5fe3c0eeb36b92ed243d (diff)
downloadchat-1b9deb43925393a52b03cd43bb733e9e602c1483.tar.gz
chat-1b9deb43925393a52b03cd43bb733e9e602c1483.tar.bz2
chat-1b9deb43925393a52b03cd43bb733e9e602c1483.zip
Changed named emoticons to not require surrounding whitespace and added unit tests (#3009)
Diffstat (limited to 'webapp/tests')
-rw-r--r--webapp/tests/emoticons.test.jsx44
1 files changed, 44 insertions, 0 deletions
diff --git a/webapp/tests/emoticons.test.jsx b/webapp/tests/emoticons.test.jsx
new file mode 100644
index 000000000..bb0421651
--- /dev/null
+++ b/webapp/tests/emoticons.test.jsx
@@ -0,0 +1,44 @@
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import assert from 'assert';
+
+import * as Emoticons from 'utils/emoticons.jsx';
+
+describe('Emoticons', function() {
+ this.timeout(100000);
+
+ it('handleEmoticons', function(done) {
+ assert.equal(
+ Emoticons.handleEmoticons(':goat: :dash:', new Map()),
+ 'MM_EMOTICON0 MM_EMOTICON1',
+ 'should replace emoticons with tokens'
+ );
+
+ assert.equal(
+ Emoticons.handleEmoticons(':goat::dash:', new Map()),
+ 'MM_EMOTICON0MM_EMOTICON1',
+ 'should replace emoticons not separated by whitespace'
+ );
+
+ assert.equal(
+ Emoticons.handleEmoticons('/:goat:..:dash:)', new Map()),
+ '/MM_EMOTICON0..MM_EMOTICON1)',
+ 'should replace emoticons separated by punctuation'
+ );
+
+ assert.equal(
+ Emoticons.handleEmoticons('asdf:goat:asdf:dash:asdf', new Map()),
+ 'asdfMM_EMOTICON0asdfMM_EMOTICON1asdf',
+ 'should replace emoticons separated by text'
+ );
+
+ assert.equal(
+ Emoticons.handleEmoticons(':asdf: :goat : : dash:', new Map()),
+ ':asdf: :goat : : dash:',
+ 'shouldn\'t replace invalid emoticons'
+ );
+
+ done();
+ });
+}); \ No newline at end of file