-
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.
- Loading branch information
Showing
5 changed files
with
266 additions
and
91 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
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,107 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import '@testing-library/jest-dom'; | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import List from '../../components/List'; | ||
|
||
describe('List test suite', () => { | ||
beforeEach(() => { | ||
const location: Location = window.location; | ||
|
||
window.location = { | ||
...location, | ||
reload: vi.fn(), | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
window.location = location; | ||
}); | ||
|
||
it('should render List component', () => { | ||
const listId = 1; | ||
const description = 'Lista de jogos 01'; | ||
const gamesList = [ | ||
{ | ||
id: 1, | ||
gameid: 2, | ||
listid: 1, | ||
profileid: 1, | ||
game: { | ||
id: 2, | ||
id_igdb: '72', | ||
}, | ||
}, | ||
{ | ||
id: 2, | ||
gameid: 3, | ||
listid: 1, | ||
profileid: 1, | ||
game: { | ||
id: 3, | ||
id_igdb: '1942', | ||
}, | ||
}, | ||
{ | ||
id: 3, | ||
gameid: 1, | ||
listid: 1, | ||
profileid: 1, | ||
game: { | ||
id: 1, | ||
id_igdb: '1020', | ||
}, | ||
}, | ||
]; | ||
|
||
render(<List id={listId} description={description} gamesList={gamesList} />); | ||
|
||
const listContainer = screen.getByTestId('list-container'); | ||
|
||
expect(listContainer).toBeInTheDocument(); | ||
}); | ||
|
||
it('should delete List when delete button is clicked', () => { | ||
const listId = 1; | ||
const description = 'Lista de jogos 01'; | ||
const gamesList = [ | ||
{ | ||
id: 1, | ||
gameid: 2, | ||
listid: 1, | ||
profileid: 1, | ||
game: { | ||
id: 2, | ||
id_igdb: '72', | ||
}, | ||
}, | ||
{ | ||
id: 2, | ||
gameid: 3, | ||
listid: 1, | ||
profileid: 1, | ||
game: { | ||
id: 3, | ||
id_igdb: '1942', | ||
}, | ||
}, | ||
{ | ||
id: 3, | ||
gameid: 1, | ||
listid: 1, | ||
profileid: 1, | ||
game: { | ||
id: 1, | ||
id_igdb: '1020', | ||
}, | ||
}, | ||
]; | ||
|
||
render(<List id={listId} description={description} gamesList={gamesList} />); | ||
|
||
const deleteListButton = screen.getByTestId('delete-list-button'); | ||
|
||
fireEvent.click(deleteListButton); | ||
|
||
expect(deleteListButton).toBeInTheDocument(); | ||
}); | ||
}); |
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,14 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
Check failure on line 1 in src/tests/components/MainSlider.test.tsx GitHub Actions / build-app-react
|
||
import '@testing-library/jest-dom'; | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import { MainSlider } from '../../components/MainSlider'; | ||
|
||
describe('MainSlider test suite', () => { | ||
test('should render MainSlider component', async () => { | ||
render(<MainSlider />); | ||
|
||
const mainSliderContainer = screen.getByTestId('main-slider-container'); | ||
|
||
expect(mainSliderContainer).toBeInTheDocument(); | ||
}); | ||
}); |