generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Changing the Signup.test to pass with the new conventions
- Loading branch information
1 parent
f8eecc9
commit 17beee4
Showing
2 changed files
with
7 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import React from 'react'; | ||
import { render, fireEvent, waitFor } from '@testing-library/react'; | ||
import { render, fireEvent, waitFor, getByTestId, getAllByTestId } from '@testing-library/react'; | ||
import axios from 'axios'; | ||
import { MemoryRouter, createMemoryRouter } from 'react-router'; | ||
import Signup from '../pages/Signup'; | ||
|
@@ -13,16 +13,16 @@ describe('Signup Component', () => { | |
expect(getByPlaceholderText('session.username')).toBeInTheDocument(); | ||
expect(getByPlaceholderText('session.password')).toBeInTheDocument(); | ||
expect(getByPlaceholderText('session.confirm_password')).toBeInTheDocument(); | ||
expect(getByText('Sign Up')).toBeInTheDocument(); | ||
expect(getByTestId(document.body, 'Sign up')).toBeInTheDocument(); | ||
}); | ||
|
||
it('toggles password visibility', () => { | ||
const { getByPlaceholderText, getAllByRole } = render(<MemoryRouter><Signup /></MemoryRouter>); | ||
|
||
const passwordInput = getByPlaceholderText('session.password'); | ||
const confirmPasswordInput = getByPlaceholderText('session.confirm_password'); | ||
const showPasswordButtons = getAllByRole('button', { name: /Show/i }); | ||
const showPasswordButtons = getAllByTestId(document.body, 'show-confirm-password-button'); | ||
|
||
fireEvent.click(showPasswordButtons[0]); | ||
fireEvent.click(showPasswordButtons[1]); | ||
|
||
|
@@ -41,7 +41,7 @@ describe('Signup Component', () => { | |
const emailInput = getByPlaceholderText('session.email'); | ||
const usernameInput = getByPlaceholderText('session.username'); | ||
const passwordInput = getByPlaceholderText('session.password'); | ||
const signUpButton = getByText('Sign Up'); | ||
const signUpButton = getByTestId(document.body, 'Sign up'); | ||
|
||
// Fill out the form with valid data and submit it | ||
fireEvent.change(emailInput, { target: { value: '[email protected]' } }); | ||
|