From 670bfbf62686ebe9f2ab332733d851a62b6950b0 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Mon, 4 Sep 2017 05:48:17 -0400 Subject: PLT-7518 Added unit tests for channel linking (#7352) * PLT-7518 Added unit tests for channel linking * Removed unused escaping function --- .../tests/utils/formatting_channel_links.test.jsx | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 webapp/tests/utils/formatting_channel_links.test.jsx (limited to 'webapp/tests') 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(), + '

~123

' + ); + + assert.equal( + TextFormatting.formatText('~town-square').trim(), + '

~town-square

' + ); + + done(); + }); + + it('Channel links', (done) => { + assert.equal( + TextFormatting.formatText('~town-square', { + channelNamesMap: {'town-square': {display_name: 'Town Square'}}, + team: {name: 'myteam'} + }).trim(), + '

~Town Square

' + ); + assert.equal( + TextFormatting.formatText('~town-square.', { + channelNamesMap: {'town-square': {display_name: 'Town Square'}}, + team: {name: 'myteam'} + }).trim(), + '

~Town Square.

' + ); + + assert.equal( + TextFormatting.formatText('~town-square', { + channelNamesMap: {'town-square': {display_name: 'Reception'}}, + team: {name: 'myteam'} + }).trim(), + '

~<b>Reception</b>

' + ); + + done(); + }); +}); -- cgit v1.2.3-1-g7c22