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
48
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">~<b>Reception</b></a></p>'
);
done();
});
});
|