@@ -57,10 +57,10 @@ describe('Login basic route', () => {
57
57
it ( 'Should send error when empty body is sent' , async ( ) => {
58
58
const response = await addHeaders ( request . post ( endpoint ) , apikey ) ;
59
59
expect ( response . status ) . toBe ( 400 ) ;
60
- expect ( userFindByEmailSpy ) . not . toBeCalled ( ) ;
61
- expect ( bcryptCompareSpy ) . not . toBeCalled ( ) ;
62
- expect ( keystoreCreateSpy ) . not . toBeCalled ( ) ;
63
- expect ( createTokensSpy ) . not . toBeCalled ( ) ;
60
+ expect ( userFindByEmailSpy ) . not . toHaveBeenCalled ( ) ;
61
+ expect ( bcryptCompareSpy ) . not . toHaveBeenCalled ( ) ;
62
+ expect ( keystoreCreateSpy ) . not . toHaveBeenCalled ( ) ;
63
+ expect ( createTokensSpy ) . not . toHaveBeenCalled ( ) ;
64
64
} ) ;
65
65
66
66
it ( 'Should send error when email is only sent' , async ( ) => {
@@ -70,10 +70,10 @@ describe('Login basic route', () => {
70
70
) ;
71
71
expect ( response . status ) . toBe ( 400 ) ;
72
72
expect ( response . body . message ) . toMatch ( / p a s s w o r d / ) ;
73
- expect ( userFindByEmailSpy ) . not . toBeCalled ( ) ;
74
- expect ( bcryptCompareSpy ) . not . toBeCalled ( ) ;
75
- expect ( keystoreCreateSpy ) . not . toBeCalled ( ) ;
76
- expect ( createTokensSpy ) . not . toBeCalled ( ) ;
73
+ expect ( userFindByEmailSpy ) . not . toHaveBeenCalled ( ) ;
74
+ expect ( bcryptCompareSpy ) . not . toHaveBeenCalled ( ) ;
75
+ expect ( keystoreCreateSpy ) . not . toHaveBeenCalled ( ) ;
76
+ expect ( createTokensSpy ) . not . toHaveBeenCalled ( ) ;
77
77
} ) ;
78
78
79
79
it ( 'Should send error when password is only sent' , async ( ) => {
@@ -83,10 +83,10 @@ describe('Login basic route', () => {
83
83
) ;
84
84
expect ( response . status ) . toBe ( 400 ) ;
85
85
expect ( response . body . message ) . toMatch ( / e m a i l / ) ;
86
- expect ( userFindByEmailSpy ) . not . toBeCalled ( ) ;
87
- expect ( bcryptCompareSpy ) . not . toBeCalled ( ) ;
88
- expect ( keystoreCreateSpy ) . not . toBeCalled ( ) ;
89
- expect ( createTokensSpy ) . not . toBeCalled ( ) ;
86
+ expect ( userFindByEmailSpy ) . not . toHaveBeenCalled ( ) ;
87
+ expect ( bcryptCompareSpy ) . not . toHaveBeenCalled ( ) ;
88
+ expect ( keystoreCreateSpy ) . not . toHaveBeenCalled ( ) ;
89
+ expect ( createTokensSpy ) . not . toHaveBeenCalled ( ) ;
90
90
} ) ;
91
91
92
92
it ( 'Should send error when email is not valid format' , async ( ) => {
@@ -96,10 +96,10 @@ describe('Login basic route', () => {
96
96
) ;
97
97
expect ( response . status ) . toBe ( 400 ) ;
98
98
expect ( response . body . message ) . toMatch ( / v a l i d e m a i l / ) ;
99
- expect ( userFindByEmailSpy ) . not . toBeCalled ( ) ;
100
- expect ( bcryptCompareSpy ) . not . toBeCalled ( ) ;
101
- expect ( keystoreCreateSpy ) . not . toBeCalled ( ) ;
102
- expect ( createTokensSpy ) . not . toBeCalled ( ) ;
99
+ expect ( userFindByEmailSpy ) . not . toHaveBeenCalled ( ) ;
100
+ expect ( bcryptCompareSpy ) . not . toHaveBeenCalled ( ) ;
101
+ expect ( keystoreCreateSpy ) . not . toHaveBeenCalled ( ) ;
102
+ expect ( createTokensSpy ) . not . toHaveBeenCalled ( ) ;
103
103
} ) ;
104
104
105
105
it ( 'Should send error when password is not valid format' , async ( ) => {
@@ -113,10 +113,10 @@ describe('Login basic route', () => {
113
113
expect ( response . status ) . toBe ( 400 ) ;
114
114
expect ( response . body . message ) . toMatch ( / p a s s w o r d l e n g t h / ) ;
115
115
expect ( response . body . message ) . toMatch ( / 6 c h a r / ) ;
116
- expect ( userFindByEmailSpy ) . not . toBeCalled ( ) ;
117
- expect ( bcryptCompareSpy ) . not . toBeCalled ( ) ;
118
- expect ( keystoreCreateSpy ) . not . toBeCalled ( ) ;
119
- expect ( createTokensSpy ) . not . toBeCalled ( ) ;
116
+ expect ( userFindByEmailSpy ) . not . toHaveBeenCalled ( ) ;
117
+ expect ( bcryptCompareSpy ) . not . toHaveBeenCalled ( ) ;
118
+ expect ( keystoreCreateSpy ) . not . toHaveBeenCalled ( ) ;
119
+ expect ( createTokensSpy ) . not . toHaveBeenCalled ( ) ;
120
120
} ) ;
121
121
122
122
it ( 'Should send error when user not registered for email' , async ( ) => {
@@ -129,10 +129,10 @@ describe('Login basic route', () => {
129
129
) ;
130
130
expect ( response . status ) . toBe ( 400 ) ;
131
131
expect ( response . body . message ) . toMatch ( / n o t r e g i s t e r e d / ) ;
132
- expect ( userFindByEmailSpy ) . toBeCalledTimes ( 1 ) ;
133
- expect ( bcryptCompareSpy ) . not . toBeCalled ( ) ;
134
- expect ( keystoreCreateSpy ) . not . toBeCalled ( ) ;
135
- expect ( createTokensSpy ) . not . toBeCalled ( ) ;
132
+ expect ( userFindByEmailSpy ) . toHaveBeenCalledTimes ( 1 ) ;
133
+ expect ( bcryptCompareSpy ) . not . toHaveBeenCalled ( ) ;
134
+ expect ( keystoreCreateSpy ) . not . toHaveBeenCalled ( ) ;
135
+ expect ( createTokensSpy ) . not . toHaveBeenCalled ( ) ;
136
136
} ) ;
137
137
138
138
it ( 'Should send error for wrong password' , async ( ) => {
@@ -145,10 +145,10 @@ describe('Login basic route', () => {
145
145
) ;
146
146
expect ( response . status ) . toBe ( 401 ) ;
147
147
expect ( response . body . message ) . toMatch ( / a u t h e n t i c a t i o n f a i l u r e / i) ;
148
- expect ( userFindByEmailSpy ) . toBeCalledTimes ( 1 ) ;
149
- expect ( bcryptCompareSpy ) . toBeCalledTimes ( 1 ) ;
150
- expect ( keystoreCreateSpy ) . not . toBeCalled ( ) ;
151
- expect ( createTokensSpy ) . not . toBeCalled ( ) ;
148
+ expect ( userFindByEmailSpy ) . toHaveBeenCalledTimes ( 1 ) ;
149
+ expect ( bcryptCompareSpy ) . toHaveBeenCalledTimes ( 1 ) ;
150
+ expect ( keystoreCreateSpy ) . not . toHaveBeenCalled ( ) ;
151
+ expect ( createTokensSpy ) . not . toHaveBeenCalled ( ) ;
152
152
} ) ;
153
153
154
154
it ( 'Should send success response for correct credentials' , async ( ) => {
@@ -172,12 +172,12 @@ describe('Login basic route', () => {
172
172
expect ( response . body . data . tokens ) . toHaveProperty ( 'accessToken' ) ;
173
173
expect ( response . body . data . tokens ) . toHaveProperty ( 'refreshToken' ) ;
174
174
175
- expect ( userFindByEmailSpy ) . toBeCalledTimes ( 1 ) ;
176
- expect ( keystoreCreateSpy ) . toBeCalledTimes ( 1 ) ;
177
- expect ( bcryptCompareSpy ) . toBeCalledTimes ( 1 ) ;
178
- expect ( createTokensSpy ) . toBeCalledTimes ( 1 ) ;
175
+ expect ( userFindByEmailSpy ) . toHaveBeenCalledTimes ( 1 ) ;
176
+ expect ( keystoreCreateSpy ) . toHaveBeenCalledTimes ( 1 ) ;
177
+ expect ( bcryptCompareSpy ) . toHaveBeenCalledTimes ( 1 ) ;
178
+ expect ( createTokensSpy ) . toHaveBeenCalledTimes ( 1 ) ;
179
179
180
- expect ( bcryptCompareSpy ) . toBeCalledWith ( password , user . password ) ;
180
+ expect ( bcryptCompareSpy ) . toHaveBeenCalledWith ( password , user . password ) ;
181
181
} ) ;
182
182
} ) ;
183
183
0 commit comments