Merge "build: Update grunt-jscs to 2.8.0"
[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( 2 );
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>' );
15 } );
16
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>" } }'
20 );
21 } );
22
23 api.parse( new mw.Title( 'Earth' ) ).done( function ( html ) {
24 assert.equal( html, '<p><b>Earth</b> is a planet.</p>' );
25 } );
26
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>" } }'
30 );
31 } );
32
33 this.server.respond();
34 } );
35 }( mediaWiki ) );