Trying to create a test case for the following function: The expected behavior is that if a successPath is provided, then onSignInSuccess should redirect to it.
export const onSignInSuccess = ( data ) => {
return ( ) => {
global.location.href = data?.detail?.data?.successPath;
}
}
What I have attempted so far but encountered issues:
const data = { detail : { data: { redirectPage: true, successPath: 'test.com' } } }
onSignInSuccess( data )()
expect( jest.fn() ).toHaveBeenCalledWith( 'test.com' )