File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1
1
import request from 'supertest' ;
2
2
import createLoopback from '~/test/utils/create-loopback' ;
3
+ import AccountFactory from './account' ;
4
+ import { host } from '../config.json' ;
5
+
6
+ describe ( 'Account unit' , ( ) => {
7
+ const AccountMock = {
8
+ on : jest . fn ( ) ,
9
+ app : { models : { Email : { send : jest . fn ( ) } } } ,
10
+ } ;
11
+
12
+ beforeEach ( ( ) => {
13
+ jest . resetAllMocks ( ) ;
14
+ } ) ;
15
+
16
+ it ( 'add resetPasswordRequest remote method' , ( ) => {
17
+ AccountFactory ( AccountMock ) ;
18
+ expect ( AccountMock . on ) . toBeCalledWith (
19
+ 'resetPasswordRequest' ,
20
+ expect . any ( Function ) ,
21
+ ) ;
22
+ } ) ;
23
+
24
+ it ( 'calls send method from Email model' , ( ) => {
25
+ const infoMock = {
26
+ email : 'foo@bar.net' ,
27
+ accessToken : {
28
+ id : 'foobar' ,
29
+ } ,
30
+ } ;
31
+ AccountMock . on . mockImplementation ( ( _ , fn ) => {
32
+ fn ( infoMock ) ;
33
+ } ) ;
34
+ AccountFactory ( AccountMock ) ;
35
+ expect ( AccountMock . app . models . Email . send ) . toBeCalledWith (
36
+ expect . objectContaining ( {
37
+ to : infoMock . email ,
38
+ from : 'alpp <noreply@mydomain.com>' ,
39
+ subject : '[alpp] Create a new password' ,
40
+ html : expect . stringMatching (
41
+ new RegExp ( `${ host } .*${ infoMock . accessToken . id } ` )
42
+ ) ,
43
+ } ) ,
44
+ expect . any ( Function ) ,
45
+ ) ;
46
+ } ) ;
47
+ } ) ;
3
48
4
49
describe ( 'Account' , ( ) => {
5
50
const email = '936ue5+4bnywbeje42pw@sharklasers.com' ;
You can’t perform that action at this time.
0 commit comments