@@ -46,30 +46,29 @@ jest.mock('../register/data/apiHook', () => ({
4646// Mock the ThirdPartyAuthContext
4747const mockClearThirdPartyAuthErrorMessage = jest . fn ( ) ;
4848
49+ const mockDefaultThirdPartyAuthContextValue = {
50+ fieldDescriptions : { } ,
51+ optionalFields : { fields : { } , extended_profile : [ ] } ,
52+ thirdPartyAuthApiStatus : null ,
53+ thirdPartyAuthContext : {
54+ autoSubmitRegForm : false ,
55+ currentProvider : null ,
56+ finishAuthUrl : null ,
57+ countryCode : null ,
58+ providers : [ ] ,
59+ secondaryProviders : [ ] ,
60+ pipelineUserDetails : null ,
61+ errorMessage : null ,
62+ welcomePageRedirectUrl : null ,
63+ } ,
64+ setThirdPartyAuthContextBegin : jest . fn ( ) ,
65+ setThirdPartyAuthContextSuccess : jest . fn ( ) ,
66+ setThirdPartyAuthContextFailure : jest . fn ( ) ,
67+ clearThirdPartyAuthErrorMessage : mockClearThirdPartyAuthErrorMessage ,
68+ } ;
69+
4970jest . mock ( '../common-components/components/ThirdPartyAuthContext.tsx' , ( ) => ( {
50- useThirdPartyAuthContext : jest . fn ( ( ) => ( {
51- fieldDescriptions : { } ,
52- optionalFields : {
53- fields : { } ,
54- extended_profile : [ ] ,
55- } ,
56- thirdPartyAuthApiStatus : null ,
57- thirdPartyAuthContext : {
58- autoSubmitRegForm : false ,
59- currentProvider : null ,
60- finishAuthUrl : null ,
61- countryCode : null ,
62- providers : [ ] ,
63- secondaryProviders : [ ] ,
64- pipelineUserDetails : null ,
65- errorMessage : null ,
66- welcomePageRedirectUrl : null ,
67- } ,
68- setThirdPartyAuthContextBegin : jest . fn ( ) ,
69- setThirdPartyAuthContextSuccess : jest . fn ( ) ,
70- setThirdPartyAuthContextFailure : jest . fn ( ) ,
71- clearThirdPartyAuthErrorMessage : mockClearThirdPartyAuthErrorMessage ,
72- } ) ) ,
71+ useThirdPartyAuthContext : jest . fn ( ( ) => mockDefaultThirdPartyAuthContextValue ) ,
7372 ThirdPartyAuthProvider : ( { children } ) => children ,
7473} ) ) ;
7574
@@ -185,29 +184,16 @@ describe('Logistration', () => {
185184 // Update the mock to include secondary providers
186185 const { useThirdPartyAuthContext } = require ( '../common-components/components/ThirdPartyAuthContext.tsx' ) ;
187186 useThirdPartyAuthContext . mockReturnValue ( {
188- fieldDescriptions : { } ,
189- optionalFields : { fields : { } , extended_profile : [ ] } ,
190- thirdPartyAuthApiStatus : null ,
187+ ...mockDefaultThirdPartyAuthContextValue ,
191188 thirdPartyAuthContext : {
192- autoSubmitRegForm : false ,
193- currentProvider : null ,
194- finishAuthUrl : null ,
195- countryCode : null ,
196- providers : [ ] ,
189+ ...mockDefaultThirdPartyAuthContextValue . thirdPartyAuthContext ,
197190 secondaryProviders : [ {
198191 id : 'saml-test' ,
199192 name : 'Test University' ,
200193 loginUrl : '/dummy-auth' ,
201194 registerUrl : '/dummy_auth' ,
202195 } ] ,
203- pipelineUserDetails : null ,
204- errorMessage : null ,
205- welcomePageRedirectUrl : null ,
206196 } ,
207- setThirdPartyAuthContextBegin : jest . fn ( ) ,
208- setThirdPartyAuthContextSuccess : jest . fn ( ) ,
209- setThirdPartyAuthContextFailure : jest . fn ( ) ,
210- clearThirdPartyAuthErrorMessage : mockClearThirdPartyAuthErrorMessage ,
211197 } ) ;
212198
213199 const props = { selectedPage : LOGIN_PAGE } ;
@@ -230,29 +216,16 @@ describe('Logistration', () => {
230216
231217 const { useThirdPartyAuthContext } = require ( '../common-components/components/ThirdPartyAuthContext.tsx' ) ;
232218 useThirdPartyAuthContext . mockReturnValue ( {
233- fieldDescriptions : { } ,
234- optionalFields : { fields : { } , extended_profile : [ ] } ,
235- thirdPartyAuthApiStatus : null ,
219+ ...mockDefaultThirdPartyAuthContextValue ,
236220 thirdPartyAuthContext : {
237- autoSubmitRegForm : false ,
238- currentProvider : null ,
239- finishAuthUrl : null ,
240- countryCode : null ,
241- providers : [ ] ,
221+ ...mockDefaultThirdPartyAuthContextValue . thirdPartyAuthContext ,
242222 secondaryProviders : [ {
243223 id : 'saml-test' ,
244224 name : 'Test University' ,
245225 loginUrl : '/dummy-auth' ,
246226 registerUrl : '/dummy_auth' ,
247227 } ] ,
248- pipelineUserDetails : null ,
249- errorMessage : null ,
250- welcomePageRedirectUrl : null ,
251228 } ,
252- setThirdPartyAuthContextBegin : jest . fn ( ) ,
253- setThirdPartyAuthContextSuccess : jest . fn ( ) ,
254- setThirdPartyAuthContextFailure : jest . fn ( ) ,
255- clearThirdPartyAuthErrorMessage : mockClearThirdPartyAuthErrorMessage ,
256229 } ) ;
257230
258231 const props = { selectedPage : LOGIN_PAGE } ;
@@ -274,29 +247,16 @@ describe('Logistration', () => {
274247
275248 const { useThirdPartyAuthContext } = require ( '../common-components/components/ThirdPartyAuthContext.tsx' ) ;
276249 useThirdPartyAuthContext . mockReturnValue ( {
277- fieldDescriptions : { } ,
278- optionalFields : { fields : { } , extended_profile : [ ] } ,
279- thirdPartyAuthApiStatus : null ,
250+ ...mockDefaultThirdPartyAuthContextValue ,
280251 thirdPartyAuthContext : {
281- autoSubmitRegForm : false ,
282- currentProvider : null ,
283- finishAuthUrl : null ,
284- countryCode : null ,
285- providers : [ ] ,
252+ ...mockDefaultThirdPartyAuthContextValue . thirdPartyAuthContext ,
286253 secondaryProviders : [ {
287254 id : 'saml-test' ,
288255 name : 'Test University' ,
289256 loginUrl : '/dummy-auth' ,
290257 registerUrl : '/dummy_auth' ,
291258 } ] ,
292- pipelineUserDetails : null ,
293- errorMessage : null ,
294- welcomePageRedirectUrl : null ,
295259 } ,
296- setThirdPartyAuthContextBegin : jest . fn ( ) ,
297- setThirdPartyAuthContextSuccess : jest . fn ( ) ,
298- setThirdPartyAuthContextFailure : jest . fn ( ) ,
299- clearThirdPartyAuthErrorMessage : mockClearThirdPartyAuthErrorMessage ,
300260 } ) ;
301261
302262 delete window . location ;
0 commit comments