@@ -34,7 +34,8 @@ describe('Auth token refresh', function() {
3434
3535 AuthTokenRefresh . use ( 'explicit_name' , strategy ) ;
3636
37- expect ( AuthTokenRefresh . _strategies . explicit_name . strategy ) . to . equal ( strategy ) ; expect ( AuthTokenRefresh . _strategies . strategy ) . to . be . undefined ;
37+ expect ( AuthTokenRefresh . _strategies . explicit_name ) . to . be . defined ;
38+ expect ( AuthTokenRefresh . _strategies . internal_name ) . to . be . undefined ;
3839 } ) ;
3940
4041 it ( 'should add a strategy without an explicitly defined name' , function ( ) {
@@ -45,7 +46,7 @@ describe('Auth token refresh', function() {
4546
4647 AuthTokenRefresh . use ( strategy ) ;
4748
48- expect ( AuthTokenRefresh . _strategies . internal_name . strategy ) . to . equal ( strategy ) ;
49+ expect ( AuthTokenRefresh . _strategies . internal_name ) . to . be . defined ;
4950 } ) ;
5051
5152 it ( 'should add a strategy with a refreshURL' , function ( ) {
@@ -56,7 +57,6 @@ describe('Auth token refresh', function() {
5657 } ;
5758
5859 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,7 +67,6 @@ describe('Auth token refresh', function() {
6767 } ;
6868
6969 AuthTokenRefresh . use ( strategy ) ;
70- expect ( AuthTokenRefresh . _strategies . test_strategy . strategy ) . to . equal ( strategy ) ;
7170 expect ( AuthTokenRefresh . _strategies . test_strategy . refreshOAuth2 . _accessTokenUrl ) . to . equal ( 'accessTokenUrl' ) ;
7271 } ) ;
7372
@@ -81,7 +80,41 @@ describe('Auth token refresh', function() {
8180 AuthTokenRefresh . use ( strategy ) ;
8281 expect ( AuthTokenRefresh . _strategies . test_strategy . refreshOAuth2 ) . to . not . equal ( strategyOAuth2 ) ;
8382 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+ } ;
94+
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+ } ;
84112
113+ AuthTokenRefresh . use ( strategy , params ) ;
114+ expect ( AuthTokenRefresh . _strategies . test_strategy . params ) . to . eql ( {
115+ some : 'extra_param' ,
116+ grant_type : 'refresh_token'
117+ } ) ;
85118 } ) ;
86119
87120 it ( 'should not add a null strategy' , function ( ) {
@@ -143,6 +176,9 @@ describe('Auth token refresh', function() {
143176
144177 AuthTokenRefresh . _strategies = {
145178 test_strategy : {
179+ params : {
180+ grant_type : 'refresh_token'
181+ } ,
146182 refreshOAuth2 : {
147183 getOAuthAccessToken : getOAuthAccessTokenSpy
148184 }
0 commit comments