@@ -24,16 +24,18 @@ import { mocked } from 'jest-mock';
2424
2525import SpaceStore from "../../../../src/stores/spaces/SpaceStore" ;
2626import { MetaSpace } from "../../../../src/stores/spaces" ;
27- import RoomListHeader from "../../../../src/components/views/rooms/RoomListHeader" ;
27+ import _RoomListHeader from "../../../../src/components/views/rooms/RoomListHeader" ;
2828import * as testUtils from "../../../test-utils" ;
29- import { createTestClient , mkSpace } from "../../../test-utils" ;
29+ import { stubClient , mkSpace } from "../../../test-utils" ;
3030import DMRoomMap from "../../../../src/utils/DMRoomMap" ;
31- import MatrixClientContext from "../../../../src/contexts/MatrixClientContext " ;
31+ import { MatrixClientPeg } from "../../../../src/MatrixClientPeg " ;
3232import SettingsStore from "../../../../src/settings/SettingsStore" ;
3333import { SettingLevel } from "../../../../src/settings/SettingLevel" ;
3434import { shouldShowComponent } from '../../../../src/customisations/helpers/UIComponents' ;
3535import { UIComponent } from '../../../../src/settings/UIFeature' ;
3636
37+ const RoomListHeader = testUtils . wrapInMatrixClientContext ( _RoomListHeader ) ;
38+
3739jest . mock ( '../../../../src/customisations/helpers/UIComponents' , ( ) => ( {
3840 shouldShowComponent : jest . fn ( ) ,
3941} ) ) ;
@@ -55,9 +57,7 @@ const setupMainMenu = async (client: MatrixClient, testSpace: Room): Promise<Rea
5557 SpaceStore . instance . setActiveSpace ( testSpace . roomId ) ;
5658 } ) ;
5759
58- const wrapper = mount ( < MatrixClientContext . Provider value = { client } >
59- < RoomListHeader />
60- </ MatrixClientContext . Provider > ) ;
60+ const wrapper = mount ( < RoomListHeader /> ) ;
6161
6262 expect ( wrapper . text ( ) ) . toBe ( "Test Space" ) ;
6363 act ( ( ) => {
@@ -74,9 +74,7 @@ const setupPlusMenu = async (client: MatrixClient, testSpace: Room): Promise<Rea
7474 SpaceStore . instance . setActiveSpace ( testSpace . roomId ) ;
7575 } ) ;
7676
77- const wrapper = mount ( < MatrixClientContext . Provider value = { client } >
78- < RoomListHeader />
79- </ MatrixClientContext . Provider > ) ;
77+ const wrapper = mount ( < RoomListHeader /> ) ;
8078
8179 expect ( wrapper . text ( ) ) . toBe ( "Test Space" ) ;
8280 act ( ( ) => {
@@ -116,7 +114,8 @@ describe("RoomListHeader", () => {
116114 getDMRoomsForUserId : jest . fn ( ) ,
117115 } as unknown as DMRoomMap ;
118116 DMRoomMap . setShared ( dmRoomMap ) ;
119- client = createTestClient ( ) ;
117+ stubClient ( ) ;
118+ client = MatrixClientPeg . get ( ) ;
120119 mocked ( shouldShowComponent ) . mockReturnValue ( true ) ; // show all UIComponents
121120 } ) ;
122121
@@ -125,9 +124,7 @@ describe("RoomListHeader", () => {
125124 SpaceStore . instance . setActiveSpace ( MetaSpace . Home ) ;
126125 } ) ;
127126
128- const wrapper = mount ( < MatrixClientContext . Provider value = { client } >
129- < RoomListHeader />
130- </ MatrixClientContext . Provider > ) ;
127+ const wrapper = mount ( < RoomListHeader /> ) ;
131128
132129 expect ( wrapper . text ( ) ) . toBe ( "Home" ) ;
133130 act ( ( ) => {
0 commit comments