@@ -59,12 +59,7 @@ const mockLoggerService = {
5959
6060// Create utility functions for test data
6161const createTestUser = ( ) : User => {
62- const user = User . create (
63- 64- 'hashedPassword' ,
65- new FirstName ( 'John' ) ,
66- new LastName ( 'Doe' ) ,
67- ) ;
62+ const user = User . create ( new Email ( '[email protected] ' ) , 'hashedPassword' , new FirstName ( 'John' ) , new LastName ( 'Doe' ) ) ; 6863
6964 // Add roles
7065 const role = Role . fromData ( {
@@ -141,7 +136,7 @@ describe('LoginCommandHandler', () => {
141136 firstName : user . firstName . getValue ( ) ,
142137 lastName : user . lastName . getValue ( ) ,
143138 emailVerified : emailVerified || false ,
144- roles : user . roles . map ( role => ( {
139+ roles : user . roles . map ( ( role ) => ( {
145140 id : role . id . getValue ( ) ,
146141 name : role . name ,
147142 } ) ) ,
@@ -164,10 +159,7 @@ describe('LoginCommandHandler', () => {
164159
165160 // Act & Assert
166161 await expect ( handler . execute ( command ) ) . rejects . toThrow ( UnauthorizedException ) ;
167- expect ( userService . validateCredentials ) . toHaveBeenCalledWith (
168- 169- 'wrongPassword' ,
170- ) ;
162+ expect ( userService . validateCredentials ) . toHaveBeenCalledWith ( '[email protected] ' , 'wrongPassword' ) ; 171163 } ) ;
172164
173165 it ( 'should return email verification required response when email is not verified' , async ( ) => {
@@ -193,10 +185,7 @@ describe('LoginCommandHandler', () => {
193185 message : 'Email verification required' ,
194186 } ) ;
195187
196- expect ( userService . validateCredentials ) . toHaveBeenCalledWith (
197- 198- 'Password123!' ,
199- ) ;
188+ expect ( userService . validateCredentials ) . toHaveBeenCalledWith ( '[email protected] ' , 'Password123!' ) ; 200189 expect ( authService . updateLastLogin ) . toHaveBeenCalledWith ( user . id . getValue ( ) ) ;
201190 expect ( authService . isEmailVerified ) . toHaveBeenCalledWith ( '[email protected] ' ) ; 202191 } ) ;
@@ -225,10 +214,7 @@ describe('LoginCommandHandler', () => {
225214 message : 'OTP verification required' ,
226215 } ) ;
227216
228- expect ( userService . validateCredentials ) . toHaveBeenCalledWith (
229- 230- 'Password123!' ,
231- ) ;
217+ expect ( userService . validateCredentials ) . toHaveBeenCalledWith ( '[email protected] ' , 'Password123!' ) ; 232218 expect ( authService . updateLastLogin ) . toHaveBeenCalledWith ( user . id . getValue ( ) ) ;
233219 expect ( authService . isEmailVerified ) . toHaveBeenCalledWith ( '[email protected] ' ) ; 234220 } ) ;
@@ -266,10 +252,7 @@ describe('LoginCommandHandler', () => {
266252 } ) ,
267253 } ) ;
268254
269- expect ( userService . validateCredentials ) . toHaveBeenCalledWith (
270- 271- 'Password123!' ,
272- ) ;
255+ expect ( userService . validateCredentials ) . toHaveBeenCalledWith ( '[email protected] ' , 'Password123!' ) ; 273256 expect ( authService . updateLastLogin ) . toHaveBeenCalledWith ( user . id . getValue ( ) ) ;
274257 expect ( authService . isEmailVerified ) . toHaveBeenCalledWith ( '[email protected] ' ) ; 275258 expect ( roleRepository . findById ) . toHaveBeenCalledWith ( user . roles [ 0 ] . id . getValue ( ) ) ;
@@ -328,7 +311,7 @@ describe('LoginCommandHandler', () => {
328311 mockAuthService . isEmailVerified . mockResolvedValue ( true ) ;
329312
330313 // Mock repository to return different roles based on role id
331- mockRoleRepository . findById . mockImplementation ( roleId => {
314+ mockRoleRepository . findById . mockImplementation ( ( roleId ) => {
332315 if ( roleId === '550e8400-e29b-41d4-a716-446655440001' ) {
333316 return Promise . resolve ( userRoleWithPermissions ) ;
334317 } else if ( roleId === '550e8400-e29b-41d4-a716-446655440003' ) {
0 commit comments