import { renderHook } from '@testing-library/react-hooks';
import * as reactRedux from 'react-redux';
import { mockWindonwLocation } from '@tests/utility';
import { history } from '@lib/history';
import { useAfterSignIn } from './useAfterSignIn';
describe('useAfterSignIn', () => {
describe('onRouteAfterSignIn', () => {
const useSelectorMock = jest.spyOn(reactRedux, 'useSelector');
beforeEach(() => {
useSelectorMock.mockClear();
});
it('should be redirect to bank main, if not set the prevPathname and not set url', async () => {
useSelectorMock.mockReturnValue({
isTransferPortal: false,
});
mockWindonwLocation({});
const { result } = renderHook(() => useAfterSignIn());
result.current.onRouteAfterSignIn();
expect(history.location.pathname).toBe('/');
expect(history.location.hash).toBe('');
expect(history.location.search).toBe('');
});
});
});
Version
Test Scenario
Test Code
Reference