@@ -32,6 +32,7 @@ var ParseObject = require('../ParseObject');
32
32
var ParsePromise = require ( '../ParsePromise' ) ;
33
33
var ParseUser = require ( '../ParseUser' ) ;
34
34
var Storage = require ( '../Storage' ) ;
35
+ var ParseError = require ( '../ParseError' ) ;
35
36
36
37
var asyncHelper = require ( './test_helpers/asyncHelper' ) ;
37
38
@@ -360,4 +361,49 @@ describe('ParseUser', () => {
360
361
done ( ) ;
361
362
} ) ;
362
363
} ) ) ;
364
+
365
+ it ( 'can get error when recursive _linkWith call fails' , asyncHelper ( ( done ) => {
366
+ CoreManager . setRESTController ( {
367
+ request ( method , path , body , options ) {
368
+ expect ( method ) . toBe ( 'POST' ) ;
369
+ expect ( path ) . toBe ( 'users' ) ;
370
+ expect ( body . authData . test ) . toEqual ( {
371
+ id : 'id' ,
372
+ access_token : 'access_token'
373
+ } ) ;
374
+
375
+ var error = new ParseError (
376
+ ParseError . ACCOUNT_ALREADY_LINKED ,
377
+ 'Another user is already linked to this facebook id.'
378
+ ) ;
379
+ return ParsePromise . error ( error ) ;
380
+ } ,
381
+ ajax ( ) { }
382
+ } ) ;
383
+
384
+ var provider = {
385
+ authenticate ( options ) {
386
+ if ( options . success ) {
387
+ options . success ( this , {
388
+ id : 'id' ,
389
+ access_token : 'access_token'
390
+ } ) ;
391
+ }
392
+ } ,
393
+
394
+ restoreAuthentication ( authData ) { } ,
395
+
396
+ getAuthType ( ) {
397
+ return 'test' ;
398
+ } ,
399
+
400
+ deauthenticate ( ) { }
401
+ } ;
402
+
403
+ ParseUser . logInWith ( provider , { } ) . then ( ( ) => { } , ( error ) => {
404
+ expect ( error . code ) . toBe ( ParseError . ACCOUNT_ALREADY_LINKED ) ;
405
+ expect ( error . message ) . toBe ( 'Another user is already linked to this facebook id.' ) ;
406
+ done ( ) ;
407
+ } ) ;
408
+ } ) ) ;
363
409
} ) ;
0 commit comments