11import request from 'supertest' ;
22import createLoopback from '~/test/utils/create-loopback' ;
33import AccountFactory from './account' ;
4- import { host } from '../config.json' ;
4+ import { host } from '../config.json' ;
55
66describe ( 'Account unit' , ( ) => {
77 const AccountMock = {
@@ -31,6 +31,10 @@ describe('Account unit', () => {
3131 AccountMock . on . mockImplementation ( ( _ , fn ) => {
3232 fn ( infoMock ) ;
3333 } ) ;
34+ console . log = jest . fn ( ) ;
35+ AccountMock . app . models . Email . send . mockImplementation ( ( _ , errFn ) => {
36+ errFn ( ) ;
37+ } ) ;
3438 AccountFactory ( AccountMock ) ;
3539 expect ( AccountMock . app . models . Email . send ) . toBeCalledWith (
3640 expect . objectContaining ( {
@@ -43,10 +47,32 @@ describe('Account unit', () => {
4347 } ) ,
4448 expect . any ( Function ) ,
4549 ) ;
50+ expect ( console . log ) . toBeCalledWith (
51+ expect . any ( String ) ,
52+ expect . stringContaining ( infoMock . email )
53+ ) ;
54+ } ) ;
55+
56+ it ( 'console log when Email send throws' , ( ) => {
57+ const infoMock = {
58+ 59+ accessToken : {
60+ id : 'foobar' ,
61+ } ,
62+ } ;
63+ AccountMock . on . mockImplementation ( ( _ , fn ) => {
64+ fn ( infoMock ) ;
65+ } ) ;
66+ console . log = jest . fn ( ) ;
67+ AccountMock . app . models . Email . send . mockImplementation ( ( _ , errFn ) => {
68+ errFn ( 'foo' ) ;
69+ } ) ;
70+ AccountFactory ( AccountMock ) ;
71+ expect ( console . log ) . toBeCalledWith ( 'foo' ) ;
4672 } ) ;
4773} ) ;
4874
49- describe ( 'Account' , ( ) => {
75+ describe ( 'Account e2e ' , ( ) => {
5076 const email = '[email protected] ' ; 5177 let server , testAccount , Account ;
5278
0 commit comments