mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +00:00
add tests for useSelectableSeasons hook
This commit is contained in:
parent
dd5e9c803b
commit
ad9db5095e
1 changed files with 50 additions and 0 deletions
50
tests/hooks.spec.js
Normal file
50
tests/hooks.spec.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
const { renderHook, act } = require('@testing-library/react-hooks');
|
||||
const useSelectableSeasons = require('../src/routes/MetaDetails/VideosList/useSelectableSeasons');
|
||||
|
||||
const videos = [{ 'season': 4 }, { 'season': 5 }, { 'season': 4 }, { 'season': 7 }];
|
||||
|
||||
describe('hooks tests', () => {
|
||||
describe('useSelectableSeasons hook', () => {
|
||||
it('match 4', async () => {
|
||||
const { result } = renderHook(() => useSelectableSeasons(videos));
|
||||
const [, selectedSeason] = result.current;
|
||||
expect(selectedSeason).toBe(4);
|
||||
});
|
||||
|
||||
it('match 5', async () => {
|
||||
const { result } = renderHook(() => useSelectableSeasons(videos));
|
||||
|
||||
act(() => {
|
||||
const [, , , selectSeason] = result.current;
|
||||
selectSeason(5);
|
||||
});
|
||||
|
||||
const [, selectedSeason] = result.current;
|
||||
expect(selectedSeason).toBe(5);
|
||||
});
|
||||
|
||||
it('not match 6', async () => {
|
||||
const { result } = renderHook(() => useSelectableSeasons(videos));
|
||||
|
||||
act(() => {
|
||||
const [, , , selectSeason] = result.current;
|
||||
selectSeason(6);
|
||||
});
|
||||
|
||||
const [, selectedSeason] = result.current;
|
||||
expect(selectedSeason).toBe(undefined);
|
||||
});
|
||||
|
||||
it('not match $', async () => {
|
||||
const { result } = renderHook(() => useSelectableSeasons(videos));
|
||||
|
||||
act(() => {
|
||||
const [, , , selectSeason] = result.current;
|
||||
selectSeason('$');
|
||||
});
|
||||
|
||||
const [, selectedSeason] = result.current;
|
||||
expect(selectedSeason).toBe(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue