Skip to content

Commit 4d76e27

Browse files
NicolasBonetclaude
andcommitted
Fix lint errors in AIRulesSection tests
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9dbf62e commit 4d76e27

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

tests/ui/AIRulesSectionTest.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ const mockedNavigate = jest.mocked(Navigation.navigate);
6666
const POLICY_ID = 'POLICY_ID_1';
6767

6868
function 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

7272
function 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+
7678
describe('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

Comments
 (0)