forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix at mention rendering when multiple at mentions pattern are typed …
…without space in between (mattermost#1700)
- Loading branch information
1 parent
75b44d4
commit 1b1e4a2
Showing
2 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,21 @@ describe('TextFormatting.AtMentions', function() { | |
'$MM_ATMENTION0$', | ||
'should capture trailing punctuation as part of mention' | ||
); | ||
assert.equal( | ||
TextFormatting.autolinkAtMentions('@foo.com @bar.com', new Map()), | ||
'$MM_ATMENTION0$ $MM_ATMENTION1$', | ||
'should capture two at mentions with space in between' | ||
); | ||
assert.equal( | ||
TextFormatting.autolinkAtMentions('@[email protected]', new Map()), | ||
'$MM_ATMENTION0$$MM_ATMENTION1$', | ||
'should capture two at mentions without space in between' | ||
); | ||
assert.equal( | ||
TextFormatting.autolinkAtMentions('@[email protected]@baz.com', new Map()), | ||
'$MM_ATMENTION0$$MM_ATMENTION1$$MM_ATMENTION2$', | ||
'should capture multiple at mentions without space in between' | ||
); | ||
}); | ||
|
||
it('Not at mentions', function() { | ||
|
@@ -82,5 +97,45 @@ describe('TextFormatting.AtMentions', function() { | |
TextFormatting.formatText('@ALL', {atMentions: true, mentionKeys: [{key: '@all'}]}).trim(), | ||
'<p><span class=\'mention--highlight\'><span data-mention="ALL">@ALL</span></span></p>', | ||
); | ||
assert.equal( | ||
TextFormatting.formatText('@foo.com', {atMentions: true, mentionKeys: [{key: '@foo.com'}]}).trim(), | ||
'<p><span class=\'mention--highlight\'><span data-mention="foo.com">@foo.com</span></span></p>', | ||
); | ||
assert.equal( | ||
TextFormatting.formatText('@foo.com @bar.com', {atMentions: true, mentionKeys: [{key: '@foo.com'}, {key: '@bar.com'}]}).trim(), | ||
'<p><span class=\'mention--highlight\'><span data-mention="foo.com">@foo.com</span></span> <span class=\'mention--highlight\'><span data-mention="bar.com">@bar.com</span></span></p>', | ||
); | ||
assert.equal( | ||
TextFormatting.formatText('@[email protected]', {atMentions: true, mentionKeys: [{key: '@foo.com'}, {key: '@bar.com'}]}).trim(), | ||
'<p><span class=\'mention--highlight\'><span data-mention="foo.com">@foo.com</span></span><span class=\'mention--highlight\'><span data-mention="bar.com">@bar.com</span></span></p>', | ||
); | ||
}); | ||
|
||
it('Mix highlight at mentions', function() { | ||
assert.equal( | ||
TextFormatting.formatText('@foo.com @bar.com', {atMentions: true, mentionKeys: [{key: '@foo.com'}]}).trim(), | ||
'<p><span class=\'mention--highlight\'><span data-mention="foo.com">@foo.com</span></span> <span data-mention="bar.com">@bar.com</span></p>', | ||
'should highlight first at mention, with space in between' | ||
); | ||
assert.equal( | ||
TextFormatting.formatText('@foo.com @bar.com', {atMentions: true, mentionKeys: [{key: '@bar.com'}]}).trim(), | ||
'<p><span data-mention="foo.com">@foo.com</span> <span class=\'mention--highlight\'><span data-mention="bar.com">@bar.com</span></span></p>', | ||
'should highlight second at mention, with space in between' | ||
); | ||
assert.equal( | ||
TextFormatting.formatText('@[email protected]', {atMentions: true, mentionKeys: [{key: '@foo.com'}]}).trim(), | ||
'<p><span class=\'mention--highlight\'><span data-mention="foo.com">@foo.com</span></span><span data-mention="bar.com">@bar.com</span></p>', | ||
'should highlight first at mention, without space in between' | ||
); | ||
assert.equal( | ||
TextFormatting.formatText('@[email protected]', {atMentions: true, mentionKeys: [{key: '@bar.com'}]}).trim(), | ||
'<p><span data-mention="foo.com">@foo.com</span><span class=\'mention--highlight\'><span data-mention="bar.com">@bar.com</span></span></p>', | ||
'should highlight second at mention, without space in between' | ||
); | ||
assert.equal( | ||
TextFormatting.formatText('@[email protected]', {atMentions: true, mentionKeys: [{key: '@user'}]}).trim(), | ||
'<p><span data-mention="foo.com">@foo.com</span><span data-mention="bar.com">@bar.com</span></p>', | ||
'should not highlight any at mention' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters