blob: a0c7daf1a066ca720090a5b9f5f6aa26411873cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
( function ( mw ) {
QUnit.module( 'mediawiki.api.category', QUnit.newMwEnvironment( {
setup: function () {
this.server = this.sandbox.useFakeServer();
}
} ) );
QUnit.test( '.getCategoriesByPrefix()', function ( assert ) {
QUnit.expect( 1 );
var api = new mw.Api();
api.getCategoriesByPrefix( 'Foo' ).done( 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 ) );
|