Merge "Add GENDER support to protection null revision edit summary"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.api / mediawiki.api.parse.test.js
1 ( function ( mw ) {
2 QUnit.module( 'mediawiki.api.parse', QUnit.newMwEnvironment( {
3 setup: function () {
4 this.server = this.sandbox.useFakeServer();
5 }
6 } ) );
7
8 QUnit.test( 'Hello world', function ( assert ) {
9 QUnit.expect( 3 );
10
11 var api = new mw.Api();
12
13 api.parse( '\'\'\'Hello world\'\'\'' ).done( function ( html ) {
14 assert.equal( html, '<p><b>Hello world</b></p>', 'Parse wikitext by string' );
15 } );
16
17 api.parse( {
18 toString: function () {
19 return '\'\'\'Hello world\'\'\'';
20 }
21 } ).done( function ( html ) {
22 assert.equal( html, '<p><b>Hello world</b></p>', 'Parse wikitext by toString object' );
23 } );
24
25 this.server.respondWith( /action=parse.*&text='''Hello\+world'''/, function ( request ) {
26 request.respond( 200, { 'Content-Type': 'application/json' },
27 '{ "parse": { "text": "<p><b>Hello world</b></p>" } }'
28 );
29 } );
30
31 api.parse( new mw.Title( 'Earth' ) ).done( function ( html ) {
32 assert.equal( html, '<p><b>Earth</b> is a planet.</p>', 'Parse page by Title object' );
33 } );
34
35 this.server.respondWith( /action=parse.*&page=Earth/, function ( request ) {
36 request.respond( 200, { 'Content-Type': 'application/json' },
37 '{ "parse": { "text": "<p><b>Earth</b> is a planet.</p>" } }'
38 );
39 } );
40
41 this.server.respond();
42 } );
43 }( mediaWiki ) );