Untitled
unknown
plain_text
2 years ago
2.1 kB
4
Indexable
import userEvent from '@testing-library/user-event'; import { screen, waitFor } from '@testing-library/react'; import App from '../App'; import { renderWithRouterAndRedux } from './helpers/renderWith'; const login = 'email-input'; const password = 'password-input'; it('Verificar se email e senha estão na tela', () => { renderWithRouterAndRedux(<App />); const email = screen.getByTestId(login); const senha = screen.getByTestId(password); expect(email).toBeInTheDocument(); expect(senha).toBeInTheDocument(); }); it('Verificar se o botão de login habilita e desabilita', async () => { renderWithRouterAndRedux(<App />); const user = userEvent.setup(); const emailCorreto = 'seuemail@yahoo.com'; const emailIncorreto = 'seuemailyahoo.com'; const senhaCorreta = '1234567'; const senhaIncorreta = '12345'; const email = screen.getByTestId(login); const senha = screen.getByTestId(password); const button = screen.getByRole('button'); await user.type(email, emailIncorreto); await user.type(senha, senhaIncorreta); expect(button).toBeDisabled(); await user.clear(email); await user.clear(senha); await user.type(email, emailCorreto); await user.type(senha, senhaIncorreta); expect(button).toBeDisabled(); await user.clear(email); await user.clear(senha); await user.type(email, emailCorreto); await user.type(senha, senhaIncorreta); expect(button).toBeDisabled(); await user.clear(email); await user.clear(senha); await user.type(email, emailCorreto); await user.type(senha, senhaCorreta); expect(button).toBeEnabled(); }); it('Testar funcionamento da rota', async () => { renderWithRouterAndRedux(<App />); const user = userEvent.setup(); const email = 'email@yahoo.com'; const senha = '1234567'; const acesso = screen.getByTestId(login); const senhaCorreta = screen.getByTestId(password); const button = screen.getByRole('button'); await user.type(acesso, email); await user.type(senhaCorreta, senha); expect(button).toBeEnabled(); await user.click(button); waitFor(() => expect(global.window.location.pathname).toEqual('/carteira')); });
Editor is loading...