@@ -655,7 +655,7 @@ define(['require', 'tv4', './src/eventhandling'], function (require, tv4, eventH
655655 } ,
656656
657657 {
658- desc : "#authorize uses the given redirectUri " ,
658+ desc : "#authorize uses the cordovaRedirectUri when in Cordova " ,
659659 run : function ( env , test ) {
660660 global . document = {
661661 location : {
@@ -664,14 +664,21 @@ define(['require', 'tv4', './src/eventhandling'], function (require, tv4, eventH
664664 }
665665 } ;
666666
667- const authURL = 'https://provider.com/oauth' ;
668- env . rs . access . claim ( 'contacts' , 'r' ) ;
667+ global . cordova = { foo : 'bar' } ; // Pretend we run in Cordova
669668
670- env . rs . authorize ( { authURL, redirectUri : 'http://my.custom-redirect.url' } ) ;
669+ global . Authorize . openWindow = function ( url , redirectUri ) {
670+ test . assertAnd ( url , 'https://provider.com/oauth?redirect_uri=https%3A%2F%2Fmy.custom-redirect.url&scope=contacts%3Ar&client_id=https%3A%2F%2Fmy.custom-redirect.url&response_type=token' ) ;
671+ test . assertAnd ( redirectUri , 'https://my.custom-redirect.url' ) ;
672+ delete global . cordova ;
673+ delete global . document ;
674+ test . done ( ) ;
675+ } ;
671676
672- test . assert ( document . location . href , 'https://provider.com/oauth?redirect_uri=http%3A%2F%2Fmy.custom-redirect.url&scope=contacts%3Ar&client_id=http%3A%2F%2Fmy.custom-redirect.url&response_type=token' ) ;
677+ const authURL = 'https://provider.com/oauth' ;
673678
674- delete global . document ;
679+ env . rs . access . claim ( 'contacts' , 'r' ) ;
680+ env . rs . setCordovaRedirectUri ( 'https://my.custom-redirect.url' ) ;
681+ env . rs . authorize ( { authURL } ) ;
675682 }
676683 } ,
677684
0 commit comments