11import { mockAppRoot } from '@rocket.chat/mock-providers' ;
2- import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts' ;
32import { renderHook } from '@testing-library/react' ;
43
54import { useRoomMenuActions } from './useRoomMenuActions' ;
6- import { createFakeRoom , createFakeSubscription } from '../../../../../tests/mocks/data' ;
5+ import { createFakeSubscription } from '../../../../../tests/mocks/data' ;
76
8- const mockRoom = createFakeRoom ( { _id : 'room1' , t : 'c' , name : 'room1' , fname : 'Room 1' } ) ;
9- const mockSubscription = createFakeSubscription ( { name : 'room1' , t : 'c' , disableNotifications : false , rid : 'room1' } ) ;
7+ const mockSubscription = createFakeSubscription ( { name : 'room1' , fname : 'Room 1' , t : 'c' , disableNotifications : false , rid : 'room1' } ) ;
108
119jest . mock ( '../../../../../client/lib/rooms/roomCoordinator' , ( ) => ( {
1210 roomCoordinator : {
@@ -42,7 +40,7 @@ describe('useRoomMenuActions', () => {
4240 it ( 'should return all menu options for normal rooms' , ( ) => {
4341 const { result } = renderHook ( ( ) => useRoomMenuActions ( mockHookProps ) , {
4442 wrapper : mockAppRoot ( )
45- . withSubscriptions ( [ { ...mockSubscription , rid : 'room1' } ] as unknown as SubscriptionWithRoom [ ] )
43+ . withSubscription ( { ...mockSubscription , rid : 'room1' } )
4644 . withPermission ( 'leave-c' )
4745 . withPermission ( 'leave-p' )
4846 . withSetting ( 'Favorite_Rooms' , true )
@@ -59,7 +57,7 @@ describe('useRoomMenuActions', () => {
5957 it ( 'should return priorities section for omnichannel room' , ( ) => {
6058 const { result } = renderHook ( ( ) => useRoomMenuActions ( { ...mockHookProps , type : 'l' } ) , {
6159 wrapper : mockAppRoot ( )
62- . withSubscriptions ( [ { ...mockSubscription , ... mockRoom , t : 'l' } ] as unknown as SubscriptionWithRoom [ ] )
60+ . withSubscription ( { ...mockSubscription , t : 'l' } )
6361 . withPermission ( 'leave-c' )
6462 . withPermission ( 'leave-p' )
6563 . withSetting ( 'Favorite_Rooms' , true )
@@ -76,7 +74,7 @@ describe('useRoomMenuActions', () => {
7674 it ( 'should not return any menu option if hideDefaultOptions' , ( ) => {
7775 const { result } = renderHook ( ( ) => useRoomMenuActions ( { ...mockHookProps , hideDefaultOptions : true } ) , {
7876 wrapper : mockAppRoot ( )
79- . withSubscriptions ( [ { ... mockSubscription , ... mockRoom } ] as unknown as SubscriptionWithRoom [ ] )
77+ . withSubscription ( mockSubscription )
8078 . withPermission ( 'leave-c' )
8179 . withPermission ( 'leave-p' )
8280 . withSetting ( 'Favorite_Rooms' , true )
@@ -89,7 +87,7 @@ describe('useRoomMenuActions', () => {
8987 it ( 'should not return favorite room option if setting is disabled' , ( ) => {
9088 const { result } = renderHook ( ( ) => useRoomMenuActions ( mockHookProps ) , {
9189 wrapper : mockAppRoot ( )
92- . withSubscriptions ( [ { ... mockSubscription , ... mockRoom } ] as unknown as SubscriptionWithRoom [ ] )
90+ . withSubscription ( mockSubscription )
9391 . withPermission ( 'leave-c' )
9492 . withPermission ( 'leave-p' )
9593 . withSetting ( 'Favorite_Rooms' , false )
0 commit comments