6
6
* later version: http://www.gnu.org/licenses/gpl-2.0.txt
7
7
*/
8
8
9
+ import * as ReactDOMServer from 'react-dom/server' ;
9
10
import test from 'tape' ;
10
11
11
12
import formatDate from '../common/utility/formatDate' ;
@@ -15,6 +16,7 @@ import compareDates, {
15
16
compareDatePeriods ,
16
17
} from '../common/utility/compareDates' ;
17
18
import formatDatePeriod from '../common/utility/formatDatePeriod' ;
19
+ import formatSetlist from '../common/utility/formatSetlist' ;
18
20
import formatTrackLength from '../common/utility/formatTrackLength' ;
19
21
import parseDate from '../common/utility/parseDate' ;
20
22
import * as dates from '../edit/utility/dates' ;
@@ -563,3 +565,40 @@ test('formatUserDate', function (t) {
563
565
'%H ranges from 00-23' ,
564
566
) ;
565
567
} ) ;
568
+
569
+ test ( 'formatSetlist' , function ( t ) {
570
+ t . plan ( 1 ) ;
571
+
572
+ const setlist =
573
+ '@ pre-text [e1af2f0d-c685-4e83-a27d-b27e79787aab|artist 1] mid-text ' +
574
+ '[0eda70b7-c77b-4775-b1db-5b0e5a3ca4c1|artist 2] post-text\n\r\n' +
575
+ '* e [b831b5a4-e1a9-4516-bb50-b6eed446fc9b|work 1] [not a link]\r' +
576
+ '@ plain text artist\n' +
577
+ '# comment [b831b5a4-e1a9-4516-bb50-b6eed446fc9b|not a link]\r\n' +
578
+ '# comment <a href="#">also not a link</a>\r\n' +
579
+ '@ nor a link <a href="#">here</a>\n\r' +
580
+ '* plain text work\n' +
581
+ 'ignored!\r\n' ;
582
+
583
+ t . equal (
584
+ ReactDOMServer . renderToStaticMarkup ( formatSetlist ( setlist ) ) ,
585
+ 'pre-text <strong>' +
586
+ 'Artist: ' +
587
+ '<a href="/artist/e1af2f0d-c685-4e83-a27d-b27e79787aab">artist 1</a>' +
588
+ '</strong> mid-text ' +
589
+ '<strong>Artist: ' +
590
+ '<a href="/artist/0eda70b7-c77b-4775-b1db-5b0e5a3ca4c1">artist 2</a>' +
591
+ '</strong> post-text<br/><br/>' +
592
+ 'e <a href="/work/b831b5a4-e1a9-4516-bb50-b6eed446fc9b">work 1</a> ' +
593
+ '[not a link]<br/>' +
594
+ 'plain text artist<br/>' +
595
+ '<span class="comment">' +
596
+ 'comment [b831b5a4-e1a9-4516-bb50-b6eed446fc9b|not a link]' +
597
+ '</span><br/>' +
598
+ '<span class="comment">' +
599
+ 'comment <a href="#">also not a link</a>' +
600
+ '</span><br/>' +
601
+ 'nor a link <a href="#">here</a><br/>' +
602
+ 'plain text work<br/><br/><br/>' ,
603
+ ) ;
604
+ } ) ;
0 commit comments