1
1
import request from 'supertest' ;
2
2
import createLoopback from '~/test/utils/create-loopback' ;
3
3
import AccountFactory from './account' ;
4
- import { host } from '../config.json' ;
4
+ import { host } from '../config.json' ;
5
5
6
6
describe ( 'Account unit' , ( ) => {
7
7
const AccountMock = {
@@ -31,6 +31,10 @@ describe('Account unit', () => {
31
31
AccountMock . on . mockImplementation ( ( _ , fn ) => {
32
32
fn ( infoMock ) ;
33
33
} ) ;
34
+ console . log = jest . fn ( ) ;
35
+ AccountMock . app . models . Email . send . mockImplementation ( ( _ , errFn ) => {
36
+ errFn ( ) ;
37
+ } ) ;
34
38
AccountFactory ( AccountMock ) ;
35
39
expect ( AccountMock . app . models . Email . send ) . toBeCalledWith (
36
40
expect . objectContaining ( {
@@ -43,10 +47,32 @@ describe('Account unit', () => {
43
47
} ) ,
44
48
expect . any ( Function ) ,
45
49
) ;
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
+ email : 'foo@bar.net' ,
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' ) ;
46
72
} ) ;
47
73
} ) ;
48
74
49
- describe ( 'Account' , ( ) => {
75
+ describe ( 'Account e2e ' , ( ) => {
50
76
const email = '936ue5+4bnywbeje42pw@sharklasers.com' ;
51
77
let server , testAccount , Account ;
52
78
0 commit comments