Merge "Define 'MW_UPDATER' when running update.php"
[mediawiki.git] / tests / qunit / suites / resources / mediawiki.api / mediawiki.api.parse.test.js
blob2bed9b9fc2fb913dc77c41f2f2d85da02e360490
1 ( function ( mw, $ ) {
2         QUnit.module( 'mediawiki.api.parse', QUnit.newMwEnvironment() );
4         QUnit.asyncTest( 'Hello world', function ( assert ) {
5                 var api;
6                 QUnit.expect( 6 );
8                 api = new mw.Api();
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(),
16                                         res = $res.get( 0 );
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' );
25                                 QUnit.start();
26                         } );
27         } );
28 }( mediaWiki, jQuery ) );