2014-06-11 04:34:49 +00:00
|
|
|
( function ( $, mw ) {
|
|
|
|
|
2015-08-11 13:45:24 +00:00
|
|
|
QUnit.module( 'ext.popups.renderer.renderers.article', QUnit.newMwEnvironment() );
|
2015-03-25 20:53:27 +00:00
|
|
|
|
2014-12-02 08:08:47 +00:00
|
|
|
QUnit.test( 'render.article.getProcessedElements', function ( assert ) {
|
2015-03-26 08:12:01 +00:00
|
|
|
QUnit.expect( 13 );
|
2014-06-11 04:34:49 +00:00
|
|
|
|
2015-08-26 10:15:16 +00:00
|
|
|
function test( extract, title, expected, msg ) {
|
2014-12-02 08:08:47 +00:00
|
|
|
var $div = $( '<div>' ).append(
|
2015-08-11 13:45:24 +00:00
|
|
|
mw.popups.render.renderers.article.getProcessedElements( extract, title )
|
2014-06-11 04:34:49 +00:00
|
|
|
);
|
2014-12-02 08:08:47 +00:00
|
|
|
assert.equal( $div.html(), expected, msg );
|
2014-06-11 04:34:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test(
|
|
|
|
'Isaac Newton was born in', 'Isaac Newton',
|
2014-12-02 08:08:47 +00:00
|
|
|
'<b>Isaac Newton</b> was born in',
|
|
|
|
'Title as first word'
|
2014-06-11 04:34:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
'The C* language not to be confused with C# or C', 'C*',
|
2014-12-02 08:08:47 +00:00
|
|
|
'The <b>C*</b> language not to be confused with C# or C',
|
|
|
|
'Title containing *'
|
2014-06-11 04:34:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
'Person (was born in Location) is good', 'Person',
|
2014-12-02 08:08:47 +00:00
|
|
|
'<b>Person</b> is good',
|
|
|
|
'Extract with text in parentheses'
|
2014-06-11 04:34:49 +00:00
|
|
|
);
|
|
|
|
|
2015-01-02 10:57:35 +00:00
|
|
|
test(
|
|
|
|
'Person, (was born in Location) is good', 'Person',
|
|
|
|
'<b>Person</b>, is good',
|
|
|
|
'Comma after title'
|
|
|
|
);
|
|
|
|
|
2014-06-11 04:34:49 +00:00
|
|
|
test(
|
|
|
|
'Person (was born in Location (at Time)) is good', 'Person',
|
2014-12-02 08:08:47 +00:00
|
|
|
'<b>Person</b> is good',
|
|
|
|
'Extract with nested parentheses'
|
2014-06-11 04:34:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
'Person (was born in Location (at Time) ) is good', 'Person',
|
2014-12-02 08:08:47 +00:00
|
|
|
'<b>Person</b> is good',
|
|
|
|
'Extract with nested parentheses and random spaces'
|
2014-06-11 04:34:49 +00:00
|
|
|
);
|
|
|
|
|
2015-01-02 10:57:35 +00:00
|
|
|
test(
|
|
|
|
'I like trains', 'Train',
|
|
|
|
'I like <b>train</b>s',
|
|
|
|
'Make the simple plural bold'
|
|
|
|
);
|
|
|
|
|
2014-06-11 04:34:49 +00:00
|
|
|
test(
|
|
|
|
'Brackets ) are funny ( when not used properly', 'Brackets',
|
2014-12-02 08:08:47 +00:00
|
|
|
'<b>Brackets</b> ) are funny ( when not used properly',
|
|
|
|
'Extract with unbalanced parentheses'
|
2014-06-11 04:34:49 +00:00
|
|
|
);
|
|
|
|
|
2015-01-02 11:31:12 +00:00
|
|
|
test(
|
|
|
|
'Vappu (born August 7), also known as Lexy', 'Vappu',
|
|
|
|
'<b>Vappu</b>, also known as Lexy',
|
|
|
|
'Spaces around bracketed text should be removed'
|
|
|
|
);
|
|
|
|
|
2014-11-26 02:21:03 +00:00
|
|
|
test(
|
|
|
|
'Epic XSS <script>alert("XSS")</script> is epic', 'Epic XSS',
|
2014-12-02 08:08:47 +00:00
|
|
|
'<b>Epic XSS</b> <script>alert</script> is epic',
|
|
|
|
'XSS Attack'
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
'Foo\'s pub is a pub in Bar', 'Foo\'s pub',
|
2015-03-26 08:12:01 +00:00
|
|
|
'<b>Foo\'s pub</b> is a pub in Bar',
|
2014-12-02 08:08:47 +00:00
|
|
|
'Correct escaping'
|
|
|
|
);
|
|
|
|
|
2015-03-26 08:12:01 +00:00
|
|
|
test(
|
|
|
|
'\"Heroes\" is a David Bowie album', '\"Heroes\"',
|
|
|
|
'<b>\"Heroes\"</b> is a David Bowie album',
|
|
|
|
'Quotes in title'
|
|
|
|
);
|
|
|
|
|
2014-12-02 08:08:47 +00:00
|
|
|
test(
|
|
|
|
'*Testing if Things are correctly identified', 'Things',
|
|
|
|
'*Testing if <b>Things</b> are correctly identified',
|
|
|
|
'Article that begins with asterisk'
|
2014-11-26 02:21:03 +00:00
|
|
|
);
|
|
|
|
|
2014-06-11 04:34:49 +00:00
|
|
|
} );
|
|
|
|
|
2015-08-26 10:15:16 +00:00
|
|
|
} )( jQuery, mediaWiki );
|