@@ -2598,13 +2598,30 @@ describe('[Rooms]', () => {
25982598
25992599 describe ( '/rooms.delete' , ( ) => {
26002600 let testChannel : IRoom ;
2601+ let testTeam : ITeam ;
2602+ let testUser : IUser ;
2603+ let testUser2 : IUser ;
2604+ let userCredentials : Credentials ;
26012605
2602- before ( 'create an channel' , async ( ) => {
2603- const result = await createRoom ( { type : 'c' , name : `channel.test.${ Date . now ( ) } -${ Math . random ( ) } ` } ) ;
2604- testChannel = result . body . channel ;
2606+ before ( 'create channel and team' , async ( ) => {
2607+ testUser = await createUser ( ) ;
2608+ testUser2 = await createUser ( ) ;
2609+ userCredentials = await login ( testUser . username , password ) ;
2610+
2611+ const {
2612+ body : { channel } ,
2613+ } = await createRoom ( { type : 'c' , name : `channel.test.${ Date . now ( ) } -${ Math . random ( ) } ` } ) ;
2614+ testChannel = channel ;
2615+ testTeam = await createTeam ( userCredentials , `team.test.${ Date . now ( ) } -${ Math . random ( ) } ` , TEAM_TYPE . PUBLIC , [
2616+ testUser . username as string ,
2617+ testUser2 . username as string ,
2618+ ] ) ;
26052619 } ) ;
26062620
2607- after ( ( ) => deleteRoom ( { type : 'c' , roomId : testChannel . _id } ) ) ;
2621+ after ( 'delete channel and team' , async ( ) => {
2622+ await deleteTeam ( userCredentials , testTeam . name ) ;
2623+ await deleteRoom ( { type : 'c' , roomId : testChannel . _id } ) ;
2624+ } ) ;
26082625
26092626 it ( 'should throw an error when roomId is not provided' , ( done ) => {
26102627 void request
@@ -2643,6 +2660,18 @@ describe('[Rooms]', () => {
26432660 } )
26442661 . end ( done ) ;
26452662 } ) ;
2663+ it ( 'should throw an error when room is a main team room' , ( done ) => {
2664+ void request
2665+ . post ( api ( 'rooms.delete' ) )
2666+ . set ( credentials )
2667+ . send ( { roomId : testTeam . roomId } )
2668+ . expect ( 'Content-Type' , 'application/json' )
2669+ . expect ( 400 )
2670+ . expect ( ( res ) => {
2671+ expect ( res . body ) . to . have . property ( 'success' , false ) ;
2672+ } )
2673+ . end ( done ) ;
2674+ } ) ;
26462675 } ) ;
26472676
26482677 describe ( 'rooms.saveRoomSettings' , ( ) => {
0 commit comments