mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-19 05:15:52 +00:00
a43ef7ca51
Instead of replacing all instances of the title in the extract - '$1<b>$2</b>$3' We now put symbolic strings there which we use to split the string and then make an array of text and <b> elements that get appended to $contentbox. Bug: T76378 Change-Id: I02222bbff84532f63cac67af1bf889c328ec6ff2
71 lines
1.7 KiB
JavaScript
71 lines
1.7 KiB
JavaScript
( function ( $, mw ) {
|
|
|
|
QUnit.module( 'ext.popups' );
|
|
QUnit.test( 'render.article.getProcessedElements', function ( assert ) {
|
|
QUnit.expect( 9 );
|
|
|
|
function test ( extract, title, expected, msg ) {
|
|
var $div = $( '<div>' ).append(
|
|
mw.popups.render.article.getProcessedElements( extract, title )
|
|
);
|
|
assert.equal( $div.html(), expected, msg );
|
|
}
|
|
|
|
test(
|
|
'Isaac Newton was born in', 'Isaac Newton',
|
|
'<b>Isaac Newton</b> was born in',
|
|
'Title as first word'
|
|
);
|
|
|
|
test(
|
|
'The C* language not to be confused with C# or C', 'C*',
|
|
'The <b>C*</b> language not to be confused with C# or C',
|
|
'Title containing *'
|
|
);
|
|
|
|
test(
|
|
'Person (was born in Location) is good', 'Person',
|
|
'<b>Person</b> is good',
|
|
'Extract with text in parentheses'
|
|
);
|
|
|
|
test(
|
|
'Person (was born in Location (at Time)) is good', 'Person',
|
|
'<b>Person</b> is good',
|
|
'Extract with nested parentheses'
|
|
);
|
|
|
|
test(
|
|
'Person (was born in Location (at Time) ) is good', 'Person',
|
|
'<b>Person</b> is good',
|
|
'Extract with nested parentheses and random spaces'
|
|
);
|
|
|
|
test(
|
|
'Brackets ) are funny ( when not used properly', 'Brackets',
|
|
'<b>Brackets</b> ) are funny ( when not used properly',
|
|
'Extract with unbalanced parentheses'
|
|
);
|
|
|
|
test(
|
|
'Epic XSS <script>alert("XSS")</script> is epic', 'Epic XSS',
|
|
'<b>Epic XSS</b> <script>alert</script> is epic',
|
|
'XSS Attack'
|
|
);
|
|
|
|
test(
|
|
'Foo\'s pub is a pub in Bar', 'Foo\'s pub',
|
|
'<b>Foo&#039;s pub</b> is a pub in Bar',
|
|
'Correct escaping'
|
|
);
|
|
|
|
test(
|
|
'*Testing if Things are correctly identified', 'Things',
|
|
'*Testing if <b>Things</b> are correctly identified',
|
|
'Article that begins with asterisk'
|
|
);
|
|
|
|
} );
|
|
|
|
} ) ( jQuery, mediaWiki );
|