@@ -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
+ var error = new ParseError (
375
+ ParseError . ACCOUNT_ALREADY_LINKED ,
376
+ 'Another user is already linked to this facebook id.'
377
+ ) ;
378
+ return ParsePromise . error ( error ) ;
379
+ } ,
380
+ ajax ( ) { }
381
+ } ) ;
382
+ var provider = {
383
+ authenticate ( options ) {
384
+ if ( options . success ) {
385
+ options . success ( this , {
386
+ id : 'id' ,
387
+ access_token : 'access_token'
388
+ } ) ;
389
+ }
390
+ } ,
391
+
392
+ restoreAuthentication ( authData ) { } ,
393
+
394
+ getAuthType ( ) {
395
+ return 'test' ;
396
+ } ,
397
+
398
+ deauthenticate ( ) { }
399
+ } ;
400
+
401
+ ParseUser . logInWith ( provider , { } ) . then ( ( ) => {
402
+
403
+ } , ( 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