@@ -18,9 +18,9 @@ describe('LoginForm Form ', () => {
1818 render ( < LoginForm /> ) ;
1919
2020 const button = screen . getByTestId ( LOGIN_BUTTON ) ;
21- expect ( screen . queryByText ( / E m a i l i s r e q u i r e d / i) ) . not . toBeOnTheScreen ( ) ;
21+ expect ( screen . queryByText ( / U s e r n a m e i s r e q u i r e d / i) ) . not . toBeOnTheScreen ( ) ;
2222 fireEvent . press ( button ) ;
23- expect ( await screen . findByText ( / E m a i l i s r e q u i r e d / i) ) . toBeOnTheScreen ( ) ;
23+ expect ( await screen . findByText ( / U s e r n a m e i s r e q u i r e d / i) ) . toBeOnTheScreen ( ) ;
2424 expect ( screen . getByText ( / P a s s w o r d i s r e q u i r e d / i) ) . toBeOnTheScreen ( ) ;
2525 } ) ;
2626
@@ -29,24 +29,26 @@ describe('LoginForm Form ', () => {
2929
3030 const button = screen . getByTestId ( LOGIN_BUTTON ) ;
3131 const emailInput = screen . getByTestId ( 'email-input' ) ;
32+ const usernameInput = screen . getByTestId ( 'username-input' ) ;
3233 const passwordInput = screen . getByTestId ( 'password-input' ) ;
3334
34- fireEvent . changeText ( emailInput , 'yyyyy' ) ;
35+ fireEvent . changeText ( emailInput , 'yyyy' ) ;
36+ fireEvent . changeText ( usernameInput , ' ' ) ;
3537 fireEvent . changeText ( passwordInput , 'test' ) ;
3638 fireEvent . press ( button ) ;
3739
38- expect ( screen . queryByText ( / E m a i l i s r e q u i r e d / i) ) . not . toBeOnTheScreen ( ) ;
40+ expect ( screen . queryByText ( / U s e r n a m e i s r e q u i r e d / i) ) . not . toBeOnTheScreen ( ) ;
3941 expect ( await screen . findByText ( / I n v a l i d E m a i l F o r m a t / i) ) . toBeOnTheScreen ( ) ;
4042 } ) ;
4143
4244 it ( 'Should call LoginForm with correct values when values are valid' , async ( ) => {
4345 render ( < LoginForm onSubmit = { onSubmitMock } /> ) ;
4446
4547 const button = screen . getByTestId ( LOGIN_BUTTON ) ;
46- const emailInput = screen . getByTestId ( 'email -input' ) ;
48+ const emailInput = screen . getByTestId ( 'username -input' ) ;
4749 const passwordInput = screen . getByTestId ( 'password-input' ) ;
4850
49- fireEvent . changeText ( emailInput , 'youssef@gmail.com ' ) ;
51+ fireEvent . changeText ( emailInput , 'youssef' ) ;
5052 fireEvent . changeText ( passwordInput , 'password' ) ;
5153 fireEvent . press ( button ) ;
5254 await waitFor ( ( ) => {
@@ -55,10 +57,11 @@ describe('LoginForm Form ', () => {
5557 // undefined because we don't use second argument of the SubmitHandler
5658 expect ( onSubmitMock ) . toHaveBeenCalledWith (
5759 {
58- 60+ email : undefined ,
61+ username : 'youssef' ,
5962 password : 'password' ,
6063 } ,
61- undefined
64+ undefined ,
6265 ) ;
6366 } ) ;
6467} ) ;
0 commit comments