|
1 |
| -/* eslint-disable max-len */ |
| 1 | +/* eslint-disable max-len,no-useless-concat */ |
2 | 2 | import ExpensiMark from '../lib/ExpensiMark';
|
3 | 3 |
|
4 | 4 | const parser = new ExpensiMark();
|
@@ -693,9 +693,9 @@ test('Test url replacements', () => {
|
693 | 693 | '<a href="http://example.com/foo/*/bar/*/test.txt" target="_blank" rel="noreferrer noopener">http://example.com/foo/*/bar/*/test.txt</a> ' +
|
694 | 694 | 'test-.com ' +
|
695 | 695 | '-<a href="https://test.com" target="_blank" rel="noreferrer noopener">test.com</a> ' +
|
696 |
| - '@test.com ' + |
697 |
| - '@test.com <a href="https://test.com" target="_blank" rel="noreferrer noopener">test.com</a> ' + |
698 |
| - '@test.com @test.com '; |
| 696 | + '<mention-short>@test.com</mention-short> ' + |
| 697 | + '<mention-short>@test.com</mention-short> <a href="https://test.com" target="_blank" rel="noreferrer noopener">test.com</a> ' + |
| 698 | + '<mention-short>@test.com</mention-short> <mention-short>@test.com</mention-short> '; |
699 | 699 |
|
700 | 700 | expect(parser.replace(urlTestStartString)).toBe(urlTestReplacedString);
|
701 | 701 | });
|
@@ -876,7 +876,7 @@ test('Test urls autolinks correctly', () => {
|
876 | 876 | {
|
877 | 877 | testString: 'expensify.com -expensify.com @expensify.com',
|
878 | 878 | resultString:
|
879 |
| - '<a href="https://expensify.com" target="_blank" rel="noreferrer noopener">expensify.com</a> -<a href="https://expensify.com" target="_blank" rel="noreferrer noopener">expensify.com</a> @expensify.com', |
| 879 | + '<a href="https://expensify.com" target="_blank" rel="noreferrer noopener">expensify.com</a> -<a href="https://expensify.com" target="_blank" rel="noreferrer noopener">expensify.com</a> <mention-short>@expensify.com</mention-short>', |
880 | 880 | },
|
881 | 881 | {
|
882 | 882 | testString: 'https//www.expensify.com',
|
@@ -1376,7 +1376,7 @@ test('Test for user mention without leading whitespace', () => {
|
1376 | 1376 |
|
1377 | 1377 | test('Test for user mention with @username@expensify', () => {
|
1378 | 1378 | const testString = '@username@expensify';
|
1379 |
| - const resultString = '@username@expensify'; |
| 1379 | + const resultString = '<mention-short>@username</mention-short><mention-short>@expensify</mention-short>'; |
1380 | 1380 | expect(parser.replace(testString)).toBe(resultString);
|
1381 | 1381 | });
|
1382 | 1382 |
|
@@ -1452,6 +1452,26 @@ test('Test for @here mention with inlineCodeBlock style', () => {
|
1452 | 1452 | expect(parser.replace(testString)).toBe(resultString);
|
1453 | 1453 | });
|
1454 | 1454 |
|
| 1455 | +describe('Tests for short mentions', () => { |
| 1456 | + test('short mentions should work for @username', () => { |
| 1457 | + const testString = '@johnny'; |
| 1458 | + const resultString = '<mention-short>@johnny</mention-short>'; |
| 1459 | + expect(parser.replace(testString)).toBe(resultString); |
| 1460 | + }); |
| 1461 | + |
| 1462 | + test('short mentions should work for @firstname.lastname', () => { |
| 1463 | + const testString = '@john.doe'; |
| 1464 | + const resultString = '<mention-short>@john.doe</mention-short>'; |
| 1465 | + expect(parser.replace(testString)).toBe(resultString); |
| 1466 | + }); |
| 1467 | + |
| 1468 | + test('short mentions should work and not break @here after mention', () => { |
| 1469 | + const testString = '@john.doe@here'; |
| 1470 | + const resultString = '<mention-short>@john.doe</mention-short><mention-here>@here</mention-here>'; |
| 1471 | + expect(parser.replace(testString)).toBe(resultString); |
| 1472 | + }); |
| 1473 | +}); |
| 1474 | + |
1455 | 1475 | // Examples that should match for here mentions:
|
1456 | 1476 | test('Test for here mention with @here', () => {
|
1457 | 1477 | const testString = '@here';
|
@@ -1650,13 +1670,13 @@ test('Skip rendering invalid markdown', () => {
|
1650 | 1670 |
|
1651 | 1671 | test('Test for email with test+1@gmail.com@gmail.com', () => {
|
1652 | 1672 | const testString = 'test+1@gmail.com@gmail.com';
|
1653 |
| - const resultString = '<a href="mailto:test+1@gmail.com">test+1@gmail.com</a>@gmail.com'; |
| 1673 | + const resultString = '<a href="mailto:test+1@gmail.com">test+1@gmail.com</a><mention-short>@gmail.com</mention-short>'; |
1654 | 1674 | expect(parser.replace(testString)).toBe(resultString);
|
1655 | 1675 | });
|
1656 | 1676 |
|
1657 | 1677 | test('Test for email with test@gmail.com@gmail.com', () => {
|
1658 | 1678 | const testString = 'test@gmail.com@gmail.com';
|
1659 |
| - const resultString = '<a href="mailto:test@gmail.com">test@gmail.com</a>@gmail.com'; |
| 1679 | + const resultString = '<a href="mailto:test@gmail.com">test@gmail.com</a><mention-short>@gmail.com</mention-short>'; |
1660 | 1680 | expect(parser.replace(testString)).toBe(resultString);
|
1661 | 1681 | });
|
1662 | 1682 |
|
|
0 commit comments