@@ -34,8 +34,7 @@ describe('Auth token refresh', function() {
3434
3535 AuthTokenRefresh . use ( 'explicit_name' , strategy ) ;
3636
37- expect ( AuthTokenRefresh . _strategies . explicit_name ) . to . be . defined ;
38- expect ( AuthTokenRefresh . _strategies . internal_name ) . to . be . undefined ;
37+ expect ( AuthTokenRefresh . _strategies . explicit_name . strategy ) . to . equal ( strategy ) ; expect ( AuthTokenRefresh . _strategies . strategy ) . to . be . undefined ;
3938 } ) ;
4039
4140 it ( 'should add a strategy without an explicitly defined name' , function ( ) {
@@ -46,7 +45,7 @@ describe('Auth token refresh', function() {
4645
4746 AuthTokenRefresh . use ( strategy ) ;
4847
49- expect ( AuthTokenRefresh . _strategies . internal_name ) . to . be . defined ;
48+ expect ( AuthTokenRefresh . _strategies . internal_name . strategy ) . to . equal ( strategy ) ;
5049 } ) ;
5150
5251 it ( 'should add a strategy with a refreshURL' , function ( ) {
@@ -57,6 +56,7 @@ describe('Auth token refresh', function() {
5756 } ;
5857
5958 AuthTokenRefresh . use ( strategy ) ;
59+ expect ( AuthTokenRefresh . _strategies . test_strategy . strategy ) . to . equal ( strategy ) ;
6060 expect ( AuthTokenRefresh . _strategies . test_strategy . refreshOAuth2 . _accessTokenUrl ) . to . equal ( 'refreshURL' ) ;
6161 } ) ;
6262
@@ -67,6 +67,7 @@ describe('Auth token refresh', function() {
6767 } ;
6868
6969 AuthTokenRefresh . use ( strategy ) ;
70+ expect ( AuthTokenRefresh . _strategies . test_strategy . strategy ) . to . equal ( strategy ) ;
7071 expect ( AuthTokenRefresh . _strategies . test_strategy . refreshOAuth2 . _accessTokenUrl ) . to . equal ( 'accessTokenUrl' ) ;
7172 } ) ;
7273
@@ -80,41 +81,7 @@ describe('Auth token refresh', function() {
8081 AuthTokenRefresh . use ( strategy ) ;
8182 expect ( AuthTokenRefresh . _strategies . test_strategy . refreshOAuth2 ) . to . not . equal ( strategyOAuth2 ) ;
8283 expect ( AuthTokenRefresh . _strategies . test_strategy . refreshOAuth2 ) . to . be . instanceof ( OAuth2 ) ;
83- } ) ;
84-
85- it ( 'should add a strategy with an explicit name and params' , function ( ) {
86- var strategyOAuth2 = newOAuth2 ( ) ;
87- var strategy = {
88- name : 'test_strategy' ,
89- _oauth2 : strategyOAuth2
90- } ;
91- var params = {
92- some : 'extra_param'
93- } ;
9484
95- AuthTokenRefresh . use ( 'explicit_strategy' , strategy , params ) ;
96- expect ( AuthTokenRefresh . _strategies . explicit_strategy . params ) . to . eql ( {
97- some : 'extra_param' ,
98- grant_type : 'refresh_token'
99- } ) ;
100- expect ( AuthTokenRefresh . _strategies . test_strategy ) . to . be . undefined ;
101- } ) ;
102-
103- it ( 'should add a strategy with explicit params' , function ( ) {
104- var strategyOAuth2 = newOAuth2 ( ) ;
105- var strategy = {
106- name : 'test_strategy' ,
107- _oauth2 : strategyOAuth2
108- } ;
109- var params = {
110- some : 'extra_param'
111- } ;
112-
113- AuthTokenRefresh . use ( strategy , params ) ;
114- expect ( AuthTokenRefresh . _strategies . test_strategy . params ) . to . eql ( {
115- some : 'extra_param' ,
116- grant_type : 'refresh_token'
117- } ) ;
11885 } ) ;
11986
12087 it ( 'should not add a null strategy' , function ( ) {
@@ -176,9 +143,6 @@ describe('Auth token refresh', function() {
176143
177144 AuthTokenRefresh . _strategies = {
178145 test_strategy : {
179- params : {
180- grant_type : 'refresh_token'
181- } ,
182146 refreshOAuth2 : {
183147 getOAuthAccessToken : getOAuthAccessTokenSpy
184148 }
@@ -190,6 +154,23 @@ describe('Auth token refresh', function() {
190154 expect ( getOAuthAccessTokenSpy ) . to . have . been . calledWith ( 'refresh_token' , { grant_type : 'refresh_token' } , done ) ;
191155 } ) ;
192156
157+ it ( 'should refresh a new access token with extra params' , function ( ) {
158+ var getOAuthAccessTokenSpy = sinon . spy ( ) ;
159+ var done = sinon . spy ( ) ;
160+
161+ AuthTokenRefresh . _strategies = {
162+ test_strategy : {
163+ refreshOAuth2 : {
164+ getOAuthAccessToken : getOAuthAccessTokenSpy
165+ }
166+ }
167+ } ;
168+
169+ AuthTokenRefresh . requestNewAccessToken ( 'test_strategy' , 'refresh_token' , { some : 'extra_param' } , done ) ;
170+
171+ expect ( getOAuthAccessTokenSpy ) . to . have . been . calledWith ( 'refresh_token' , { grant_type : 'refresh_token' , some : 'extra_param' } , done ) ;
172+ } ) ;
173+
193174 it ( 'should not refresh if the strategy was not previously registered' , function ( ) {
194175 var done = sinon . spy ( ) ;
195176 var expectedErr = new Error ( 'Strategy was not registered to refresh a token' ) ;
0 commit comments