1- import type { IRoom , ISubscription } from '@rocket.chat/core-typings' ;
21import { mockAppRoot } from '@rocket.chat/mock-providers' ;
3- import type { SubscriptionWithRoom } from '@rocket.chat/ui-contexts' ;
42import { render , screen } from '@testing-library/react' ;
53
64import SidebarItemBadges from './SidebarItemBadges' ;
75import { createFakeSubscription } from '../../../tests/mocks/data' ;
86
97jest . mock ( '../../views/omnichannel/components/OmnichannelBadges' , ( ) => ( {
108 __esModule : true ,
11- default : ( ) => < div data-testid = 'omnichannel-badges' > OmnichannelBadges</ div > ,
9+ default : ( ) => < i role = 'status' aria-label = ' OmnichannelBadges' / >,
1210} ) ) ;
1311
14- const createRoomWithSubscription = ( overrides : Partial < SubscriptionWithRoom > = { } ) => {
15- return createFakeSubscription ( overrides ) as unknown as IRoom & ISubscription ;
16- } ;
17-
1812describe ( 'SidebarItemBadges' , ( ) => {
1913 const appRoot = mockAppRoot ( )
2014 . withTranslations ( 'en' , 'core' , {
@@ -30,32 +24,30 @@ describe('SidebarItemBadges', () => {
3024 } ) ;
3125
3226 it ( 'should render UnreadBadge when there are unread messages' , ( ) => {
33- render (
34- < SidebarItemBadges room = { createRoomWithSubscription ( { unread : 1 , userMentions : 1 , groupMentions : 0 } ) } roomTitle = 'Test Room' /> ,
35- { wrapper : appRoot } ,
36- ) ;
27+ render ( < SidebarItemBadges room = { createFakeSubscription ( { unread : 1 , userMentions : 1 , groupMentions : 0 } ) } roomTitle = 'Test Room' /> , {
28+ wrapper : appRoot ,
29+ } ) ;
3730
3831 expect ( screen . getByRole ( 'status' , { name : '1 mention from Test Room' } ) ) . toBeInTheDocument ( ) ;
3932 } ) ;
4033
4134 it ( 'should not render UnreadBadge when there are no unread messages' , ( ) => {
42- render (
43- < SidebarItemBadges room = { createRoomWithSubscription ( { unread : 0 , userMentions : 0 , groupMentions : 0 } ) } roomTitle = 'Test Room' /> ,
44- { wrapper : appRoot } ,
45- ) ;
35+ render ( < SidebarItemBadges room = { createFakeSubscription ( { unread : 0 , userMentions : 0 , groupMentions : 0 } ) } roomTitle = 'Test Room' /> , {
36+ wrapper : appRoot ,
37+ } ) ;
4638
4739 expect ( screen . queryByRole ( 'status' , { name : 'Test Room' } ) ) . not . toBeInTheDocument ( ) ;
4840 } ) ;
4941
5042 it ( 'should render OmnichannelBadges when the room is an omnichannel room' , ( ) => {
51- render ( < SidebarItemBadges room = { createRoomWithSubscription ( { t : 'l' } ) } /> , { wrapper : appRoot } ) ;
43+ render ( < SidebarItemBadges room = { createFakeSubscription ( { t : 'l' } ) } /> , { wrapper : appRoot } ) ;
5244
53- expect ( screen . getByTestId ( 'omnichannel-badges' ) ) . toBeInTheDocument ( ) ;
45+ expect ( screen . getByRole ( 'status' , { name : 'OmnichannelBadges' } ) ) . toBeInTheDocument ( ) ;
5446 } ) ;
5547
5648 it ( 'should not render OmnichannelBadges when the room is not an omnichannel room' , ( ) => {
57- render ( < SidebarItemBadges room = { createRoomWithSubscription ( { t : 'p' } ) } /> , { wrapper : appRoot } ) ;
49+ render ( < SidebarItemBadges room = { createFakeSubscription ( { t : 'p' } ) } /> , { wrapper : appRoot } ) ;
5850
59- expect ( screen . queryByTestId ( 'omnichannel-badges' ) ) . not . toBeInTheDocument ( ) ;
51+ expect ( screen . queryByRole ( 'status' , { name : 'OmnichannelBadges' } ) ) . not . toBeInTheDocument ( ) ;
6052 } ) ;
6153} ) ;
0 commit comments