]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - tests/qunit/suites/resources/mediawiki.api/mediawiki.api.category.test.js
MediaWiki 1.30.2
[autoinstalls/mediawiki.git] / tests / qunit / suites / resources / mediawiki.api / mediawiki.api.category.test.js
1 ( function ( mw ) {
2         QUnit.module( 'mediawiki.api.category', QUnit.newMwEnvironment( {
3                 setup: function () {
4                         this.server = this.sandbox.useFakeServer();
5                         this.server.respondImmediately = true;
6                 }
7         } ) );
8
9         QUnit.test( '.getCategoriesByPrefix()', function ( assert ) {
10                 this.server.respondWith( [ 200, { 'Content-Type': 'application/json' },
11                         '{ "query": { "allpages": [ ' +
12                                 '{ "title": "Category:Food" },' +
13                                 '{ "title": "Category:Fool Supermarine S.6" },' +
14                                 '{ "title": "Category:Fools" }' +
15                                 '] } }'
16                 ] );
17
18                 return new mw.Api().getCategoriesByPrefix( 'Foo' ).then( function ( matches ) {
19                         assert.deepEqual(
20                                 matches,
21                                 [ 'Food', 'Fool Supermarine S.6', 'Fools' ]
22                         );
23                 } );
24         } );
25 }( mediaWiki ) );