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('@displayedUser'); }); it('highlights username', () => { const text = 'hello @user'; const result = highlightUsers(text, 'user', 'displayedUser'); expect(result).to.contain('@user'); }); it('not highlights any email', () => { const text = habiticaMarkdown.render('hello@example.com'); const result = highlightUsers(text, 'example', 'displayedUser'); expect(result).to.not.contain('@example'); }); 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('@mentions'); expect(result).to.contain('@use'); expect(result).to.not.contain('@mentions.com'); }); });