@@ -5,11 +5,13 @@ describe( "Autolinker Mention Matching -", () => {
55 const twitterAutolinker = new Autolinker ( { mention : 'twitter' , newWindow : false } )
66 const instagramAutolinker = new Autolinker ( { mention : 'instagram' , newWindow : false } ) ;
77 const soundcloudAutolinker = new Autolinker ( { mention : 'soundcloud' , newWindow : false } ) ;
8+ const tiktokAutolinker = new Autolinker ( { mention : 'soundcloud' , newWindow : false } ) ;
89
910 const services = [
1011 { serviceName : 'twitter' , urlPrefix : 'https://twitter.com' , autolinker : twitterAutolinker } ,
1112 { serviceName : 'instagram' , urlPrefix : 'https://instagram.com' , autolinker : instagramAutolinker } ,
1213 { serviceName : 'soundcloud' , urlPrefix : 'https://soundcloud.com' , autolinker : soundcloudAutolinker } ,
14+ { serviceName : 'tiktok' , urlPrefix : 'https://www.tiktok.com/@' , autolinker : tiktokAutolinker } ,
1315 ] ;
1416
1517 it ( `should not autolink mentions by default` , ( ) => {
@@ -215,6 +217,25 @@ describe( "Autolinker Mention Matching -", () => {
215217
216218 } ) ;
217219
220+ describe ( 'tiktok-specific tests' , ( ) => {
221+
222+ it ( 'should link a tiktok mention that is up to 24 characters long' , ( ) => {
223+ const aUsername = _ . repeat ( 'a' , 24 ) ;
224+ const bUsername = _ . repeat ( 'b' , 25 ) ; // too long - don't link
225+
226+ const result = tiktokAutolinker . link ( `@${ aUsername } and @${ bUsername } ` ) ;
227+ expect ( result ) . toBe ( `<a href="https://www.tiktok.com/@${ aUsername } ">@${ aUsername } </a> and @${ bUsername } ` ) ;
228+ } ) ;
229+
230+
231+ it ( `should link a tiktok mention that has a period in it` , ( ) => {
232+ const result = tiktokAutolinker . link ( `Hello @asdf.defg` ) ;
233+
234+ expect ( result ) . toBe ( `Hello <a href="https://www.tiktok.com/@asdf.defg">@asdf.defg</a>` ) ;
235+ } ) ;
236+
237+ } ) ;
238+
218239
219240 it ( `should NOT automatically link a username that is actually part of an
220241 email address when email address linking is turned on
0 commit comments