Skip to content

Commit a9fbdd3

Browse files
committed
Add formatSetlist test
1 parent 5605cbc commit a9fbdd3

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

root/static/scripts/tests/utility.js

+39
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* later version: http://www.gnu.org/licenses/gpl-2.0.txt
77
*/
88

9+
import * as ReactDOMServer from 'react-dom/server';
910
import test from 'tape';
1011

1112
import formatDate from '../common/utility/formatDate';
@@ -15,6 +16,7 @@ import compareDates, {
1516
compareDatePeriods,
1617
} from '../common/utility/compareDates';
1718
import formatDatePeriod from '../common/utility/formatDatePeriod';
19+
import formatSetlist from '../common/utility/formatSetlist';
1820
import formatTrackLength from '../common/utility/formatTrackLength';
1921
import parseDate from '../common/utility/parseDate';
2022
import * as dates from '../edit/utility/dates';
@@ -563,3 +565,40 @@ test('formatUserDate', function (t) {
563565
'%H ranges from 00-23',
564566
);
565567
});
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 &lt;a href=&quot;#&quot;&gt;also not a link&lt;/a&gt;' +
600+
'</span><br/>' +
601+
'nor a link &lt;a href=&quot;#&quot;&gt;here&lt;/a&gt;<br/>' +
602+
'plain text work<br/><br/><br/>',
603+
);
604+
});

0 commit comments

Comments
 (0)