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