diff --git a/packages/wallets/src/components/DesktopWalletsList/DesktopWalletsList.tsx b/packages/wallets/src/components/DesktopWalletsList/DesktopWalletsList.tsx index 3ca54664fbf9..175293136738 100644 --- a/packages/wallets/src/components/DesktopWalletsList/DesktopWalletsList.tsx +++ b/packages/wallets/src/components/DesktopWalletsList/DesktopWalletsList.tsx @@ -10,7 +10,7 @@ const DesktopWalletsList = () => { const { data: activeWallet, isInitializing } = useActiveWalletAccount(); return ( -
+
{isInitializing && } {!isInitializing && ( ({ + ...jest.requireActual('@deriv/api-v2'), + useActiveWalletAccount: jest.fn(), +})); + +const wrapper = ({ children }: PropsWithChildren) => { + return ( + + + {children} + + + ); +}; + +describe('DesktopWalletsList', () => { + it('renders the component', () => { + const mockUseActiveWalletAccount = { + isInitializing: true, + }; + (useActiveWalletAccount as jest.Mock).mockReturnValue(mockUseActiveWalletAccount); + render(, { wrapper }); + expect(screen.getByTestId('dt_desktop-wallets-list')).toBeInTheDocument(); + }); + it('renders the component when authorization is not initializing', () => { + const mockUseActiveWalletAccount = { + data: { + is_active: true, + is_virtual: false, + loginid: 'CRW1', + }, + isInitializing: false, + }; + (useActiveWalletAccount as jest.Mock).mockReturnValue(mockUseActiveWalletAccount); + + render(, { wrapper }); + expect(screen.getByTestId('dt_wallets_container')).toBeInTheDocument(); + }); + it('displays loader while authorization is initializing', () => { + const mockUseActiveWalletAccount = { + isInitializing: true, + }; + (useActiveWalletAccount as jest.Mock).mockReturnValue(mockUseActiveWalletAccount); + + render(, { wrapper }); + expect(screen.getByTestId('dt_wallets_card_loader')).toBeInTheDocument(); + }); +}); diff --git a/packages/wallets/src/components/SkeletonLoader/WalletsCardLoader/WalletsCardLoader.tsx b/packages/wallets/src/components/SkeletonLoader/WalletsCardLoader/WalletsCardLoader.tsx index 7e0c5f17f9c7..82d00bf4f711 100644 --- a/packages/wallets/src/components/SkeletonLoader/WalletsCardLoader/WalletsCardLoader.tsx +++ b/packages/wallets/src/components/SkeletonLoader/WalletsCardLoader/WalletsCardLoader.tsx @@ -3,7 +3,7 @@ import './WalletsCardLoader.scss'; const WalletsCardLoader = () => { return ( -
+
);