@@ -4,25 +4,23 @@ import Speakers2024 from "./Speakers2024";
44import {
55 createMockSpeakers ,
66 renderWithRouterAndQueryClient ,
7- } from "../../ utils/testing/speakerTestUtils" ;
7+ } from "@ utils/testing/speakerTestUtils" ;
88import { useFetchSpeakers } from "@hooks/useFetchSpeakers" ;
9- import userEvent from "@testing-library/user-event" ;
9+ import { useWindowSize } from "react-use" ;
10+ import { type MockedFunction , vi } from "vitest" ;
1011
11- import { vi } from "vitest" ;
12- import { gaEventTracker } from "@components/analytics/Analytics" ;
12+ vi . mock ( "@hooks/useFetchSpeakers" ) ;
1313
14- vi . mock ( "../../hooks/useFetchSpeakers" ) ;
15-
16- vi . mock ( "../../components/analytics/Analytics" , ( ) => ( {
17- gaEventTracker : jest . fn ( ) ,
14+ vi . mock ( "@components/analytics/Analytics" , ( ) => ( {
15+ gaEventTracker : vi . fn ( ) ,
1816} ) ) ;
1917vi . mock ( "react-use" , ( ) => ( {
2018 useWindowSize : vi . fn ( ) ,
2119} ) ) ;
2220vi . mock ( "@sentry/react" , ( ) => ( {
23- captureException : jest . fn ( ) ,
21+ captureException : vi . fn ( ) ,
2422} ) ) ;
25- vi . mock ( "../../ data/2024.json" , ( ) => ( {
23+ vi . mock ( "@ data/2024.json" , ( ) => ( {
2624 hideSpeakers : false ,
2725 edition : "2024" ,
2826 title : "DevBcn" ,
@@ -33,15 +31,17 @@ vi.mock("../../data/2024.json", () => ({
3331 } ,
3432} ) ) ;
3533
36- const mockedUseFetchSpeakers = useFetchSpeakers as jest . MockedFunction <
34+ const mockedUseFetchSpeakers = useFetchSpeakers as MockedFunction <
3735 typeof useFetchSpeakers
3836> ;
3937
4038describe ( "Speakers2024 component" , ( ) => {
4139 beforeEach ( ( ) => {
4240 vi . clearAllMocks ( ) ;
43- // eslint-disable-next-line @typescript-eslint/no-require-imports
44- require ( "react-use" ) . useWindowSize . mockReturnValue ( { width : 1200 } ) ;
41+ ( useWindowSize as MockedFunction < typeof useWindowSize > ) . mockReturnValue ( {
42+ width : 1200 ,
43+ height : 0 ,
44+ } ) ;
4545 } ) ;
4646
4747 it ( "displays loading state when data is being fetched" , ( ) => {
@@ -99,70 +99,6 @@ describe("Speakers2024 component", () => {
9999 originalModule . hideSpeakers = originalHideSpeakers ;
100100 } ) ;
101101
102- it . skip ( "displays CFP button when current date is within CFP period" , ( ) => {
103- // Mock the hook to return success state with data
104- mockedUseFetchSpeakers . mockReturnValue ( {
105- data : [ ] ,
106- isLoading : false ,
107- error : null ,
108- isSuccess : true ,
109- } ) ;
110-
111- // Mock Date to return a date within the CFP period
112- const originalDate = Date ;
113- const mockDate = new Date ( "2023-01-15" ) ;
114- global . Date = class extends Date {
115- constructor ( ) {
116- return mockDate ;
117- }
118-
119- static now ( ) {
120- return mockDate . getTime ( ) ;
121- }
122- } as unknown as typeof Date ;
123-
124- renderWithRouterAndQueryClient ( < Speakers2024 /> ) ;
125-
126- const cfpButton = screen . getByText ( / A p p l y t o b e a S p e a k e r / i) ;
127- expect ( cfpButton ) . toBeInTheDocument ( ) ;
128-
129- // Restore original Date
130- global . Date = originalDate ;
131- } ) ;
132-
133- it . skip ( "tracks CFP button clicks" , async ( ) => {
134- // Mock the hook to return success state with data
135- mockedUseFetchSpeakers . mockReturnValue ( {
136- data : [ ] ,
137- isLoading : false ,
138- error : null ,
139- isSuccess : true ,
140- } ) ;
141-
142- // Mock Date to return a date within the CFP period
143- const originalDate = Date ;
144- const mockDate = new Date ( "2023-01-15" ) ;
145- global . Date = class extends Date {
146- constructor ( ) {
147- return mockDate ;
148- }
149-
150- static now ( ) {
151- return mockDate . getTime ( ) ;
152- }
153- } as unknown as typeof Date ;
154-
155- renderWithRouterAndQueryClient ( < Speakers2024 /> ) ;
156-
157- const cfpButton = screen . getByText ( / A p p l y t o b e a S p e a k e r / i) ;
158- await userEvent . click ( cfpButton ) ;
159-
160- expect ( gaEventTracker ) . toHaveBeenCalledWith ( "CFP" , "CFP" ) ;
161-
162- // Restore original Date
163- global . Date = originalDate ;
164- } ) ;
165-
166102 it ( "calls useFetchSpeakers with the correct year" , ( ) => {
167103 // Mock the hook to return loading state
168104 mockedUseFetchSpeakers . mockReturnValue ( {
0 commit comments