@@ -125,6 +125,53 @@ describe('auth0.WebAuth.crossOriginAuthentication', function() {
125
125
}
126
126
) ;
127
127
} ) ;
128
+ it ( 'should map error correctly when popup:true' , function ( done ) {
129
+ stub ( request , 'post' , function ( url ) {
130
+ expect ( url ) . to . be ( 'https://me.auth0.com/co/authenticate' ) ;
131
+ return new RequestMock ( {
132
+ body : {
133
+ client_id : '...' ,
134
+ credential_type : 'password' ,
135
+
136
+ password : '123456'
137
+ } ,
138
+ headers : {
139
+ 'Content-Type' : 'application/json'
140
+ } ,
141
+ cb : function ( cb ) {
142
+ cb ( null , {
143
+ body : {
144
+ login_ticket : 'a_login_ticket' ,
145
+ co_verifier : 'co_verifier' ,
146
+ co_id : 'co_id'
147
+ }
148
+ } ) ;
149
+ }
150
+ } ) ;
151
+ } ) ;
152
+ stub ( WebMessageHandler . prototype , 'run' , function ( options , callback ) {
153
+ callback ( { error : 'any error' , error_description : 'a huge error string' } ) ;
154
+ } ) ;
155
+ this . co . login (
156
+ {
157
+
158
+ password : '123456' ,
159
+ anotherOption : 'foobar' ,
160
+ popup : true
161
+ } ,
162
+ function ( err ) {
163
+ expect ( err ) . to . be . eql ( {
164
+ original : {
165
+ error : 'any error' ,
166
+ error_description : 'a huge error string'
167
+ } ,
168
+ code : 'any error' ,
169
+ description : 'a huge error string'
170
+ } ) ;
171
+ done ( ) ;
172
+ }
173
+ ) ;
174
+ } ) ;
128
175
it ( 'should call /co/authenticate with realm grant and redirect to /authorize with login_ticket when realm is used' , function ( ) {
129
176
stub ( request , 'post' , function ( url ) {
130
177
expect ( url ) . to . be ( 'https://me.auth0.com/co/authenticate' ) ;
@@ -268,7 +315,10 @@ describe('auth0.WebAuth.crossOriginAuthentication', function() {
268
315
} ,
269
316
function ( err ) {
270
317
expect ( err ) . to . be . eql ( {
271
- original : { error : 'any_error' , error_description : 'a super big error message description' } ,
318
+ original : {
319
+ error : 'any_error' ,
320
+ error_description : 'a super big error message description'
321
+ } ,
272
322
code : 'any_error' ,
273
323
description : 'a super big error message description'
274
324
} ) ;
0 commit comments