|
2742 | 2742 | done(); |
2743 | 2743 | })); |
2744 | 2744 |
|
| 2745 | + it("parses for mentions as indicated with an @ preceded by a space or at the start of the text", |
| 2746 | + mock.initConverse( |
| 2747 | + null, ['rosterGroupsFetched'], {}, |
| 2748 | + async function (done, _converse) { |
| 2749 | + |
| 2750 | + await test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'tom'); |
| 2751 | + const view = _converse.api.chatviews.get('lounge@localhost'); |
| 2752 | + ['NotAnAdress', 'darnuria'].forEach((nick) => { |
| 2753 | + _converse.connection._dataRecv(test_utils.createRequest( |
| 2754 | + $pres({ |
| 2755 | + 'to': 'tom@localhost/resource', |
| 2756 | + 'from': `lounge@localhost/${nick}` |
| 2757 | + }) |
| 2758 | + .c('x', {xmlns: Strophe.NS.MUC_USER}) |
| 2759 | + .c('item', { |
| 2760 | + 'affiliation': 'none', |
| 2761 | + 'jid': `${nick.replace(/\s/g, '-')}@localhost/resource`, |
| 2762 | + 'role': 'participant' |
| 2763 | + }))); |
| 2764 | + }); |
| 2765 | + |
| 2766 | + // Test that we don't match @nick in email adresses. |
| 2767 | + let [text, references] = view.model.parseTextForReferences('contact contact@NotAnAdress.eu'); |
| 2768 | + expect(references.length).toBe(0); |
| 2769 | + expect(text).toBe('contact contact@NotAnAdress.eu'); |
| 2770 | + |
| 2771 | + // Test that we don't match @nick in url |
| 2772 | + [text, references] = view.model.parseTextForReferences('nice website https://darnuria.eu/@darnuria'); |
| 2773 | + expect(references.length).toBe(0); |
| 2774 | + expect(text).toBe('nice website https://darnuria.eu/@darnuria'); |
| 2775 | + |
| 2776 | + done(); |
| 2777 | + })); |
| 2778 | + |
2745 | 2779 | it("can get corrected and given new references", |
2746 | 2780 | mock.initConverse( |
2747 | 2781 | null, ['rosterGroupsFetched'], {}, |
|
0 commit comments