2 QUnit
.module( 'mediawiki.api.parse', QUnit
.newMwEnvironment() );
4 QUnit
.asyncTest( 'Hello world', function ( assert
) {
10 api
.parse( '\'\'\'Hello world\'\'\'' )
11 .done( function ( html
) {
12 // Parse into a document fragment instead of comparing HTML, due to
13 // presence of Tidy influencing whitespace.
14 // Html also contains "NewPP report" comment.
15 var $res
= $( '<div>' ).html( html
).children(),
17 assert
.equal( $res
.length
, 1, 'Response contains 1 element' );
18 assert
.equal( res
.nodeName
.toLowerCase(), 'p', 'Response is a paragraph' );
19 assert
.equal( $res
.children().length
, 1, 'Response has 1 child element' );
20 assert
.equal( $res
.children().get( 0 ).nodeName
.toLowerCase(), 'b', 'Child element is a bold tag' );
21 // Trim since Tidy may or may not mess with the spacing here
22 assert
.equal( $.trim( $res
.text() ), 'Hello world', 'Response contains given text' );
23 assert
.equal( $res
.find( 'b' ).text(), 'Hello world', 'Bold tag wraps the entire, same, text' );
28 }( mediaWiki
, jQuery
) );