diff --git a/src/components/App.test.tsx b/src/components/App.test.tsx index 7333f46ec..010791f61 100644 --- a/src/components/App.test.tsx +++ b/src/components/App.test.tsx @@ -1,9 +1,15 @@ import { render, screen, act } from '../testUtils' import user from '@testing-library/user-event' import * as apiMock from '../libs/JmWalletApi' +import * as loadersMock from './loaders/DataLoaders' import App from './App' +jest.mock('./loaders/DataLoaders', () => ({ + ...jest.requireActual('./loaders/DataLoaders'), + allWalletsLoader: jest.fn(), +})) + jest.mock('../libs/JmWalletApi', () => ({ ...jest.requireActual('../libs/JmWalletApi'), getGetinfo: jest.fn(), @@ -15,6 +21,12 @@ describe('', () => { const neverResolvingPromise = new Promise(() => {}) ;(apiMock.getGetinfo as jest.Mock).mockResolvedValue(neverResolvingPromise) ;(apiMock.getSession as jest.Mock).mockResolvedValue(neverResolvingPromise) + ;(loadersMock.allWalletsLoader as jest.Mock).mockReturnValue( + Promise.resolve({ + ok: true, + wallets: [], + }), + ) }) it('should display Onboarding screen initially', async () => { diff --git a/src/components/App.tsx b/src/components/App.tsx index c21c84ec6..02589a842 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -39,55 +39,144 @@ import Send from './Send' import RescanChain from './RescanChain' import Settings from './Settings' import Wallets from './Wallets' +import { allWalletsLoader } from './loaders/DataLoaders' const DevSetupPage = lazy(() => import('./DevSetupPage')) -export default function App() { - const { t } = useTranslation() - const settings = useSettings() - const currentWallet = useCurrentWallet() - const setCurrentWallet = useSetCurrentWallet() - const clearCurrentWallet = useClearCurrentWallet() - const reloadCurrentWalletInfo = useReloadCurrentWalletInfo() - const serviceInfo = useServiceInfo() - const sessionConnectionError = useSessionConnectionError() - const [reloadingWalletInfoCounter, setReloadingWalletInfoCounter] = useState(0) - const isReloadingWalletInfo = useMemo(() => reloadingWalletInfoCounter > 0, [reloadingWalletInfoCounter]) - - const startWallet = useCallback( - (walletFileName: Api.WalletFileName, auth: Api.ApiAuthContext) => { - setSession({ walletFileName, auth }) - setCurrentWallet({ walletFileName, token: auth.token }) +const router3 = (startWallet: any, sessionConnectionError: any, currentWallet: any, stopWallet: any, t: any) => + createBrowserRouter([ + { + id: 'base', + element: ( + <> + + + + +