Merge "resources: Strip '$' and 'mw' from file closures"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.api / mediawiki.api.category.test.js
index 8ad1290..51ee7ad 100644 (file)
@@ -1,4 +1,4 @@
-( function ( mw ) {
+( function () {
        QUnit.module( 'mediawiki.api.category', QUnit.newMwEnvironment( {
                setup: function () {
                        this.server = this.sandbox.useFakeServer();
                        );
                } );
        } );
-}( mediaWiki ) );
+
+       QUnit.test( '.isCategory("")', function ( assert ) {
+               this.server.respondWith( /titles=$/, [
+                       200,
+                       { 'Content-Type': 'application/json' },
+                       '{"batchcomplete":true}'
+               ] );
+               return new mw.Api().isCategory( '' ).then( function ( response ) {
+                       assert.strictEqual( response, false );
+               } );
+       } );
+
+       QUnit.test( '.isCategory("#")', function ( assert ) {
+               this.server.respondWith( /titles=%23$/, [
+                       200,
+                       { 'Content-Type': 'application/json' },
+                       '{"batchcomplete":true,"query":{"normalized":[{"fromencoded":false,"from":"#","to":""}]}}'
+               ] );
+               return new mw.Api().isCategory( '#' ).then( function ( response ) {
+                       assert.strictEqual( response, false );
+               } );
+       } );
+
+       QUnit.test( '.isCategory("mw:")', function ( assert ) {
+               this.server.respondWith( /titles=mw%3A$/, [
+                       200,
+                       { 'Content-Type': 'application/json' },
+                       '{"batchcomplete":true,"query":{"interwiki":[{"title":"mw:","iw":"mw"}]}}'
+               ] );
+               return new mw.Api().isCategory( 'mw:' ).then( function ( response ) {
+                       assert.strictEqual( response, false );
+               } );
+       } );
+
+       QUnit.test( '.isCategory("|")', function ( assert ) {
+               this.server.respondWith( /titles=%1F%7C$/, [
+                       200,
+                       { 'Content-Type': 'application/json' },
+                       '{"batchcomplete":true,"query":{"pages":[{"title":"|","invalidreason":"The requested page title contains invalid characters: \\"|\\".","invalid":true}]}}'
+               ] );
+               return new mw.Api().isCategory( '|' ).then( function ( response ) {
+                       assert.strictEqual( response, false );
+               } );
+       } );
+
+       QUnit.test( '.getCategories("")', function ( assert ) {
+               this.server.respondWith( /titles=$/, [
+                       200,
+                       { 'Content-Type': 'application/json' },
+                       '{"batchcomplete":true}'
+               ] );
+               return new mw.Api().getCategories( '' ).then( function ( response ) {
+                       assert.strictEqual( response, false );
+               } );
+       } );
+
+       QUnit.test( '.getCategories("#")', function ( assert ) {
+               this.server.respondWith( /titles=%23$/, [
+                       200,
+                       { 'Content-Type': 'application/json' },
+                       '{"batchcomplete":true,"query":{"normalized":[{"fromencoded":false,"from":"#","to":""}]}}'
+               ] );
+               return new mw.Api().getCategories( '#' ).then( function ( response ) {
+                       assert.strictEqual( response, false );
+               } );
+       } );
+
+       QUnit.test( '.getCategories("mw:")', function ( assert ) {
+               this.server.respondWith( /titles=mw%3A$/, [
+                       200,
+                       { 'Content-Type': 'application/json' },
+                       '{"batchcomplete":true,"query":{"interwiki":[{"title":"mw:","iw":"mw"}]}}'
+               ] );
+               return new mw.Api().getCategories( 'mw:' ).then( function ( response ) {
+                       assert.strictEqual( response, false );
+               } );
+       } );
+
+       QUnit.test( '.getCategories("|")', function ( assert ) {
+               this.server.respondWith( /titles=%1F%7C$/, [
+                       200,
+                       { 'Content-Type': 'application/json' },
+                       '{"batchcomplete":true,"query":{"pages":[{"title":"|","invalidreason":"The requested page title contains invalid characters: \\"|\\".","invalid":true}]}}'
+               ] );
+               return new mw.Api().getCategories( '|' ).then( function ( response ) {
+                       assert.strictEqual( response, false );
+               } );
+       } );
+
+}() );