11import React , { useState } from 'react' ;
22import { Text } from 'react-native' ;
3+
4+ import { act } from 'react-test-renderer' ;
5+
36import { render , waitFor } from '@testing-library/react-native' ;
47import type { Channel , ChannelResponse , Event , StreamChat } from 'stream-chat' ;
8+
59import { ChatContext , useChannelUpdated } from '../../../../../index' ;
6- import { act } from 'react-test-renderer' ;
710
811describe ( 'useChannelUpdated' , ( ) => {
912 it ( "defaults to the channels own_capabilities if the event doesn't include it" , async ( ) => {
10- let eventHanler : ( event : Event ) => any ;
13+ let eventHanler : ( event : Event ) => void ;
1114 const mockChannel = {
1215 cid : 'channeltype:123abc' ,
1316 data : {
@@ -25,10 +28,10 @@ describe('useChannelUpdated', () => {
2528 } ;
2629
2730 const mockClient = {
28- on : jest . fn ( ) . mockImplementation ( ( _eventName : string , handler : ( event : Event ) => any ) => {
31+ off : jest . fn ( ) ,
32+ on : jest . fn ( ) . mockImplementation ( ( _eventName : string , handler : ( event : Event ) => void ) => {
2933 eventHanler = handler ;
3034 } ) ,
31- off : jest . fn ( ) ,
3235 } as unknown as StreamChat ;
3336
3437 const TestComponent = ( ) => {
@@ -38,7 +41,9 @@ describe('useChannelUpdated', () => {
3841
3942 if (
4043 channels [ 0 ] . data ?. own_capabilities &&
41- Object . keys ( channels [ 0 ] . data ?. own_capabilities as any ) . includes ( 'send_messages' )
44+ Object . keys ( channels [ 0 ] . data ?. own_capabilities as { [ key : string ] : boolean } ) . includes (
45+ 'send_messages' ,
46+ )
4247 ) {
4348 return < Text > Send messages enabled</ Text > ;
4449 }
0 commit comments