@@ -494,7 +494,7 @@ describe('Accounts', () => {
494
494
const error = 'something bad' ;
495
495
Accounts . config ( { } , { sendResetPasswordEmail : ( ) => Promise . reject ( { message : error } ) } ) ;
496
496
try {
497
- await Accounts . requestPasswordReset ( 'email' ) ;
497
+ await Accounts . requestPasswordReset ( 'email@g.co ' ) ;
498
498
throw new Error ( ) ;
499
499
} catch ( err ) {
500
500
expect ( err . message ) . toEqual ( error ) ;
@@ -504,9 +504,21 @@ describe('Accounts', () => {
504
504
it ( 'should call transport.sendResetPasswordEmail' , async ( ) => {
505
505
const mock = jest . fn ( ( ) => Promise . resolve ( ) ) ;
506
506
Accounts . config ( { } , { sendResetPasswordEmail : mock } ) ;
507
- await Accounts . requestPasswordReset ( 'email' ) ;
507
+ await Accounts . requestPasswordReset ( 'email@g.co ' ) ;
508
508
expect ( mock . mock . calls . length ) . toEqual ( 1 ) ;
509
- expect ( mock . mock . calls [ 0 ] [ 0 ] ) . toEqual ( 'email' ) ;
509
+ expect ( mock . mock . calls [ 0 ] [ 0 ] ) . toEqual ( '[email protected] ' ) ;
510
+ } ) ;
511
+
512
+ it ( 'should throw if an invalid email is provided' , async ( ) => {
513
+ const mock = jest . fn ( ) ;
514
+ Accounts . config ( { } , { sendResetPasswordEmail : mock } ) ;
515
+ try {
516
+ await Accounts . requestPasswordReset ( 'email' ) ;
517
+ throw new Error ( ) ;
518
+ } catch ( err ) {
519
+ expect ( err . message ) . toEqual ( 'Valid email must be provided' ) ;
520
+ expect ( mock . mock . calls . length ) . toEqual ( 0 ) ;
521
+ }
510
522
} ) ;
511
523
} ) ;
512
524
@@ -515,7 +527,7 @@ describe('Accounts', () => {
515
527
const error = 'something bad' ;
516
528
Accounts . config ( { } , { sendVerificationEmail : ( ) => Promise . reject ( { message : error } ) } ) ;
517
529
try {
518
- await Accounts . requestVerificationEmail ( 'email' ) ;
530
+ await Accounts . requestVerificationEmail ( 'email@g.co ' ) ;
519
531
throw new Error ( ) ;
520
532
} catch ( err ) {
521
533
expect ( err . message ) . toEqual ( error ) ;
@@ -525,9 +537,21 @@ describe('Accounts', () => {
525
537
it ( 'should call transport.sendVerificationEmail' , async ( ) => {
526
538
const mock = jest . fn ( ( ) => Promise . resolve ( ) ) ;
527
539
Accounts . config ( { } , { sendVerificationEmail : mock } ) ;
528
- await Accounts . requestVerificationEmail ( 'email' ) ;
540
+ await Accounts . requestVerificationEmail ( 'email@g.co ' ) ;
529
541
expect ( mock . mock . calls . length ) . toEqual ( 1 ) ;
530
- expect ( mock . mock . calls [ 0 ] [ 0 ] ) . toEqual ( 'email' ) ;
542
+ expect ( mock . mock . calls [ 0 ] [ 0 ] ) . toEqual ( '[email protected] ' ) ;
543
+ } ) ;
544
+
545
+ it ( 'should throw if an invalid email is provided' , async ( ) => {
546
+ const mock = jest . fn ( ) ;
547
+ Accounts . config ( { } , { sendVerificationEmail : mock } ) ;
548
+ try {
549
+ await Accounts . requestVerificationEmail ( 'email' ) ;
550
+ throw new Error ( ) ;
551
+ } catch ( err ) {
552
+ expect ( err . message ) . toEqual ( 'Valid email must be provided' ) ;
553
+ expect ( mock . mock . calls . length ) . toEqual ( 0 ) ;
554
+ }
531
555
} ) ;
532
556
} ) ;
533
557
} ) ;
0 commit comments