@@ -2,18 +2,18 @@ import { renderHook, waitFor } from "@testing-library/react";
22import axios from "axios" ;
33import { type MockedFunction , vi } from "vitest" ;
44
5- import {
6- useFetchLiveView ,
7- useFetchTalks ,
8- useFetchTalksById ,
9- } from "./useFetchTalks" ;
105import {
116 createMockAxiosResponse ,
127 createMockGroup ,
138 createMockSession ,
149 getQueryClientWrapper ,
1510 SESSION_URLS ,
1611} from "../utils/testing/testUtils" ;
12+ import {
13+ useFetchLiveView ,
14+ useFetchTalks ,
15+ useFetchTalksById ,
16+ } from "./useFetchTalks" ;
1717
1818import type { IGroup } from "../types/sessions" ;
1919
@@ -79,6 +79,24 @@ describe("useFetchTalks", () => {
7979 expect ( result . current . data ) . toEqual ( mockData ) ;
8080 } ) ;
8181
82+ it ( "should use 2025 URL when '2025' is provided" , async ( ) => {
83+ const mockData : IGroup [ ] = [ createMockGroup ( { groupName : "test" } ) ] ;
84+ const payload = createMockAxiosResponse ( mockData ) ;
85+
86+ mockedAxios . get . mockResolvedValue ( payload ) ;
87+
88+ const { wrapper } = getQueryClientWrapper ( ) ;
89+ const { result } = renderHook ( ( ) => useFetchTalks ( "2025" ) , {
90+ wrapper,
91+ } ) ;
92+
93+ await waitFor ( ( ) => result . current . isSuccess ) ;
94+ await waitFor ( ( ) => ! result . current . isLoading ) ;
95+
96+ expect ( mockedAxios . get ) . toHaveBeenCalledWith ( SESSION_URLS [ "2025" ] ) ;
97+ expect ( result . current . data ) . toEqual ( mockData ) ;
98+ } ) ;
99+
82100 it ( "should use custom URL when a URL is provided" , async ( ) => {
83101 const mockData : IGroup [ ] = [ createMockGroup ( { groupName : "test" } ) ] ;
84102 const payload = createMockAxiosResponse ( mockData ) ;
@@ -186,6 +204,35 @@ describe("useFetchTalksById", () => {
186204 expect ( result . current . data ) . toEqual ( expectedData ) ;
187205 } ) ;
188206
207+ it ( "should use 2025 URL when '2025' is provided" , async ( ) => {
208+ const mockSession = createMockSession ( {
209+ track : "" ,
210+ description : "" ,
211+ startsAt : "2025-01-01T00:00:00" ,
212+ } ) ;
213+ const mockData : IGroup [ ] = [
214+ createMockGroup ( {
215+ groupName : "test " ,
216+ sessions : [ mockSession ] ,
217+ } ) ,
218+ ] ;
219+ const payload = createMockAxiosResponse ( mockData ) ;
220+
221+ mockedAxios . get . mockResolvedValue ( payload ) ;
222+
223+ const { wrapper } = getQueryClientWrapper ( ) ;
224+ const { result } = renderHook ( ( ) => useFetchTalksById ( "123" , "2025" ) , {
225+ wrapper,
226+ } ) ;
227+
228+ await waitFor ( ( ) => result . current . isSuccess ) ;
229+ await waitFor ( ( ) => ! result . current . isLoading ) ;
230+
231+ expect ( mockedAxios . get ) . toHaveBeenCalledWith ( SESSION_URLS [ "2025" ] ) ;
232+ const expectedData = mockData [ 0 ] . sessions [ 0 ] ;
233+ expect ( result . current . data ) . toEqual ( expectedData ) ;
234+ } ) ;
235+
189236 it ( "should use custom URL when a URL is provided" , async ( ) => {
190237 const mockSession = createMockSession ( ) ;
191238 const mockData : IGroup [ ] = [
@@ -296,6 +343,34 @@ describe("useFetchLiveView", () => {
296343 expect ( result . current . data ) . toEqual ( [ mockSession ] ) ;
297344 } ) ;
298345
346+ it ( "should use 2025 URL when '2025' is provided" , async ( ) => {
347+ const mockSession = createMockSession ( {
348+ track : "" ,
349+ description : "" ,
350+ startsAt : "2025-01-01T00:00:00" ,
351+ } ) ;
352+ const mockData : IGroup [ ] = [
353+ createMockGroup ( {
354+ groupName : "test " ,
355+ sessions : [ mockSession ] ,
356+ } ) ,
357+ ] ;
358+ const payload = createMockAxiosResponse ( mockData ) ;
359+
360+ mockedAxios . get . mockResolvedValue ( payload ) ;
361+
362+ const { wrapper } = getQueryClientWrapper ( ) ;
363+ const { result } = renderHook ( ( ) => useFetchLiveView ( "2025" ) , {
364+ wrapper,
365+ } ) ;
366+
367+ await waitFor ( ( ) => result . current . isSuccess ) ;
368+ await waitFor ( ( ) => ! result . current . isLoading ) ;
369+
370+ expect ( mockedAxios . get ) . toHaveBeenCalledWith ( SESSION_URLS [ "2025" ] ) ;
371+ expect ( result . current . data ) . toEqual ( [ mockSession ] ) ;
372+ } ) ;
373+
299374 it ( "should use custom URL when a URL is provided" , async ( ) => {
300375 const mockSession = createMockSession ( ) ;
301376 const mockData : IGroup [ ] = [
0 commit comments