@@ -18,27 +18,49 @@ describe("Send reset ", () => {
18
18
moxios . uninstall ( ) ;
19
19
store . clearActions ( ) ;
20
20
} ) ;
21
-
21
+ //resetResponse.data.status
22
22
test ( "Should send reset email action" , async ( ) => {
23
23
moxios . wait ( ( ) => {
24
24
const request = moxios . requests . mostRecent ( ) ;
25
- request . respondWith ( { status :200 ,
26
- response :{ message :"Sent successfully" } } ) ;
25
+ request . respondWith ( { response :{ status :200 , message :"Sent successfully" } } ) ;
27
26
} ) ;
28
27
return store . dispatch ( sendResetEmail ( "[email protected] " ) ) . then ( ( ) => {
29
28
expect ( store . getActions ( ) . length ) . toEqual ( 1 ) ;
29
+ expect ( store . getActions ( ) [ 0 ] . payload ) . toEqual ( true ) ;
30
30
} )
31
31
} ) ;
32
32
33
33
34
34
test ( "Should reset password action" , async ( ) => {
35
35
moxios . wait ( ( ) => {
36
36
const request = moxios . requests . mostRecent ( ) ;
37
- request . respondWith ( { status :200 ,
38
- response :{ message :"Password changed successfully!" } } ) ;
37
+ request . respondWith ( { response :{ status :200 , message :"Password changed successfully!" } } ) ;
38
+ } ) ;
39
+ return store . dispatch ( resetPassword ( "dann123" , token ) ) . then ( ( ) => {
40
+ expect ( store . getActions ( ) . length ) . toEqual ( 1 ) ;
41
+ expect ( store . getActions ( ) [ 0 ] . payload ) . toEqual ( true ) ;
42
+ } )
43
+ } ) ;
44
+
45
+ test ( "Should not reset password (wrong response)" , async ( ) => {
46
+ moxios . wait ( ( ) => {
47
+ const request = moxios . requests . mostRecent ( ) ;
48
+ request . respondWith ( { response :{ status :400 , message :"Password not changed !" } } ) ;
39
49
} ) ;
40
50
return store . dispatch ( resetPassword ( "dann123" , token ) ) . then ( ( ) => {
41
51
expect ( store . getActions ( ) . length ) . toEqual ( 1 ) ;
52
+ expect ( store . getActions ( ) [ 0 ] . payload ) . toEqual ( false ) ;
53
+ } )
54
+ } ) ;
55
+
56
+ test ( "Should not send link (wrong response)" , async ( ) => {
57
+ moxios . wait ( ( ) => {
58
+ const request = moxios . requests . mostRecent ( ) ;
59
+ request . respondWith ( { response :{ status :400 , message :"Password not changed !" } } ) ;
60
+ } ) ;
61
+ return store . dispatch ( sendResetEmail ( "[email protected] " ) ) . then ( ( ) => {
62
+ expect ( store . getActions ( ) . length ) . toEqual ( 1 ) ;
63
+ expect ( store . getActions ( ) [ 0 ] . payload ) . toEqual ( false ) ;
42
64
} )
43
65
} ) ;
44
66
0 commit comments