@@ -57,10 +57,10 @@ describe('Login basic route', () => {
5757 it ( 'Should send error when empty body is sent' , async ( ) => {
5858 const response = await addHeaders ( request . post ( endpoint ) , apikey ) ;
5959 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 ( ) ;
6464 } ) ;
6565
6666 it ( 'Should send error when email is only sent' , async ( ) => {
@@ -70,10 +70,10 @@ describe('Login basic route', () => {
7070 ) ;
7171 expect ( response . status ) . toBe ( 400 ) ;
7272 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 ( ) ;
7777 } ) ;
7878
7979 it ( 'Should send error when password is only sent' , async ( ) => {
@@ -83,10 +83,10 @@ describe('Login basic route', () => {
8383 ) ;
8484 expect ( response . status ) . toBe ( 400 ) ;
8585 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 ( ) ;
9090 } ) ;
9191
9292 it ( 'Should send error when email is not valid format' , async ( ) => {
@@ -96,10 +96,10 @@ describe('Login basic route', () => {
9696 ) ;
9797 expect ( response . status ) . toBe ( 400 ) ;
9898 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 ( ) ;
103103 } ) ;
104104
105105 it ( 'Should send error when password is not valid format' , async ( ) => {
@@ -113,10 +113,10 @@ describe('Login basic route', () => {
113113 expect ( response . status ) . toBe ( 400 ) ;
114114 expect ( response . body . message ) . toMatch ( / p a s s w o r d l e n g t h / ) ;
115115 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 ( ) ;
120120 } ) ;
121121
122122 it ( 'Should send error when user not registered for email' , async ( ) => {
@@ -129,10 +129,10 @@ describe('Login basic route', () => {
129129 ) ;
130130 expect ( response . status ) . toBe ( 400 ) ;
131131 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 ( ) ;
136136 } ) ;
137137
138138 it ( 'Should send error for wrong password' , async ( ) => {
@@ -145,10 +145,10 @@ describe('Login basic route', () => {
145145 ) ;
146146 expect ( response . status ) . toBe ( 401 ) ;
147147 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 ( ) ;
152152 } ) ;
153153
154154 it ( 'Should send success response for correct credentials' , async ( ) => {
@@ -172,12 +172,12 @@ describe('Login basic route', () => {
172172 expect ( response . body . data . tokens ) . toHaveProperty ( 'accessToken' ) ;
173173 expect ( response . body . data . tokens ) . toHaveProperty ( 'refreshToken' ) ;
174174
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 ) ;
179179
180- expect ( bcryptCompareSpy ) . toBeCalledWith ( password , user . password ) ;
180+ expect ( bcryptCompareSpy ) . toHaveBeenCalledWith ( password , user . password ) ;
181181 } ) ;
182182} ) ;
183183
0 commit comments