mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-10-28 11:42:29 +01:00
* fix(various): correct issues from PRs rollout 1. Send Gems modal opens from profiles again 2. Contributor titles appear on hover again 3. Tags dropdown in tasks appears again 4. Only user's own @mentions get highlighted again * fix(test): correct order of css classes in expect
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
import {highlightUsers} from '../../../../../website/client/libs/highlightUsers';
|
|
import habiticaMarkdown from 'habitica-markdown';
|
|
|
|
describe('highlightUserAndEmail', () => {
|
|
it('highlights displayname', () => {
|
|
const text = 'hello @displayedUser with text after';
|
|
|
|
const result = highlightUsers(text, 'user', 'displayedUser');
|
|
|
|
expect(result).to.contain('<span class="at-text at-highlight">@displayedUser</span>');
|
|
});
|
|
|
|
it('highlights username', () => {
|
|
const text = 'hello @user';
|
|
|
|
const result = highlightUsers(text, 'user', 'displayedUser');
|
|
expect(result).to.contain('<span class="at-text at-highlight">@user</span>');
|
|
});
|
|
|
|
it('not highlights any email', () => {
|
|
const text = habiticaMarkdown.render('hello@example.com');
|
|
|
|
const result = highlightUsers(text, 'example', 'displayedUser');
|
|
expect(result).to.not.contain('<span class="at-highlight">@example</span>');
|
|
});
|
|
|
|
|
|
it('complex highlight', () => {
|
|
const plainText = 'a bit more @mentions to @use my@mentions.com broken.@mail.com';
|
|
|
|
const text = habiticaMarkdown.render(plainText);
|
|
|
|
const result = highlightUsers(text, 'use', 'mentions');
|
|
|
|
expect(result).to.contain('<span class="at-text at-highlight">@mentions</span>');
|
|
expect(result).to.contain('<span class="at-text at-highlight">@use</span>');
|
|
expect(result).to.not.contain('<span class="at-text at-highlight">@mentions</span>.com');
|
|
});
|
|
});
|