QUnit.module( 'mediawiki.api.edit', ( hooks ) => { let server; hooks.beforeEach( function () { server = this.sandbox.useFakeServer(); server.respondImmediately = true; } ); QUnit.test( '.parse( string )', async ( assert ) => { server.respondWith( 'POST', /api.php/, [ 200, { 'Content-Type': 'application/json' }, '{ "parse": { "text": "
Hello world
" } }' ] ); const html = await new mw.Api().parse( '\'\'\'Hello world\'\'\'' ); assert.strictEqual( html, 'Hello world
', 'Parse wikitext by string' ); } ); QUnit.test( '.parse( Object.toString )', async ( assert ) => { server.respondWith( 'POST', /api.php/, [ 200, { 'Content-Type': 'application/json' }, '{ "parse": { "text": "Hello world
" } }' ] ); const input = { toString: function () { return '\'\'\'Hello world\'\'\''; } }; const html = await new mw.Api().parse( input ); assert.strictEqual( html, 'Hello world
', 'Parse wikitext by toString object' ); } ); QUnit.test( '.parse( mw.Title )', async ( assert ) => { server.respondWith( 'GET', /action=parse.*&page=Earth/, [ 200, { 'Content-Type': 'application/json' }, '{ "parse": { "text": "Earth is a planet.
" } }' ] ); const html = await new mw.Api().parse( new mw.Title( 'Earth' ) ); assert.strictEqual( html, 'Earth is a planet.
', 'Parse page by Title object' ); } ); } );