Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/348123 )

Change subject: tests: Don't assume synchronous jQuery.Deferred
......................................................................

tests: Don't assume synchronous jQuery.Deferred

Match the way mediawiki.api tests work in mediawiki/core.git

Bug: T124742
Change-Id: I4bb55c1fd196a923ba17066e507cf4aca8bf92f1
---
M tests/qunit/ext.centralauth.ForeignApi.test.js
1 file changed, 12 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/23/348123/1

diff --git a/tests/qunit/ext.centralauth.ForeignApi.test.js 
b/tests/qunit/ext.centralauth.ForeignApi.test.js
index 16f4ef5..8ef03dc 100644
--- a/tests/qunit/ext.centralauth.ForeignApi.test.js
+++ b/tests/qunit/ext.centralauth.ForeignApi.test.js
@@ -3,11 +3,6 @@
                setup: function () {
                        this.server = this.sandbox.useFakeServer();
                        this.server.respondImmediately = true;
-                       this.clock = this.sandbox.useFakeTimers();
-               },
-               teardown: function () {
-                       // https://github.com/jquery/jquery/issues/2453
-                       this.clock.tick();
                },
                config: {
                        wgUserName: true
@@ -15,7 +10,6 @@
        } ) );
 
        QUnit.test( 'Anonymous users do not get centralauthtoken', function ( 
assert ) {
-               QUnit.expect( 1 );
                mw.config.set( 'wgUserName', null );
 
                this.server.respond( function ( request ) {
@@ -25,12 +19,13 @@
                var api = new mw.ForeignApi( '//localhost:4242/w/api.php' );
 
                var spy = this.sandbox.spy( api, 'getCentralAuthToken' );
-               api.get( {} );
-               assert.ok( !spy.called, 'Anonymous users do not ask for 
centralauthtoken' );
+
+               return api.get( {} ).then( function () {
+                       assert.ok( !spy.called, 'Anonymous users do not ask for 
centralauthtoken' );
+               } );
        } );
 
        QUnit.test( 'Logged in users get centralauthtoken if not logged in 
remotely', function ( assert ) {
-               QUnit.expect( 1 );
                mw.config.set( 'wgUserName', 'User' );
 
                this.sandbox.stub( mw.ForeignApi.prototype, 'checkForeignLogin' 
).returns(
@@ -46,12 +41,13 @@
                var spy = this.sandbox.stub( api, 'getCentralAuthToken' 
).returns(
                        $.Deferred().resolve( 'CENTRALAUTHTOKEN' )
                );
-               api.get( {} );
-               assert.ok( spy.called, 'Logged in users ask for 
centralauthtoken if not logged in remotely' );
+
+               return api.get( {} ).then( function () {
+                       assert.ok( spy.called, 'Called' );
+               } );
        } );
 
        QUnit.test( 'Logged in users do not get centralauthtoken if logged in 
remotely', function ( assert ) {
-               QUnit.expect( 1 );
                mw.config.set( 'wgUserName', 'User' );
 
                this.sandbox.stub( mw.ForeignApi.prototype, 'checkForeignLogin' 
).returns(
@@ -67,8 +63,10 @@
                var spy = this.sandbox.stub( api, 'getCentralAuthToken' 
).returns(
                        $.Deferred().resolve( 'CENTRALAUTHTOKEN' )
                );
-               api.get( {} );
-               assert.ok( !spy.called, 'Logged in users do not ask for 
centralauthtoken if logged in remotely' );
+
+               api.get( {} ).then( function () {
+                       assert.ok( !spy.called, 'Called' );
+               } );
        } );
 
 }( mediaWiki, jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/348123
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4bb55c1fd196a923ba17066e507cf4aca8bf92f1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to