diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js |
first commit
Diffstat (limited to 'www/wiki/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js')
-rw-r--r-- | www/wiki/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/www/wiki/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js b/www/wiki/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js new file mode 100644 index 00000000..74da0098 --- /dev/null +++ b/www/wiki/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js @@ -0,0 +1,45 @@ +( function ( mw ) { + QUnit.module( 'mediawiki.api.parse', QUnit.newMwEnvironment( { + setup: function () { + this.server = this.sandbox.useFakeServer(); + this.server.respondImmediately = true; + } + } ) ); + + QUnit.test( '.parse( string )', function ( assert ) { + this.server.respondWith( /action=parse.*&text='''Hello(\+|%20)world'''/, [ 200, + { 'Content-Type': 'application/json' }, + '{ "parse": { "text": "<p><b>Hello world</b></p>" } }' + ] ); + + return new mw.Api().parse( '\'\'\'Hello world\'\'\'' ).done( function ( html ) { + assert.equal( html, '<p><b>Hello world</b></p>', 'Parse wikitext by string' ); + } ); + } ); + + QUnit.test( '.parse( Object.toString )', function ( assert ) { + this.server.respondWith( /action=parse.*&text='''Hello(\+|%20)world'''/, [ 200, + { 'Content-Type': 'application/json' }, + '{ "parse": { "text": "<p><b>Hello world</b></p>" } }' + ] ); + + return new mw.Api().parse( { + toString: function () { + return '\'\'\'Hello world\'\'\''; + } + } ).done( function ( html ) { + assert.equal( html, '<p><b>Hello world</b></p>', 'Parse wikitext by toString object' ); + } ); + } ); + + QUnit.test( '.parse( mw.Title )', function ( assert ) { + this.server.respondWith( /action=parse.*&page=Earth/, [ 200, + { 'Content-Type': 'application/json' }, + '{ "parse": { "text": "<p><b>Earth</b> is a planet.</p>" } }' + ] ); + + return new mw.Api().parse( new mw.Title( 'Earth' ) ).done( function ( html ) { + assert.equal( html, '<p><b>Earth</b> is a planet.</p>', 'Parse page by Title object' ); + } ); + } ); +}( mediaWiki ) ); |