]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - tests/qunit/suites/resources/mediawiki.api/mediawiki.api.category.test.js
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / tests / qunit / suites / resources / mediawiki.api / mediawiki.api.category.test.js
diff --git a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.category.test.js b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.category.test.js
new file mode 100644 (file)
index 0000000..8ad1290
--- /dev/null
@@ -0,0 +1,25 @@
+( function ( mw ) {
+       QUnit.module( 'mediawiki.api.category', QUnit.newMwEnvironment( {
+               setup: function () {
+                       this.server = this.sandbox.useFakeServer();
+                       this.server.respondImmediately = true;
+               }
+       } ) );
+
+       QUnit.test( '.getCategoriesByPrefix()', function ( assert ) {
+               this.server.respondWith( [ 200, { 'Content-Type': 'application/json' },
+                       '{ "query": { "allpages": [ ' +
+                               '{ "title": "Category:Food" },' +
+                               '{ "title": "Category:Fool Supermarine S.6" },' +
+                               '{ "title": "Category:Fools" }' +
+                               '] } }'
+               ] );
+
+               return new mw.Api().getCategoriesByPrefix( 'Foo' ).then( function ( matches ) {
+                       assert.deepEqual(
+                               matches,
+                               [ 'Food', 'Fool Supermarine S.6', 'Fools' ]
+                       );
+               } );
+       } );
+}( mediaWiki ) );