@@ -693,11 +693,10 @@ 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
- // Fixme [short-mention] this errors on "test.com</a> @test.com @test.com <a" - probably @test.com should be a legit short-mention candidate
701
700
expect ( parser . replace ( urlTestStartString ) ) . toBe ( urlTestReplacedString ) ;
702
701
} ) ;
703
702
@@ -877,7 +876,7 @@ test('Test urls autolinks correctly', () => {
877
876
{
878
877
testString : 'expensify.com -expensify.com @expensify.com' ,
879
878
resultString :
880
- '<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> ' ,
881
880
} ,
882
881
{
883
882
testString : 'https//www.expensify.com' ,
@@ -932,7 +931,6 @@ test('Test urls autolinks correctly', () => {
932
931
} ,
933
932
] ;
934
933
935
- // Fixme [short-mention] @expensify.com should now be considered a short-mention "candidate"
936
934
testCases . forEach ( ( testCase ) => {
937
935
expect ( parser . replace ( testCase . testString ) ) . toBe ( testCase . resultString ) ;
938
936
} ) ;
@@ -1327,12 +1325,6 @@ test('Test for user mention with @username@domain.com', () => {
1327
1325
expect ( parser . replace ( testString ) ) . toBe ( resultString ) ;
1328
1326
} ) ;
1329
1327
1330
- test ( 'Test for short mention mention with @username' , ( ) => {
1331
- const testString = '@john.doe' ;
1332
- const resultString = '<mention-short>@john.doe</mention-short>' ;
1333
- expect ( parser . replace ( testString ) ) . toBe ( resultString ) ;
1334
- } ) ;
1335
-
1336
1328
test ( 'Test for user mention with @@username@domain.com' , ( ) => {
1337
1329
const testString = '@@username@expensify.com' ;
1338
1330
const resultString = '@<mention-user>@username@expensify.com</mention-user>' ;
@@ -1460,6 +1452,26 @@ test('Test for @here mention with inlineCodeBlock style', () => {
1460
1452
expect ( parser . replace ( testString ) ) . toBe ( resultString ) ;
1461
1453
} ) ;
1462
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
+
1463
1475
// Examples that should match for here mentions:
1464
1476
test ( 'Test for here mention with @here' , ( ) => {
1465
1477
const testString = '@here' ;
@@ -1516,7 +1528,6 @@ test('Test for @here mention with italic, bold and strikethrough styles', () =>
1516
1528
' @here!' +
1517
1529
' @here?' ;
1518
1530
1519
- // Fixme [short-mention] these should now be short-mention candidates
1520
1531
const resultString =
1521
1532
'<mention-here>@here</mention-here>' +
1522
1533
' <em><mention-here>@here</mention-here></em>' +
@@ -1659,13 +1670,13 @@ test('Skip rendering invalid markdown', () => {
1659
1670
1660
1671
test ( 'Test for email with test+1@gmail.com@gmail.com' , ( ) => {
1661
1672
const testString = 'test+1@gmail.com@gmail.com' ;
1662
- 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> ' ;
1663
1674
expect ( parser . replace ( testString ) ) . toBe ( resultString ) ;
1664
1675
} ) ;
1665
1676
1666
1677
test ( 'Test for email with test@gmail.com@gmail.com' , ( ) => {
1667
1678
const testString = 'test@gmail.com@gmail.com' ;
1668
- 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> ' ;
1669
1680
expect ( parser . replace ( testString ) ) . toBe ( resultString ) ;
1670
1681
} ) ;
1671
1682
0 commit comments