summaryrefslogtreecommitdiffstats
path: root/webapp/tests
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-09-04 05:48:17 -0400
committerGeorge Goldberg <george@gberg.me>2017-09-04 10:48:17 +0100
commit670bfbf62686ebe9f2ab332733d851a62b6950b0 (patch)
treea2684d469c3a08e9facb8870d2ff1667cc324f24 /webapp/tests
parent8391ef62886bccba02cf1fd7a87bee75bd521366 (diff)
downloadchat-670bfbf62686ebe9f2ab332733d851a62b6950b0.tar.gz
chat-670bfbf62686ebe9f2ab332733d851a62b6950b0.tar.bz2
chat-670bfbf62686ebe9f2ab332733d851a62b6950b0.zip
PLT-7518 Added unit tests for channel linking (#7352)
* PLT-7518 Added unit tests for channel linking * Removed unused escaping function
Diffstat (limited to 'webapp/tests')
-rw-r--r--webapp/tests/utils/formatting_channel_links.test.jsx49
1 files changed, 49 insertions, 0 deletions
diff --git a/webapp/tests/utils/formatting_channel_links.test.jsx b/webapp/tests/utils/formatting_channel_links.test.jsx
new file mode 100644
index 000000000..39dddf008
--- /dev/null
+++ b/webapp/tests/utils/formatting_channel_links.test.jsx
@@ -0,0 +1,49 @@
+// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+import assert from 'assert';
+
+import * as TextFormatting from 'utils/text_formatting.jsx';
+
+describe('TextFormatting.ChannelLinks', () => {
+ it('Not channel links', (done) => {
+ assert.equal(
+ TextFormatting.formatText('~123').trim(),
+ '<p>~123</p>'
+ );
+
+ assert.equal(
+ TextFormatting.formatText('~town-square').trim(),
+ '<p>~town-square</p>'
+ );
+
+ done();
+ });
+
+ it('Channel links', (done) => {
+ assert.equal(
+ TextFormatting.formatText('~town-square', {
+ channelNamesMap: {'town-square': {display_name: 'Town Square'}},
+ team: {name: 'myteam'}
+ }).trim(),
+ '<p><a class="mention-link" href="/myteam/channels/town-square" data-channel-mention="town-square">~Town Square</a></p>'
+ );
+ assert.equal(
+ TextFormatting.formatText('~town-square.', {
+ channelNamesMap: {'town-square': {display_name: 'Town Square'}},
+ team: {name: 'myteam'}
+ }).trim(),
+ '<p><a class="mention-link" href="/myteam/channels/town-square" data-channel-mention="town-square">~Town Square</a>.</p>'
+ );
+
+ assert.equal(
+ TextFormatting.formatText('~town-square', {
+ channelNamesMap: {'town-square': {display_name: '<b>Reception</b>'}},
+ team: {name: 'myteam'}
+ }).trim(),
+ '<p><a class="mention-link" href="/myteam/channels/town-square" data-channel-mention="town-square">~&lt;b&gt;Reception&lt;/b&gt;</a></p>'
+ );
+
+ done();
+ });
+});