@@ -35,9 +35,9 @@ const genString = (len = 12) =>
3535const getValidPasswordValue = ( ) => genString ( 12 ) ;
3636const getTooShortPasswordValue = ( ) => genString ( 5 ) ;
3737
38- const renderCPLogin = ( stateOverrides = { } ) =>
38+ const renderCPLogin = initialState =>
3939 renderWithStoreRouter ( < CPLogin history = { history } location = { { } } /> , {
40- initialState : { ... makeAuthState ( true ) , ... stateOverrides } ,
40+ initialState,
4141 } ) ;
4242
4343const fillAndSubmit = ( { emailValue, passwordValue } = { } ) => {
@@ -63,11 +63,11 @@ describe('CPLogin component', () => {
6363 } ) ;
6464
6565 it ( 'renders without crashing' , ( ) => {
66- renderCPLogin ( ) ;
66+ renderCPLogin ( makeAuthState ( true ) ) ;
6767 } ) ;
6868
6969 it ( 'check if login elements get displayed when isAuthenticated is true' , ( ) => {
70- renderCPLogin ( ) ;
70+ renderCPLogin ( makeAuthState ( true ) ) ;
7171 expect ( screen . getByText ( 'Log In To Community Portal' ) ) . toBeInTheDocument ( ) ;
7272 } ) ;
7373
@@ -77,7 +77,7 @@ describe('CPLogin component', () => {
7777 } ) ;
7878
7979 it ( 'check if Enter your current user credentials... header displays as expected' , ( ) => {
80- renderCPLogin ( ) ;
80+ renderCPLogin ( makeAuthState ( true ) ) ;
8181 expect (
8282 screen . getByText (
8383 'Enter your current user credentials to access the Community Portal Dashboard' ,
@@ -86,29 +86,29 @@ describe('CPLogin component', () => {
8686 } ) ;
8787
8888 it ( 'check if Note: You must use your Production/Main credentials... displays as expected' , ( ) => {
89- renderCPLogin ( ) ;
89+ renderCPLogin ( makeAuthState ( true ) ) ;
9090 expect (
9191 screen . getByText ( 'Note: You must use your Production/Main credentials for this login.' ) ,
9292 ) . toBeInTheDocument ( ) ;
9393 } ) ;
9494
9595 it ( 'check if email label is displaying as expected' , ( ) => {
96- renderCPLogin ( ) ;
96+ renderCPLogin ( makeAuthState ( true ) ) ;
9797 expect ( screen . getByText ( 'Email' ) ) . toBeInTheDocument ( ) ;
9898 } ) ;
9999
100100 it ( 'check if password label is displaying as expected' , ( ) => {
101- renderCPLogin ( ) ;
101+ renderCPLogin ( makeAuthState ( true ) ) ;
102102 expect ( screen . getByText ( 'Password' ) ) . toBeInTheDocument ( ) ;
103103 } ) ;
104104
105105 it ( 'check if submit button is disabled when either email or password is not entered' , ( ) => {
106- renderCPLogin ( ) ;
106+ renderCPLogin ( makeAuthState ( true ) ) ;
107107 expect ( screen . getByText ( 'Submit' ) ) . toBeDisabled ( ) ;
108108 } ) ;
109109
110110 it ( 'check if validation for invalid email id works as expected' , ( ) => {
111- renderCPLogin ( ) ;
111+ renderCPLogin ( makeAuthState ( true ) ) ;
112112
113113 const { emailElement } = fillAndSubmit ( {
114114 emailValue : genString ( 4 ) , // invalid email, generated
@@ -120,7 +120,7 @@ describe('CPLogin component', () => {
120120 } ) ;
121121
122122 it ( 'check if validation for password works as expected' , ( ) => {
123- renderCPLogin ( ) ;
123+ renderCPLogin ( makeAuthState ( true ) ) ;
124124
125125 const { passwordElement } = fillAndSubmit ( {
126126 emailValue : VALID_EMAIL ,
@@ -139,7 +139,7 @@ describe('CPLogin component', () => {
139139 data : { token : '1234' } ,
140140 } ) ;
141141
142- renderCPLogin ( ) ;
142+ renderCPLogin ( makeAuthState ( true ) ) ;
143143
144144 const { emailElement, passwordElement } = fillAndSubmit ( {
145145 emailValue : VALID_EMAIL ,
@@ -163,7 +163,7 @@ describe('CPLogin component', () => {
163163 data : { token : '1234' , label : 'email' , message : 'User not found' } ,
164164 } ) ;
165165
166- renderCPLogin ( ) ;
166+ renderCPLogin ( makeAuthState ( true ) ) ;
167167
168168 fillAndSubmit ( {
169169 emailValue : VALID_EMAIL ,
@@ -182,7 +182,7 @@ describe('CPLogin component', () => {
182182 data : { token : '1234' } ,
183183 } ) ;
184184
185- renderCPLogin ( ) ;
185+ renderCPLogin ( makeAuthState ( true ) ) ;
186186
187187 const { passwordElement } = fillAndSubmit ( {
188188 emailValue : VALID_EMAIL ,
@@ -197,7 +197,7 @@ describe('CPLogin component', () => {
197197 it ( 'check failed post request does not display validation error' , async ( ) => {
198198 axios . post . mockRejectedValue ( { response : 'server error' } ) ;
199199
200- renderCPLogin ( ) ;
200+ renderCPLogin ( makeAuthState ( true ) ) ;
201201
202202 const { passwordElement } = fillAndSubmit ( {
203203 emailValue : VALID_EMAIL ,
0 commit comments