diff --git a/src/components/CreateWallet.test.tsx b/src/components/CreateWallet.test.tsx index 331440734..96f9906b5 100644 --- a/src/components/CreateWallet.test.tsx +++ b/src/components/CreateWallet.test.tsx @@ -89,6 +89,26 @@ describe('', () => { expect(await screen.findByText('create_wallet.feedback_invalid_password_confirm')).toBeVisible() }) + it('should show validation message to user if duplicate wallet name', async () => { + ;(apiMock.getWalletAll as jest.Mock).mockReturnValue( + Promise.resolve({ + ok: true, + json: () => Promise.resolve({ wallets: [`${testWalletName}.jmdat`] }), + }), + ) + setup({}) + + expect(await screen.queryByText('create_wallet.feedback_wallet_name_already_exists')).not.toBeInTheDocument() + + await user.type(screen.getByPlaceholderText('create_wallet.placeholder_wallet_name'), testWalletName) + await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password'), testWalletPassword) + await user.type(screen.getByPlaceholderText('create_wallet.placeholder_password_confirm'), testWalletPassword) + + await user.click(screen.getByText('create_wallet.button_create')) + + expect(await screen.findByText('create_wallet.feedback_wallet_name_already_exists')).toBeVisible() + }) + it('should not submit form if wallet name contains invalid characters', async () => { setup({})