2 QUnit
.module( 'mediawiki.api.parse', QUnit
.newMwEnvironment( {
4 this.server
= this.sandbox
.useFakeServer();
8 QUnit
.test( 'Hello world', function ( assert
) {
11 var api
= new mw
.Api();
13 api
.parse( '\'\'\'Hello world\'\'\'' ).done( function ( html
) {
14 assert
.equal( html
, '<p><b>Hello world</b></p>' );
17 this.server
.respondWith( /action=parse.*&text='''Hello\+world'''/, function ( request
) {
18 request
.respond( 200, { 'Content-Type': 'application/json' },
19 '{ "parse": { "text": "<p><b>Hello world</b></p>" } }'
23 api
.parse( new mw
.Title( 'Earth' ) ).done( function ( html
) {
24 assert
.equal( html
, '<p><b>Earth</b> is a planet.</p>' );
27 this.server
.respondWith( /action=parse.*&page=Earth/, function ( request
) {
28 request
.respond( 200, { 'Content-Type': 'application/json' },
29 '{ "parse": { "text": "<p><b>Earth</b> is a planet.</p>" } }'
33 this.server
.respond();