mediawiki.api: Make qunit failure easier to debug
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.api / mediawiki.api.category.test.js
index a0c7daf..a79bff6 100644 (file)
@@ -2,29 +2,24 @@
        QUnit.module( 'mediawiki.api.category', QUnit.newMwEnvironment( {
                setup: function () {
                        this.server = this.sandbox.useFakeServer();
+                       this.server.respondImmediately = true;
                }
        } ) );
 
-       QUnit.test( '.getCategoriesByPrefix()', function ( assert ) {
-               QUnit.expect( 1 );
+       QUnit.test( '.getCategoriesByPrefix()', 1, function ( assert ) {
+               this.server.respondWith( [ 200, { 'Content-Type': 'application/json' },
+                       '{ "query": { "allpages": [ ' +
+                               '{ "title": "Category:Food" },' +
+                               '{ "title": "Category:Fool Supermarine S.6" },' +
+                               '{ "title": "Category:Fools" }' +
+                               '] } }'
+               ] );
 
-               var api = new mw.Api();
-
-               api.getCategoriesByPrefix( 'Foo' ).done( function ( matches ) {
+               return new mw.Api().getCategoriesByPrefix( 'Foo' ).then( function ( matches ) {
                        assert.deepEqual(
                                matches,
                                [ 'Food', 'Fool Supermarine S.6', 'Fools' ]
                        );
                } );
-
-               this.server.respond( function ( req ) {
-                       req.respond( 200, { 'Content-Type': 'application/json' },
-                               '{ "query": { "allpages": [ ' +
-                                       '{ "title": "Category:Food" },' +
-                                       '{ "title": "Category:Fool Supermarine S.6" },' +
-                                       '{ "title": "Category:Fools" }' +
-                                       '] } }'
-                       );
-               } );
        } );
 }( mediaWiki ) );