@@ -237,6 +237,7 @@ describe("MatrixClient", function() {
237237 it ( "should get (unstable) file trees with valid state" , async ( ) => {
238238 const roomId = "!room:example.org" ;
239239 const mockRoom = {
240+ getMyMembership : ( ) => "join" ,
240241 currentState : {
241242 getStateEvents : ( eventType , stateKey ) => {
242243 if ( eventType === EventType . RoomCreate ) {
@@ -270,9 +271,33 @@ describe("MatrixClient", function() {
270271 expect ( tree . room ) . toBe ( mockRoom ) ;
271272 } ) ;
272273
274+ it ( "should not get (unstable) file trees if not joined" , async ( ) => {
275+ const roomId = "!room:example.org" ;
276+ const mockRoom = {
277+ getMyMembership : ( ) => "leave" , // "not join"
278+ } ;
279+ client . getRoom = ( getRoomId ) => {
280+ expect ( getRoomId ) . toEqual ( roomId ) ;
281+ return mockRoom ;
282+ } ;
283+ const tree = client . unstableGetFileTreeSpace ( roomId ) ;
284+ expect ( tree ) . toBeFalsy ( ) ;
285+ } ) ;
286+
287+ it ( "should not get (unstable) file trees for unknown rooms" , async ( ) => {
288+ const roomId = "!room:example.org" ;
289+ client . getRoom = ( getRoomId ) => {
290+ expect ( getRoomId ) . toEqual ( roomId ) ;
291+ return null ; // imply unknown
292+ } ;
293+ const tree = client . unstableGetFileTreeSpace ( roomId ) ;
294+ expect ( tree ) . toBeFalsy ( ) ;
295+ } ) ;
296+
273297 it ( "should not get (unstable) file trees with invalid create contents" , async ( ) => {
274298 const roomId = "!room:example.org" ;
275299 const mockRoom = {
300+ getMyMembership : ( ) => "join" ,
276301 currentState : {
277302 getStateEvents : ( eventType , stateKey ) => {
278303 if ( eventType === EventType . RoomCreate ) {
@@ -307,6 +332,7 @@ describe("MatrixClient", function() {
307332 it ( "should not get (unstable) file trees with invalid purpose/subtype contents" , async ( ) => {
308333 const roomId = "!room:example.org" ;
309334 const mockRoom = {
335+ getMyMembership : ( ) => "join" ,
310336 currentState : {
311337 getStateEvents : ( eventType , stateKey ) => {
312338 if ( eventType === EventType . RoomCreate ) {
0 commit comments