@@ -24,6 +24,8 @@ import { stubClient, mkStubRoom, wrapInMatrixClientContext } from "../../../test
2424import _VoiceChannelRadio from "../../../../src/components/views/voip/VoiceChannelRadio" ;
2525import VoiceChannelStore , { VoiceChannelEvent } from "../../../../src/stores/VoiceChannelStore" ;
2626import DMRoomMap from "../../../../src/utils/DMRoomMap" ;
27+ import { mocked } from "jest-mock" ;
28+ import { MatrixClientPeg } from "../../../../src/MatrixClientPeg" ;
2729
2830const VoiceChannelRadio = wrapInMatrixClientContext ( _VoiceChannelRadio ) ;
2931
@@ -64,17 +66,20 @@ class StubVoiceChannelStore extends EventEmitter {
6466}
6567
6668describe ( "VoiceChannelRadio" , ( ) => {
67- const room = mkStubRoom ( "!1:example.org" ) ;
68- room . isCallRoom . mockReturnValue ( true ) ;
69+ const cli = mocked ( MatrixClientPeg . get ( ) ) ;
70+ const room = mkStubRoom ( "!1:example.org" , "voice channel" , cli ) ;
71+ room . isCallRoom = ( ) => true ;
6972
7073 beforeEach ( ( ) => {
7174 stubClient ( ) ;
7275 DMRoomMap . makeShared ( ) ;
7376 // Stub out the VoiceChannelStore
74- jest . spyOn ( VoiceChannelStore , "instance" , "get" ) . mockReturnValue ( new StubVoiceChannelStore ( ) ) ;
77+ jest . spyOn ( VoiceChannelStore , "instance" , "get" )
78+ . mockReturnValue ( new StubVoiceChannelStore ( ) as unknown as VoiceChannelStore ) ;
7579 } ) ;
7680
7781 it ( "shows when connecting voice" , async ( ) => {
82+ // @ts -ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
7883 const radio = mount ( < VoiceChannelRadio /> ) ;
7984 expect ( radio . children ( ) . children ( ) . exists ( ) ) . toEqual ( false ) ;
8085
@@ -85,6 +90,7 @@ describe("VoiceChannelRadio", () => {
8590
8691 it ( "hides when disconnecting voice" , ( ) => {
8792 VoiceChannelStore . instance . connect ( "!1:example.org" ) ;
93+ // @ts -ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
8894 const radio = mount ( < VoiceChannelRadio /> ) ;
8995 expect ( radio . children ( ) . children ( ) . exists ( ) ) . toEqual ( true ) ;
9096
@@ -96,6 +102,7 @@ describe("VoiceChannelRadio", () => {
96102 describe ( "disconnect button" , ( ) => {
97103 it ( "works" , ( ) => {
98104 VoiceChannelStore . instance . connect ( "!1:example.org" ) ;
105+ // @ts -ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
99106 const radio = mount ( < VoiceChannelRadio /> ) ;
100107
101108 act ( ( ) => {
@@ -108,6 +115,7 @@ describe("VoiceChannelRadio", () => {
108115 describe ( "video button" , ( ) => {
109116 it ( "works" , ( ) => {
110117 VoiceChannelStore . instance . connect ( "!1:example.org" ) ;
118+ // @ts -ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
111119 const radio = mount ( < VoiceChannelRadio /> ) ;
112120
113121 act ( ( ) => {
@@ -125,6 +133,7 @@ describe("VoiceChannelRadio", () => {
125133 describe ( "audio button" , ( ) => {
126134 it ( "works" , ( ) => {
127135 VoiceChannelStore . instance . connect ( "!1:example.org" ) ;
136+ // @ts -ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
128137 const radio = mount ( < VoiceChannelRadio /> ) ;
129138
130139 act ( ( ) => {
0 commit comments