forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import { BrowserRouter} from 'react-router-dom'; | ||
import Welcome from './Welcome'; | ||
|
||
describe('Welcome Component', () => { | ||
|
||
it('should render the welcome message', () => { | ||
render( | ||
<BrowserRouter> | ||
<Welcome /> | ||
</BrowserRouter> | ||
); | ||
const welcomeMessage = screen.getByText(/Tu juego favorito de televisión, ¡ahora en tu ordenador!/i); | ||
expect(welcomeMessage).toBeInTheDocument(); | ||
const welcomeMessage2 = screen.getByText(/Accede a tu cuenta o regístrate para comenzar/i); | ||
expect(welcomeMessage2).toBeInTheDocument(); | ||
|
||
}); | ||
|
||
it('should navigate to login page when login button is clicked', () => { | ||
render( | ||
<BrowserRouter> | ||
<Welcome /> | ||
</BrowserRouter> | ||
); | ||
const loginButton = screen.getByRole('button', { name: /login/i }); | ||
fireEvent.click(loginButton); | ||
expect(window.location.pathname).toBe('/login'); | ||
}); | ||
|
||
it('should navigate to signup page when signup button is clicked', () => { | ||
render( | ||
<BrowserRouter> | ||
<Welcome /> | ||
</BrowserRouter> | ||
); | ||
const signupButton = screen.getByRole('button', { name: /signup/i }); | ||
fireEvent.click(signupButton); | ||
expect(window.location.pathname).toBe('/adduser'); | ||
}); | ||
|
||
}); |