mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +00:00
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
// Copyright (C) 2017-2020 Smart code 203358507
|
|
|
|
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 7', async () => {
|
|
const { result } = renderHook(() => useSelectableSeasons(videos));
|
|
const [, selectedSeason] = result.current;
|
|
expect(selectedSeason).toBe(7);
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|
|
});
|