@@ -8,14 +8,14 @@ import { renderHook } from "jest-matrix-react";
88import { act , type SyntheticEvent } from "react" ;
99
1010import { useRoomTopicViewModel } from "../../../../../src/components/viewmodels/right_panel/RoomSummaryCardTopicViewModel" ;
11- import { mkStubRoom , stubClient } from "../../../../test-utils" ;
11+ import { createTestClient , mkStubRoom } from "../../../../test-utils" ;
1212import defaultDispatcher from "../../../../../src/dispatcher/dispatcher" ;
1313import { onRoomTopicLinkClick } from "../../../../../src/components/views/elements/RoomTopic" ;
1414
1515jest . mock ( "../../../../../src/components/views/elements/RoomTopic" ) ;
1616
1717describe ( "RoomSummaryCardTopicViewModel" , ( ) => {
18- const client = stubClient ( ) ;
18+ const client = createTestClient ( ) ;
1919 const mockRoom = mkStubRoom ( "!room:example.com" , "Test Room" , client ) ;
2020 const mockUserId = "@user:example.com" ;
2121 const mockEvent = { preventDefault : jest . fn ( ) , stopPropagation : jest . fn ( ) } as unknown as SyntheticEvent ;
@@ -41,10 +41,10 @@ describe("RoomSummaryCardTopicViewModel", () => {
4141 expect ( result . current . expanded ) . toBe ( true ) ;
4242 } ) ;
4343
44- it ( "should toggle expanded state on click" , ( ) => {
44+ it ( "should toggle expanded state on click" , async ( ) => {
4545 const { result } = render ( ) ;
4646
47- act ( ( ) => {
47+ await act ( ( ) => {
4848 result . current . onExpandedClick ( mockEvent ) ;
4949 } ) ;
5050
@@ -59,17 +59,19 @@ describe("RoomSummaryCardTopicViewModel", () => {
5959
6060 it ( "should handle topic link clicks when the target is an anchor element" , ( ) => {
6161 const { result } = render ( ) ;
62- const mockAnchorEvent = { target : document . createElement ( "a" ) } ;
62+ const mockAnchorEvent = { target : document . createElement ( "a" ) } as unknown as React . MouseEvent < HTMLElement > ;
6363
64- result . current . onTopicLinkClick ( mockAnchorEvent as any ) ;
65- expect ( onRoomTopicLinkClick ) . toHaveBeenCalledWith ( mockAnchorEvent as any ) ;
64+ result . current . onTopicLinkClick ( mockAnchorEvent ) ;
65+ expect ( onRoomTopicLinkClick ) . toHaveBeenCalledWith ( mockAnchorEvent ) ;
6666 } ) ;
6767
6868 it ( "should handle topic link clicks when the target is not an anchor element" , ( ) => {
6969 const { result } = render ( ) ;
70- const mockNonAnchorEvent = { target : document . createElement ( "div" ) } ;
70+ const mockNonAnchorEvent = {
71+ target : document . createElement ( "div" ) ,
72+ } as unknown as React . MouseEvent < HTMLElement > ;
7173
72- result . current . onTopicLinkClick ( mockNonAnchorEvent as any ) ;
74+ result . current . onTopicLinkClick ( mockNonAnchorEvent ) ;
7375 expect ( onRoomTopicLinkClick ) . not . toHaveBeenCalled ( ) ;
7476 } ) ;
7577
0 commit comments