X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fqunit%2Fsuites%2Fresources%2Fmediawiki.api%2Fmediawiki.api.test.js;h=5a92da4f0c3aaa8c4e96019db6cbac758f7fdab0;hb=1edba8029a561919febf8b90f5df689d090665dd;hp=6629f5c5cc7e911b2bae4412a09d34cd783f7286;hpb=ca31fbc4dcf33ecdf5e415891ed499b4cd2021d6;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js index 6629f5c5cc..5a92da4f0c 100644 --- a/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js +++ b/tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js @@ -203,7 +203,7 @@ // Don't cache error (T67268) return api.getToken( 'testerror' ) - .then( null, function ( err ) { + .catch( function ( err ) { assert.equal( err, 'bite-me', 'Expected error' ); return api.getToken( 'testerror' ); @@ -311,7 +311,7 @@ return api.postWithToken( 'testassertpost', { action: 'example', key: 'foo', assert: 'user' } ) // Cast error to success and vice versa - .then( function ( ) { + .then( function () { return $.Deferred().reject( 'Unexpected success' ); }, function ( errorCode ) { assert.equal( errorCode, 'assertuserfailed', 'getToken fails assert' ); @@ -329,28 +329,26 @@ this.server.respond( [ 200, { 'Content-Type': 'application/json' }, '{ "example": "quux" }' ] ); return api.postWithToken( 'csrf', - { action: 'example' }, - { - headers: { - 'X-Foo': 'Bar' - } + { action: 'example' }, + { + headers: { + 'X-Foo': 'Bar' } - ) - .then( function () { - assert.equal( test.server.requests[ 0 ].requestHeaders[ 'X-Foo' ], 'Bar', 'Header sent' ); + } + ).then( function () { + assert.equal( test.server.requests[ 0 ].requestHeaders[ 'X-Foo' ], 'Bar', 'Header sent' ); - return api.postWithToken( 'csrf', - { action: 'example' }, - function () { - assert.ok( false, 'This parameter cannot be a callback' ); - } - ); - } ) - .then( function ( data ) { - assert.equal( data.example, 'quux' ); + return api.postWithToken( 'csrf', + { action: 'example' }, + function () { + assert.ok( false, 'This parameter cannot be a callback' ); + } + ); + } ).then( function ( data ) { + assert.equal( data.example, 'quux' ); - assert.equal( test.server.requests.length, 2, 'Request made' ); - } ); + assert.equal( test.server.requests.length, 2, 'Request made' ); + } ); } ); QUnit.test( 'postWithToken() - badtoken', function ( assert ) { @@ -451,7 +449,7 @@ } ); this.api.abort(); assert.ok( this.requests.length === 2, 'Check both requests triggered' ); - $.each( this.requests, function ( i, request ) { + this.requests.forEach( function ( request, i ) { assert.ok( request.abort.calledOnce, 'abort request number ' + i ); } ); } );