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.
Merge branch 'develop' into luis_test
- Loading branch information
Showing
3 changed files
with
35 additions
and
30 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import RankingLayout from './RankingLayout'; | ||
import { useState } from 'react'; | ||
import { jest } from '@jest/globals'; | ||
|
||
describe('Ranking page', () => { | ||
it ('should render the global ranking when entering Rankings page', async () => { | ||
render(<RankingLayout />); | ||
const category = screen.getAllByText(/global/i); | ||
expect(category.length).toBe(2); | ||
}); | ||
|
||
it ('should render the <category> ranking when changed the useState', async () => { | ||
const categoryMock = 'global'; | ||
const setCategoryMock = jest.fn(); | ||
|
||
React.useState = jest.fn().mockReturnValue([categoryMock, setCategoryMock]) | ||
|
||
render(<RankingLayout />); | ||
|
||
setCategoryMock.mockImplementation(newValue => newValue('cities')); | ||
const citiesButton = screen.getByRole('button', { name: /Cities/i }); | ||
fireEvent.click(citiesButton); | ||
|
||
const category = screen.getAllByText(/cities/i); | ||
expect(category.length).toBe(2); | ||
}) | ||
}) |
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