@@ -66,13 +66,15 @@ const mockedNavigate = jest.mocked(Navigation.navigate);
6666const POLICY_ID = 'POLICY_ID_1' ;
6767
6868function setPolicyAIRules ( aiRules : Record < string , unknown > | undefined ) {
69- mockedUsePolicy . mockReturnValue ( { rules : { aiRules} } as ReturnType < typeof usePolicy > ) ;
69+ ( mockedUsePolicy as jest . Mock ) . mockReturnValue ( { rules : { aiRules} } ) ;
7070}
7171
7272function getRuleTitles ( ) : string [ ] {
73- return mockedMenuItemWithTopDescription . mock . calls . map ( ( call ) => call . at ( 0 ) ?. title as string ) ;
73+ return mockedMenuItemWithTopDescription . mock . calls . map ( ( call ) => String ( call . at ( 0 ) ?. title ?? '' ) ) ;
7474}
7575
76+ const mockKeyboardEvent = new KeyboardEvent ( 'keydown' ) ;
77+
7678describe ( 'AIRulesSection' , ( ) => {
7779 beforeEach ( ( ) => {
7880 jest . clearAllMocks ( ) ;
@@ -223,7 +225,7 @@ describe('AIRulesSection', () => {
223225 ) ;
224226
225227 const onPress = mockedMenuItem . mock . calls . at ( 0 ) ?. at ( 0 ) ?. onPress ;
226- onPress ?.( { } as never ) ;
228+ onPress ?.( mockKeyboardEvent ) ;
227229
228230 expect ( mockedNavigate ) . toHaveBeenCalledWith ( ROUTES . RULES_AI_NEW . getRoute ( POLICY_ID ) ) ;
229231 } ) ;
@@ -241,7 +243,7 @@ describe('AIRulesSection', () => {
241243 ) ;
242244
243245 const onPress = mockedMenuItem . mock . calls . at ( 0 ) ?. at ( 0 ) ?. onPress ;
244- onPress ?.( { } as never ) ;
246+ onPress ?.( mockKeyboardEvent ) ;
245247
246248 expect ( showReadOnlyModal ) . toHaveBeenCalledTimes ( 1 ) ;
247249 expect ( mockedNavigate ) . not . toHaveBeenCalled ( ) ;
@@ -263,7 +265,7 @@ describe('AIRulesSection', () => {
263265 ) ;
264266
265267 const onPress = mockedMenuItemWithTopDescription . mock . calls . at ( 0 ) ?. at ( 0 ) ?. onPress ;
266- onPress ?.( { } as never ) ;
268+ onPress ?.( mockKeyboardEvent ) ;
267269
268270 expect ( mockedNavigate ) . toHaveBeenCalledWith ( ROUTES . RULES_AI_EDIT . getRoute ( POLICY_ID , 'r1' ) ) ;
269271 } ) ;
@@ -283,7 +285,7 @@ describe('AIRulesSection', () => {
283285 ) ;
284286
285287 const onPress = mockedMenuItemWithTopDescription . mock . calls . at ( 0 ) ?. at ( 0 ) ?. onPress ;
286- onPress ?.( { } as never ) ;
288+ onPress ?.( mockKeyboardEvent ) ;
287289
288290 expect ( showReadOnlyModal ) . toHaveBeenCalledTimes ( 1 ) ;
289291 expect ( mockedNavigate ) . not . toHaveBeenCalled ( ) ;
0 commit comments