Merge "mediawiki.api: Transform arrays with join('|') in query parameters"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki.api / mediawiki.api.test.js
index 1d5656e..b89526f 100644 (file)
 
                this.server.respond( function ( request ) {
                        if ( window.FormData ) {
-                               assert.ok( !request.url.match( /action=/), 'Request has no query string' );
+                               assert.ok( !request.url.match( /action=/ ), 'Request has no query string' );
                                assert.ok( request.requestBody instanceof FormData, 'Request uses FormData body' );
                        } else {
-                               assert.ok( !request.url.match( /action=test/), 'Request has no query string' );
+                               assert.ok( !request.url.match( /action=test/ ), 'Request has no query string' );
                                assert.equal( request.requestBody, 'action=test&format=json', 'Request uses query string body' );
                        }
                        request.respond( 200, { 'Content-Type': 'application/json' }, '[]' );
                } );
        } );
 
+       QUnit.test( 'Converting arrays to pipe-separated', function ( assert ) {
+               QUnit.expect( 1 );
+
+               var api = new mw.Api();
+               api.get( { test: [ 'foo', 'bar', 'baz' ] } );
+
+               this.server.respond( function ( request ) {
+                       assert.ok( request.url.match( /test=foo%7Cbar%7Cbaz/ ), 'Pipe-separated value was submitted' );
+                       request.respond( 200, { 'Content-Type': 'application/json' }, '[]' );
+               } );
+       } );
+
        QUnit.test( 'getToken( pre-populated )', function ( assert ) {
                QUnit.expect( 2 );